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
7#include "arene/base/math/pi.hpp"
8#include "arene/base/stdlib_choice/ratio.hpp"
9#include "arene/base/units/quantity_kind.hpp"
10#include "arene/base/units/quantity_origin.hpp"
11#include "arene/base/units/quantity_unit.hpp"
12#include "arene/base/units/scaled_unit.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
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
75
76/// @brief A tag type for absolute zero, the origin of the Kelvin scale
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
83using temperature = 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
87/// @brief Base quantity kind for thermodynamic temperature
89
90/// @brief Quantity kind for the number of entities of a given kind in a system
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
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
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
105/// @brief Base quantity kind for the density of luminous flux with respect to solid angle in a specified direction
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)
113using hour = scaled_unit<minute, std::ratio<60, 1>>;
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)
131using mile = scaled_unit<meter, std::ratio<1609344, 1000>>;
132
133/// @brief A quantity unit for kilograms
134using kilogram = scaled_unit<gram, std::kilo>;
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
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
155
156/// @brief An alternate name for @c angular_measure
157using plane_angle = angular_measure;
158
159/// @brief A quantity unit for @c angular_measure
160///
161/// Pi radians is 180 degrees
163 : public quantity_unit<
165 // NOLINTNEXTLINE(readability-magic-numbers)
167
168} // namespace units
169} // namespace base
170} // namespace arene
171
172#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_COMMON_UNITS_HPP_
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
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10