Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
common_units.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_COMMON_UNITS_HPP_
5#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_COMMON_UNITS_HPP_
6
8#include "arene/base/stdlib_choice/ratio.hpp"
13
14namespace arene {
15namespace base {
16namespace units {
17
18namespace scales {
19/// @brief A class to represent a scale factor of Pi
20class pi {
21 public:
22 // parasoft-begin-suppress AUTOSAR-M11_0_1-a "This member is the public API"
23 /// @brief The value of the scale factor
24 static constexpr double value{arene::base::numbers::pi};
25 // parasoft-end-suppress AUTOSAR-M11_0_1-a
26};
27} // namespace scales
28
29/// @brief Base quantity kind for all numeric quantity kinds
30class number : public quantity_kind<number> {};
31
32/// @brief Base quantity kind for the linear extent in space between any two points
33class length;
34/// @brief The SI base quantity unit for length
35class meter : public quantity_unit<meter, length> {};
36/// @brief Base quantity kind for the linear extent in space between any two points
37class length : public quantity_kind<length, meter> {};
38
39/// @brief Base quantity kind for the property of a body which expresses itself in terms of inertia with regard to
40/// changes in its state of motion as well as its gravitational attraction to other bodies
41class mass;
42/// @brief A quantity unit for mass
43///
44/// This is used as the base unit, rather than @c kilogram so that the SI prefixes work appropriately, and we don't have
45/// @c kilokilogram or @c millikilogram
46///
47/// The default unit for @c mass is still @c kilogram
48class gram : public quantity_unit<gram, mass> {};
49/// @brief The SI base quantity unit for mass
51/// @brief Base quantity kind for thr property of a body which expresses itself in terms of inertia with regard to
52/// changes in its state of motion as well as its gravitational attraction to other bodies
53class mass : public quantity_kind<mass, kilogram> {};
54
55/// @brief Base quantity kind for the time difference between two events
56class time;
57/// @brief The SI base quantity unit for time
58class second : public quantity_unit<second, time> {};
59// parasoft-begin-suppress CERT_CPP-DCL51-f-3 "False positive: time not reserved in this context"
60/// @brief Base quantity kind for time
61class time : public quantity_kind<time, second> {};
62// parasoft-end-suppress CERT_CPP-DCL51-f-3
63
64/// @brief An alternative name for @c time
65using duration = time;
66
67/// @brief Base quantity kind for the quotient of the net electric charge transferred through a surface in a
68/// quasi-infinitessimal time interval, and the duration of that time interval
70/// @brief The SI base quantity unit for electric current
71class ampere : public quantity_unit<ampere, electric_current> {};
72/// @brief Base quantity kind for the quotient of the net electric charge transferred through a surface in a
73/// quasi-infinitessimal time interval, and the duration of that time interval
74class electric_current : public quantity_kind<electric_current, ampere> {};
75
76/// @brief A tag type for absolute zero, the origin of the Kelvin scale
77class absolute_zero : public quantity_origin<absolute_zero> {};
78
79/// @brief Base quantity kind for the partial derivative of internal energy with respect to entropy at constant volume
80/// and constant number of particles in the system
82/// @brief Alias for thermodynamic temperature
84/// @brief Base quantity kind for the partial derivative of internal energy with respect to entropy at constant volume
85/// and constant number of particles in the system
86class kelvin : public quantity_unit<kelvin, thermodynamic_temperature> {};
87/// @brief Base quantity kind for thermodynamic temperature
88class thermodynamic_temperature : public quantity_kind<thermodynamic_temperature, absolute_zero, kelvin> {};
89
90/// @brief Quantity kind for the number of entities of a given kind in a system
91class number_of_entities : public quantity_kind<number_of_entities, number> {};
92/// @brief Base quantity kind for the quotient of the number of entites of a given kind in a system and the Avogadro
93/// constant
95/// @brief The SI base quantity unit for amount of substance
96class mole : public quantity_unit<mole, amount_of_substance> {};
97/// @brief Base quantity kind for the quotient of the number of entites of a given kind in a system and the Avogadro
98/// constant
99class amount_of_substance : public quantity_kind<amount_of_substance, number_of_entities, mole> {};
100
101/// @brief Base quantity kind for the density of luminous flux with respect to solid angle in a specified direction
103/// @brief The SI base quantity unit for luminous intensity
104class candela : public quantity_unit<candela, luminous_intensity> {};
105/// @brief Base quantity kind for the density of luminous flux with respect to solid angle in a specified direction
106class luminous_intensity : public quantity_kind<luminous_intensity, candela> {};
107
108/// @brief A quantity unit for minutes
109// NOLINTNEXTLINE(readability-magic-numbers)
111/// @brief A quantity unit for hours
112// NOLINTNEXTLINE(readability-magic-numbers)
114/// @brief A quantity unit for milliseconds
116/// @brief A quantity unit for microseconds
118/// @brief A quantity unit for nanoseconds
120
121/// @brief A quantity unit for kilometers
123/// @brief A quantity unit for centimeters
125/// @brief A quantity unit for millimeters
127/// @brief A quantity unit for micrometers
129/// @brief A quantity unit for miles
130// NOLINTNEXTLINE(readability-magic-numbers)
132
133/// @brief A quantity unit for kilograms
135/// @brief A quantity unit for milligrams
137/// @brief A quantity unit for micrograms
139
140/// @brief An alternative name for Ampere
141using amp = ampere;
142/// @brief A quantity unit for milliamps
144
145/// @brief A quantity kind for a measure of a geometric figure formed by two rays emanating from a common point, given
146/// by the arc length of the included arc of a circle centred at the common point divided by the radius of that circle
147class angular_measure;
148
149/// @brief A quantity unit for @c angular_measure
150class radian : public quantity_unit<radian, angular_measure> {};
151
152/// @brief A quantity kind for a measure of a geometric figure formed by two rays emanating from a common point, given
153/// by the arc length of the included arc of a circle centred at the common point divided by the radius of that circle
154class angular_measure : public quantity_kind<angular_measure, number, radian> {};
155
156/// @brief An alternate name for @c angular_measure
158
159/// @brief A quantity unit for @c angular_measure
160///
161/// Pi radians is 180 degrees
163 : public quantity_unit<
164 angular_degree,
165 // NOLINTNEXTLINE(readability-magic-numbers)
166 scaled_unit<scaled_unit<radian, inverse_unit_scale_t<scales::pi>>, std::ratio<180, 1>>> {};
167
168} // namespace units
169} // namespace base
170} // namespace arene
171
172#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_COMMON_UNITS_HPP_
CRTP base class used when defining a new quantity origin, e.g. absolute zero for temperature.
Definition quantity_origin.hpp:92
Base class for declaring a quantity unit.
Definition quantity_unit.hpp:34
A tag type for absolute zero, the origin of the Kelvin scale.
Definition common_units.hpp:77
Base quantity kind for the quotient of the number of entites of a given kind in a system and the Avog...
Definition common_units.hpp:99
The SI base quantity unit for electric current.
Definition common_units.hpp:71
A quantity unit for angular_measure.
Definition common_units.hpp:166
A quantity kind for a measure of a geometric figure formed by two rays emanating from a common point,...
Definition common_units.hpp:154
The SI base quantity unit for luminous intensity.
Definition common_units.hpp:104
Base quantity kind for the quotient of the net electric charge transferred through a surface in a qua...
Definition common_units.hpp:74
A quantity unit for mass.
Definition common_units.hpp:48
Base quantity kind for the partial derivative of internal energy with respect to entropy at constant ...
Definition common_units.hpp:86
Base quantity kind for the linear extent in space between any two points.
Definition common_units.hpp:37
Base quantity kind for the density of luminous flux with respect to solid angle in a specified direct...
Definition common_units.hpp:106
Base quantity kind for thr property of a body which expresses itself in terms of inertia with regard ...
Definition common_units.hpp:53
The SI base quantity unit for length.
Definition common_units.hpp:35
The SI base quantity unit for amount of substance.
Definition common_units.hpp:96
Quantity kind for the number of entities of a given kind in a system.
Definition common_units.hpp:91
Base quantity kind for all numeric quantity kinds.
Definition common_units.hpp:30
A quantity unit for angular_measure.
Definition common_units.hpp:150
A class to represent a scale factor of Pi.
Definition common_units.hpp:20
static constexpr double value
The value of the scale factor.
Definition common_units.hpp:24
The SI base quantity unit for time.
Definition common_units.hpp:58
Base quantity kind for thermodynamic temperature.
Definition common_units.hpp:88
Base quantity kind for time.
Definition common_units.hpp:61
Definition common_units.hpp:18
Definition common_units.hpp:16
time duration
An alternative name for time.
Definition common_units.hpp:65
scaled_unit< meter, std::kilo > kilometer
A quantity unit for kilometers.
Definition common_units.hpp:122
ampere amp
An alternative name for Ampere.
Definition common_units.hpp:141
scaled_unit< meter, std::micro > micrometer
A quantity unit for micrometers.
Definition common_units.hpp:128
scaled_unit< second, std::ratio< 60, 1 > > minute
A quantity unit for minutes.
Definition common_units.hpp:110
scaled_unit< minute, std::ratio< 60, 1 > > hour
A quantity unit for hours.
Definition common_units.hpp:113
scaled_unit< second, std::micro > microsecond
A quantity unit for microseconds.
Definition common_units.hpp:117
scaled_unit< meter, std::ratio< 1609344, 1000 > > mile
A quantity unit for miles.
Definition common_units.hpp:131
scaled_unit< gram, std::milli > milligram
A quantity unit for milligrams.
Definition common_units.hpp:136
angular_measure plane_angle
An alternate name for angular_measure.
Definition common_units.hpp:157
scaled_unit< meter, std::milli > millimeter
A quantity unit for millimeters.
Definition common_units.hpp:126
scaled_unit< gram, std::micro > microgram
A quantity unit for micrograms.
Definition common_units.hpp:138
scaled_unit< second, std::milli > millisecond
A quantity unit for milliseconds.
Definition common_units.hpp:115
scaled_unit< meter, std::centi > centimeter
A quantity unit for centimeters.
Definition common_units.hpp:124
scaled_unit< ampere, std::milli > milliamp
A quantity unit for milliamps.
Definition common_units.hpp:143
scaled_unit< gram, std::kilo > kilogram
The SI base quantity unit for mass.
Definition common_units.hpp:50
scaled_unit< second, std::nano > nanosecond
A quantity unit for nanoseconds.
Definition common_units.hpp:119
thermodynamic_temperature temperature
Alias for thermodynamic temperature.
Definition common_units.hpp:83
Definition accumulate.hpp:37
typename scaled_unit_detail::scaled_unit_helper< BaseUnit, Scale >::type scaled_unit
Type alias for a quantity unit that is another unit scaled by some scale factor.
Definition scaled_unit.hpp:128
typename quantity_kind_detail::choose_quantity_kind_base< Derived, std::remove_cv_t< ParentKindOrOriginOrUnit >, std::remove_cv_t< OriginOrUnit >, std::remove_cv_t< Unit > >::type quantity_kind
ParentKind class for declaring a quantity kind with a parent quantity kind.
Definition quantity_kind.hpp:327
Definition accumulate.hpp:36