COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
traits.h
Go to the documentation of this file.
1//
2// Copyright 2014 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
11
12
13#pragma once
14
15#include <ratio>
16#include "util/access.h"
17
18namespace comms
19{
20
21namespace traits
22{
23
24namespace endian
25{
26
29
32
33} // namespace endian
34
35namespace units
36{
37
39struct Time {};
40
42struct Distance {};
43
45struct Speed {};
46
48struct Frequency {};
49
51struct Angle {};
52
54struct Current {};
55
57struct Voltage {};
58
60struct Memory {};
61
63using NanosecondsRatio = std::nano;
64
66using MicrosecondsRatio = std::micro;
67
69using MillisecondsRatio = std::milli;
70
72using SecondsRatio = std::ratio<1, 1>;
73
75using MinutesRatio = std::ratio<60>;
76
78using HoursRatio = std::ratio<60 * 60>;
79
81using DaysRatio = std::ratio<24L * 60 * 60>;
82
84using WeeksRatio = std::ratio<7L * 24 * 60 * 60>;
85
87using NanometersRatio = std::nano;
88
90using MicrometersRatio = std::micro;
91
93using MillimetersRatio = std::milli;
94
96using CentimetersRatio = std::centi;
97
99using MetersRatio = std::ratio<1, 1>;
100
102using KilometersRatio = std::kilo;
103
106 typename std::ratio_divide<NanometersRatio, SecondsRatio>::type;
107
110 typename std::ratio_divide<MicrometersRatio, SecondsRatio>::type;
111
114 typename std::ratio_divide<MillimetersRatio, SecondsRatio>::type;
115
118 typename std::ratio_divide<CentimetersRatio, SecondsRatio>::type;
119
122 typename std::ratio_divide<MetersRatio, SecondsRatio>::type;
123
126 typename std::ratio_divide<KilometersRatio, SecondsRatio>::type;
127
130 typename std::ratio_divide<KilometersRatio, HoursRatio>::type;
131
133using HzRatio = std::ratio<1, 1>;
134
136using KiloHzRatio = std::kilo;
137
139using MegaHzRatio = std::mega;
140
142using GigaHzRatio = std::giga;
143
145using DegreesRatio = std::ratio<1, 1>;
146
148using RadiansRatio = std::ratio<180, 1>;
149
151using NanoampsRatio = std::nano;
152
154using MicroampsRatio = std::micro;
155
157using MilliampsRatio = std::milli;
158
160using AmpsRatio = std::ratio<1, 1>;
161
163using KiloampsRatio = std::kilo;
164
166using NanovoltsRatio = std::nano;
167
169using MicrovoltsRatio = std::micro;
170
172using MillivoltsRatio = std::milli;
173
175using VoltsRatio = std::ratio<1, 1>;
176
178using KilovoltsRatio = std::kilo;
179
181using BytesRatio = std::ratio<1, 1>;
182
184using KilobytesRatio = std::ratio<1024, 1>;
185
187using MegabytesRatio = std::ratio<1024UL * 1024, 1>;
188
190using GigabytesRatio = std::ratio<1024ULL * 1024 * 1024, 1>;
191
193using TerabytesRatio = std::ratio<1024ULL * 1024 * 1024 * 1024, 1>;
194
195} // namespace units
196
197namespace dispatch
198{
199
201struct Polymorphic {};
202
205
207struct LinearSwitch {};
208
209} // namespace dispatch
210
211} // namespace traits
212
213} // namespace comms
214
Contains functions for raw data access / (de)serialization.
std::kilo KiloHzRatio
Ratio for kilohertz.
Definition traits.h:136
std::kilo KilovoltsRatio
Ratio for kilovolts.
Definition traits.h:178
std::nano NanosecondsRatio
Ratio for nanoseconds.
Definition traits.h:63
typename std::ratio_divide< MillimetersRatio, SecondsRatio >::type MillimetersPerSecondRatio
Ratio for millimeters / second.
Definition traits.h:114
std::ratio< 180, 1 > RadiansRatio
Ratio for radians.
Definition traits.h:148
std::nano NanometersRatio
Ratio for nanometers.
Definition traits.h:87
std::micro MicroampsRatio
Ratio for microamperes.
Definition traits.h:154
std::ratio< 1024ULL *1024 *1024, 1 > GigabytesRatio
Ratio for gigabytes.
Definition traits.h:190
std::milli MillisecondsRatio
Ratio for milliseconds.
Definition traits.h:69
typename std::ratio_divide< MicrometersRatio, SecondsRatio >::type MicrometersPerSecondRatio
Ratio for micrometers / second.
Definition traits.h:110
std::ratio< 1, 1 > BytesRatio
Ratio for bytes.
Definition traits.h:181
std::ratio< 1024, 1 > KilobytesRatio
Ratio for kilobytes.
Definition traits.h:184
std::ratio< 60 *60 > HoursRatio
Ratio for hours.
Definition traits.h:78
std::ratio< 1, 1 > SecondsRatio
Ratio for seconds.
Definition traits.h:72
typename std::ratio_divide< MetersRatio, SecondsRatio >::type MetersPerSecondRatio
Ratio for meters / second.
Definition traits.h:122
std::ratio< 60 > MinutesRatio
Ratio for minutes.
Definition traits.h:75
typename std::ratio_divide< KilometersRatio, SecondsRatio >::type KilometersPerSecondRatio
Ratio for kilometers / second.
Definition traits.h:126
typename std::ratio_divide< KilometersRatio, HoursRatio >::type KilometersPerHourRatio
Ratio for kilometers / hour.
Definition traits.h:130
typename std::ratio_divide< CentimetersRatio, SecondsRatio >::type CentimetersPerSecondRatio
Ratio for centimeters / second.
Definition traits.h:118
std::micro MicrosecondsRatio
Ratio for microseconds.
Definition traits.h:66
std::ratio< 1, 1 > MetersRatio
Ratio for meters.
Definition traits.h:99
std::ratio< 1, 1 > AmpsRatio
Ratio for amperes.
Definition traits.h:160
std::kilo KilometersRatio
Ratio for kilometers.
Definition traits.h:102
std::ratio< 1024UL *1024, 1 > MegabytesRatio
Ratio for megabytes.
Definition traits.h:187
std::giga GigaHzRatio
Ratio for gigahertz.
Definition traits.h:142
std::milli MilliampsRatio
Ratio for milliamperes.
Definition traits.h:157
std::milli MillivoltsRatio
Ratio for millivolts.
Definition traits.h:172
typename std::ratio_divide< NanometersRatio, SecondsRatio >::type NanometersPerSecondRatio
Ratio for nanometers / second.
Definition traits.h:106
std::kilo KiloampsRatio
Ratio for kiloamperes.
Definition traits.h:163
std::ratio< 7L *24 *60 *60 > WeeksRatio
Ratio for weeks.
Definition traits.h:84
std::ratio< 1, 1 > DegreesRatio
Ratio for degrees.
Definition traits.h:145
std::nano NanovoltsRatio
Ratio for nanovolts.
Definition traits.h:166
std::centi CentimetersRatio
Ratio for centimeters.
Definition traits.h:96
std::micro MicrovoltsRatio
Ratio for microvolts.
Definition traits.h:169
std::ratio< 24L *60 *60 > DaysRatio
Ratio for days.
Definition traits.h:81
std::ratio< 1, 1 > HzRatio
Ratio for hertz.
Definition traits.h:133
std::nano NanoampsRatio
Ratio for nanoamperes.
Definition traits.h:151
std::ratio< 1, 1 > VoltsRatio
Ratio for volts.
Definition traits.h:175
std::ratio< 1024ULL *1024 *1024 *1024, 1 > TerabytesRatio
Ratio for terabytes.
Definition traits.h:193
std::micro MicrometersRatio
Ratio for micrometers.
Definition traits.h:90
std::mega MegaHzRatio
Ratio for megahertz.
Definition traits.h:139
std::milli MillimetersRatio
Ratio for millimeters.
Definition traits.h:93
Main namespace for all classes / functions of COMMS library.
Tag class used to indicate linear switch dispatch.
Definition traits.h:207
Tag class used to indicate polymorphic dispatch.
Definition traits.h:201
Tag class used to indicate static binary search dispatch.
Definition traits.h:204
Tag class used to indicate angle value.
Definition traits.h:51
Tag class used to indicate electrical current value.
Definition traits.h:54
Tag class used to indicate distance value.
Definition traits.h:42
Tag class used to indicate frequency value.
Definition traits.h:48
Tag class used to indicate memory size value.
Definition traits.h:60
Tag class used to indicate speed value.
Definition traits.h:45
Tag class used to indicate time value.
Definition traits.h:39
Tag class used to indicate electrical voltage value.
Definition traits.h:57
Empty class used in traits to indicate Big Endian.
Definition access.h:43
Empty class used in traits to indicate Little Endian.
Definition access.h:46