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 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: MPL-2.0
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
13
14#pragma once
15
16#include "comms/util/access.h"
17
18#include <ratio>
19
20namespace comms
21{
22
23namespace traits
24{
25
26namespace endian
27{
28
31
34
35} // namespace endian
36
37namespace units
38{
39
41struct Time {};
42
44struct Distance {};
45
47struct Speed {};
48
50struct Frequency {};
51
53struct Angle {};
54
56struct Current {};
57
59struct Voltage {};
60
62struct Memory {};
63
65using NanosecondsRatio = std::nano;
66
68using MicrosecondsRatio = std::micro;
69
71using MillisecondsRatio = std::milli;
72
74using SecondsRatio = std::ratio<1, 1>;
75
77using MinutesRatio = std::ratio<60>;
78
80using HoursRatio = std::ratio<60 * 60>;
81
83using DaysRatio = std::ratio<24L * 60 * 60>;
84
86using WeeksRatio = std::ratio<7L * 24 * 60 * 60>;
87
89using NanometersRatio = std::nano;
90
92using MicrometersRatio = std::micro;
93
95using MillimetersRatio = std::milli;
96
98using CentimetersRatio = std::centi;
99
101using MetersRatio = std::ratio<1, 1>;
102
104using KilometersRatio = std::kilo;
105
108 typename std::ratio_divide<NanometersRatio, SecondsRatio>::type;
109
112 typename std::ratio_divide<MicrometersRatio, SecondsRatio>::type;
113
116 typename std::ratio_divide<MillimetersRatio, SecondsRatio>::type;
117
120 typename std::ratio_divide<CentimetersRatio, SecondsRatio>::type;
121
124 typename std::ratio_divide<MetersRatio, SecondsRatio>::type;
125
128 typename std::ratio_divide<KilometersRatio, SecondsRatio>::type;
129
132 typename std::ratio_divide<KilometersRatio, HoursRatio>::type;
133
135using HzRatio = std::ratio<1, 1>;
136
138using KiloHzRatio = std::kilo;
139
141using MegaHzRatio = std::mega;
142
144using GigaHzRatio = std::giga;
145
147using DegreesRatio = std::ratio<1, 1>;
148
150using RadiansRatio = std::ratio<180, 1>;
151
153using NanoampsRatio = std::nano;
154
156using MicroampsRatio = std::micro;
157
159using MilliampsRatio = std::milli;
160
162using AmpsRatio = std::ratio<1, 1>;
163
165using KiloampsRatio = std::kilo;
166
168using NanovoltsRatio = std::nano;
169
171using MicrovoltsRatio = std::micro;
172
174using MillivoltsRatio = std::milli;
175
177using VoltsRatio = std::ratio<1, 1>;
178
180using KilovoltsRatio = std::kilo;
181
183using BytesRatio = std::ratio<1, 1>;
184
186using KilobytesRatio = std::ratio<1024, 1>;
187
189using MegabytesRatio = std::ratio<1024UL * 1024, 1>;
190
192using GigabytesRatio = std::ratio<1024ULL * 1024 * 1024, 1>;
193
195using TerabytesRatio = std::ratio<1024ULL * 1024 * 1024 * 1024, 1>;
196
197} // namespace units
198
199namespace dispatch
200{
201
203struct Polymorphic {};
204
207
209struct LinearSwitch {};
210
211} // namespace dispatch
212
213} // namespace traits
214
215} // namespace comms
216
Contains functions for raw data access / (de)serialization.
std::kilo KiloHzRatio
Ratio for kilohertz.
Definition traits.h:138
std::kilo KilovoltsRatio
Ratio for kilovolts.
Definition traits.h:180
std::nano NanosecondsRatio
Ratio for nanoseconds.
Definition traits.h:65
typename std::ratio_divide< MillimetersRatio, SecondsRatio >::type MillimetersPerSecondRatio
Ratio for millimeters / second.
Definition traits.h:116
std::ratio< 180, 1 > RadiansRatio
Ratio for radians.
Definition traits.h:150
std::nano NanometersRatio
Ratio for nanometers.
Definition traits.h:89
std::micro MicroampsRatio
Ratio for microamperes.
Definition traits.h:156
std::ratio< 1024ULL *1024 *1024, 1 > GigabytesRatio
Ratio for gigabytes.
Definition traits.h:192
std::milli MillisecondsRatio
Ratio for milliseconds.
Definition traits.h:71
typename std::ratio_divide< MicrometersRatio, SecondsRatio >::type MicrometersPerSecondRatio
Ratio for micrometers / second.
Definition traits.h:112
std::ratio< 1, 1 > BytesRatio
Ratio for bytes.
Definition traits.h:183
std::ratio< 1024, 1 > KilobytesRatio
Ratio for kilobytes.
Definition traits.h:186
std::ratio< 60 *60 > HoursRatio
Ratio for hours.
Definition traits.h:80
std::ratio< 1, 1 > SecondsRatio
Ratio for seconds.
Definition traits.h:74
typename std::ratio_divide< MetersRatio, SecondsRatio >::type MetersPerSecondRatio
Ratio for meters / second.
Definition traits.h:124
std::ratio< 60 > MinutesRatio
Ratio for minutes.
Definition traits.h:77
typename std::ratio_divide< KilometersRatio, SecondsRatio >::type KilometersPerSecondRatio
Ratio for kilometers / second.
Definition traits.h:128
typename std::ratio_divide< KilometersRatio, HoursRatio >::type KilometersPerHourRatio
Ratio for kilometers / hour.
Definition traits.h:132
typename std::ratio_divide< CentimetersRatio, SecondsRatio >::type CentimetersPerSecondRatio
Ratio for centimeters / second.
Definition traits.h:120
std::micro MicrosecondsRatio
Ratio for microseconds.
Definition traits.h:68
std::ratio< 1, 1 > MetersRatio
Ratio for meters.
Definition traits.h:101
std::ratio< 1, 1 > AmpsRatio
Ratio for amperes.
Definition traits.h:162
std::kilo KilometersRatio
Ratio for kilometers.
Definition traits.h:104
std::ratio< 1024UL *1024, 1 > MegabytesRatio
Ratio for megabytes.
Definition traits.h:189
std::giga GigaHzRatio
Ratio for gigahertz.
Definition traits.h:144
std::milli MilliampsRatio
Ratio for milliamperes.
Definition traits.h:159
std::milli MillivoltsRatio
Ratio for millivolts.
Definition traits.h:174
typename std::ratio_divide< NanometersRatio, SecondsRatio >::type NanometersPerSecondRatio
Ratio for nanometers / second.
Definition traits.h:108
std::kilo KiloampsRatio
Ratio for kiloamperes.
Definition traits.h:165
std::ratio< 7L *24 *60 *60 > WeeksRatio
Ratio for weeks.
Definition traits.h:86
std::ratio< 1, 1 > DegreesRatio
Ratio for degrees.
Definition traits.h:147
std::nano NanovoltsRatio
Ratio for nanovolts.
Definition traits.h:168
std::centi CentimetersRatio
Ratio for centimeters.
Definition traits.h:98
std::micro MicrovoltsRatio
Ratio for microvolts.
Definition traits.h:171
std::ratio< 24L *60 *60 > DaysRatio
Ratio for days.
Definition traits.h:83
std::ratio< 1, 1 > HzRatio
Ratio for hertz.
Definition traits.h:135
std::nano NanoampsRatio
Ratio for nanoamperes.
Definition traits.h:153
std::ratio< 1, 1 > VoltsRatio
Ratio for volts.
Definition traits.h:177
std::ratio< 1024ULL *1024 *1024 *1024, 1 > TerabytesRatio
Ratio for terabytes.
Definition traits.h:195
std::micro MicrometersRatio
Ratio for micrometers.
Definition traits.h:92
std::mega MegaHzRatio
Ratio for megahertz.
Definition traits.h:141
std::milli MillimetersRatio
Ratio for millimeters.
Definition traits.h:95
Main namespace for all classes / functions of COMMS library.
Tag class used to indicate linear switch dispatch.
Definition traits.h:209
Tag class used to indicate polymorphic dispatch.
Definition traits.h:203
Tag class used to indicate static binary search dispatch.
Definition traits.h:206
Tag class used to indicate angle value.
Definition traits.h:53
Tag class used to indicate electrical current value.
Definition traits.h:56
Tag class used to indicate distance value.
Definition traits.h:44
Tag class used to indicate frequency value.
Definition traits.h:50
Tag class used to indicate memory size value.
Definition traits.h:62
Tag class used to indicate speed value.
Definition traits.h:47
Tag class used to indicate time value.
Definition traits.h:41
Tag class used to indicate electrical voltage value.
Definition traits.h:59
Empty class used in traits to indicate Big Endian.
Definition access.h:44
Empty class used in traits to indicate Little Endian.
Definition access.h:47