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 - 2025 (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 "comms/util/access.h"
16
17#include <ratio>
18
19namespace comms
20{
21
22namespace traits
23{
24
25namespace endian
26{
27
30
33
34} // namespace endian
35
36namespace units
37{
38
40struct Time {};
41
43struct Distance {};
44
46struct Speed {};
47
49struct Frequency {};
50
52struct Angle {};
53
55struct Current {};
56
58struct Voltage {};
59
61struct Memory {};
62
64using NanosecondsRatio = std::nano;
65
67using MicrosecondsRatio = std::micro;
68
70using MillisecondsRatio = std::milli;
71
73using SecondsRatio = std::ratio<1, 1>;
74
76using MinutesRatio = std::ratio<60>;
77
79using HoursRatio = std::ratio<60 * 60>;
80
82using DaysRatio = std::ratio<24L * 60 * 60>;
83
85using WeeksRatio = std::ratio<7L * 24 * 60 * 60>;
86
88using NanometersRatio = std::nano;
89
91using MicrometersRatio = std::micro;
92
94using MillimetersRatio = std::milli;
95
97using CentimetersRatio = std::centi;
98
100using MetersRatio = std::ratio<1, 1>;
101
103using KilometersRatio = std::kilo;
104
107 typename std::ratio_divide<NanometersRatio, SecondsRatio>::type;
108
111 typename std::ratio_divide<MicrometersRatio, SecondsRatio>::type;
112
115 typename std::ratio_divide<MillimetersRatio, SecondsRatio>::type;
116
119 typename std::ratio_divide<CentimetersRatio, SecondsRatio>::type;
120
123 typename std::ratio_divide<MetersRatio, SecondsRatio>::type;
124
127 typename std::ratio_divide<KilometersRatio, SecondsRatio>::type;
128
131 typename std::ratio_divide<KilometersRatio, HoursRatio>::type;
132
134using HzRatio = std::ratio<1, 1>;
135
137using KiloHzRatio = std::kilo;
138
140using MegaHzRatio = std::mega;
141
143using GigaHzRatio = std::giga;
144
146using DegreesRatio = std::ratio<1, 1>;
147
149using RadiansRatio = std::ratio<180, 1>;
150
152using NanoampsRatio = std::nano;
153
155using MicroampsRatio = std::micro;
156
158using MilliampsRatio = std::milli;
159
161using AmpsRatio = std::ratio<1, 1>;
162
164using KiloampsRatio = std::kilo;
165
167using NanovoltsRatio = std::nano;
168
170using MicrovoltsRatio = std::micro;
171
173using MillivoltsRatio = std::milli;
174
176using VoltsRatio = std::ratio<1, 1>;
177
179using KilovoltsRatio = std::kilo;
180
182using BytesRatio = std::ratio<1, 1>;
183
185using KilobytesRatio = std::ratio<1024, 1>;
186
188using MegabytesRatio = std::ratio<1024UL * 1024, 1>;
189
191using GigabytesRatio = std::ratio<1024ULL * 1024 * 1024, 1>;
192
194using TerabytesRatio = std::ratio<1024ULL * 1024 * 1024 * 1024, 1>;
195
196} // namespace units
197
198namespace dispatch
199{
200
202struct Polymorphic {};
203
206
208struct LinearSwitch {};
209
210} // namespace dispatch
211
212} // namespace traits
213
214} // namespace comms
215
Contains functions for raw data access / (de)serialization.
std::kilo KiloHzRatio
Ratio for kilohertz.
Definition traits.h:137
std::kilo KilovoltsRatio
Ratio for kilovolts.
Definition traits.h:179
std::nano NanosecondsRatio
Ratio for nanoseconds.
Definition traits.h:64
typename std::ratio_divide< MillimetersRatio, SecondsRatio >::type MillimetersPerSecondRatio
Ratio for millimeters / second.
Definition traits.h:115
std::ratio< 180, 1 > RadiansRatio
Ratio for radians.
Definition traits.h:149
std::nano NanometersRatio
Ratio for nanometers.
Definition traits.h:88
std::micro MicroampsRatio
Ratio for microamperes.
Definition traits.h:155
std::ratio< 1024ULL *1024 *1024, 1 > GigabytesRatio
Ratio for gigabytes.
Definition traits.h:191
std::milli MillisecondsRatio
Ratio for milliseconds.
Definition traits.h:70
typename std::ratio_divide< MicrometersRatio, SecondsRatio >::type MicrometersPerSecondRatio
Ratio for micrometers / second.
Definition traits.h:111
std::ratio< 1, 1 > BytesRatio
Ratio for bytes.
Definition traits.h:182
std::ratio< 1024, 1 > KilobytesRatio
Ratio for kilobytes.
Definition traits.h:185
std::ratio< 60 *60 > HoursRatio
Ratio for hours.
Definition traits.h:79
std::ratio< 1, 1 > SecondsRatio
Ratio for seconds.
Definition traits.h:73
typename std::ratio_divide< MetersRatio, SecondsRatio >::type MetersPerSecondRatio
Ratio for meters / second.
Definition traits.h:123
std::ratio< 60 > MinutesRatio
Ratio for minutes.
Definition traits.h:76
typename std::ratio_divide< KilometersRatio, SecondsRatio >::type KilometersPerSecondRatio
Ratio for kilometers / second.
Definition traits.h:127
typename std::ratio_divide< KilometersRatio, HoursRatio >::type KilometersPerHourRatio
Ratio for kilometers / hour.
Definition traits.h:131
typename std::ratio_divide< CentimetersRatio, SecondsRatio >::type CentimetersPerSecondRatio
Ratio for centimeters / second.
Definition traits.h:119
std::micro MicrosecondsRatio
Ratio for microseconds.
Definition traits.h:67
std::ratio< 1, 1 > MetersRatio
Ratio for meters.
Definition traits.h:100
std::ratio< 1, 1 > AmpsRatio
Ratio for amperes.
Definition traits.h:161
std::kilo KilometersRatio
Ratio for kilometers.
Definition traits.h:103
std::ratio< 1024UL *1024, 1 > MegabytesRatio
Ratio for megabytes.
Definition traits.h:188
std::giga GigaHzRatio
Ratio for gigahertz.
Definition traits.h:143
std::milli MilliampsRatio
Ratio for milliamperes.
Definition traits.h:158
std::milli MillivoltsRatio
Ratio for millivolts.
Definition traits.h:173
typename std::ratio_divide< NanometersRatio, SecondsRatio >::type NanometersPerSecondRatio
Ratio for nanometers / second.
Definition traits.h:107
std::kilo KiloampsRatio
Ratio for kiloamperes.
Definition traits.h:164
std::ratio< 7L *24 *60 *60 > WeeksRatio
Ratio for weeks.
Definition traits.h:85
std::ratio< 1, 1 > DegreesRatio
Ratio for degrees.
Definition traits.h:146
std::nano NanovoltsRatio
Ratio for nanovolts.
Definition traits.h:167
std::centi CentimetersRatio
Ratio for centimeters.
Definition traits.h:97
std::micro MicrovoltsRatio
Ratio for microvolts.
Definition traits.h:170
std::ratio< 24L *60 *60 > DaysRatio
Ratio for days.
Definition traits.h:82
std::ratio< 1, 1 > HzRatio
Ratio for hertz.
Definition traits.h:134
std::nano NanoampsRatio
Ratio for nanoamperes.
Definition traits.h:152
std::ratio< 1, 1 > VoltsRatio
Ratio for volts.
Definition traits.h:176
std::ratio< 1024ULL *1024 *1024 *1024, 1 > TerabytesRatio
Ratio for terabytes.
Definition traits.h:194
std::micro MicrometersRatio
Ratio for micrometers.
Definition traits.h:91
std::mega MegaHzRatio
Ratio for megahertz.
Definition traits.h:140
std::milli MillimetersRatio
Ratio for millimeters.
Definition traits.h:94
Main namespace for all classes / functions of COMMS library.
Tag class used to indicate linear switch dispatch.
Definition traits.h:208
Tag class used to indicate polymorphic dispatch.
Definition traits.h:202
Tag class used to indicate static binary search dispatch.
Definition traits.h:205
Tag class used to indicate angle value.
Definition traits.h:52
Tag class used to indicate electrical current value.
Definition traits.h:55
Tag class used to indicate distance value.
Definition traits.h:43
Tag class used to indicate frequency value.
Definition traits.h:49
Tag class used to indicate memory size value.
Definition traits.h:61
Tag class used to indicate speed value.
Definition traits.h:46
Tag class used to indicate time value.
Definition traits.h:40
Tag class used to indicate electrical voltage value.
Definition traits.h:58
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