SyDEVS
v0.7
Simulation-based analysis of complex systems involving people, devices, physical elements, and dynamic environments.
|
A data type which represents the general concept of scale as a dimensionless power of 1000. More...
#include <scale.h>
Public Types | |
using | level_type = int8 |
The type used to store the "level" integer internally. More... | |
Public Member Functions | |
constexpr | scale () |
Constructs a scale value with a level integer of zero. More... | |
constexpr | scale (int64 level) |
Constructs a scale value with the specified level integer. More... | |
constexpr | scale (const scale &)=default |
Copy constructor. More... | |
scale & | operator= (const scale &)=default |
Copy assignment. More... | |
scale (scale &&)=default | |
Move constructor. More... | |
scale & | operator= (scale &&)=default |
Move assignment. More... | |
~scale ()=default | |
Destructor. More... | |
constexpr int64 | level () const |
Returns the level integer. More... | |
constexpr float64 | approx () const |
Returns 1000 to the power of level() , rounded if necessary. More... | |
scale & | operator++ () |
Increments (prefix) the level integer. More... | |
scale | operator++ (int) |
Increments (postfix) the level integer. More... | |
scale & | operator-- () |
Decrements (prefix) the level integer. More... | |
scale | operator-- (int) |
Decrements (postfix) the level integer. More... | |
scale & | operator+= (int64 rhs) |
Adds rhs to the level integer. More... | |
scale & | operator-= (int64 rhs) |
Subtracts rhs from the level integer. More... | |
constexpr const scale | operator+ () const |
Returns a copy of the scale value. More... | |
constexpr const scale | operator- () const |
Returns the negation of the scale value. More... | |
constexpr const scale | operator+ (int64 rhs) const |
Returns a scale value with level() increased by rhs . More... | |
constexpr const scale | operator- (int64 rhs) const |
Returns a scale value with level() decreased by rhs . More... | |
constexpr int64 | operator- (scale rhs) const |
Returns level() minus rhs.level() . More... | |
constexpr float64 | operator/ (scale rhs) const |
Returns 1000 to the power of level() divided by 1000 to the power of rhs.level() . More... | |
constexpr bool | operator== (scale rhs) const |
Returns true if the scale value equals rhs . More... | |
constexpr bool | operator!= (scale rhs) const |
Returns true if the scale value does not equal rhs . More... | |
constexpr bool | operator< (scale rhs) const |
Returns true if the scale value is less than rhs . More... | |
constexpr bool | operator> (scale rhs) const |
Returns true if the scale value is greater than rhs . More... | |
constexpr bool | operator<= (scale rhs) const |
Returns true if the scale value is at most rhs . More... | |
constexpr bool | operator>= (scale rhs) const |
Returns true if the scale value is at least rhs . More... | |
char | symbol () const |
Provdes the metric prefix symbol. More... | |
A data type which represents the general concept of scale as a dimensionless power of 1000.
A scale
value can be used to characterize the resolution or approximate magnitude of a meausure of time (i.e. a duration), space (i.e. a distance), or potentially any other physical quantity.
Every scale
value encapsulates a level integer, obtained using level()
, which serves as the exponent of the dimensionless power of 1000. If the level integer is known at compile time, one of the predefined scale constants below may be used instead of invoking the constructor. The constants are named based on metric prefixes.
The prefix name may be obtained from the scale
value using the operator<<
overload.
The represented power (i.e. 1000 to the power level()
) may be approximated using approx()
.
The following operators adjust the scale
value's level integer: ++
, --
, +=
, -=
, +
, -
, ==
, *
, !=
, <
, >
, <=
, >=
. Examples are below.
The /
operator yields the factor that separates two scales. The result is approximated if the denominator is a larger scale
than the numerator.
using sydevs::scale::level_type = int8 |
The type used to store the "level" integer internally.
|
constexpr |
Constructs a scale
value with a level integer of zero.
|
explicitconstexpr |
Constructs a scale
value with the specified level integer.
The dimensionless power represented by the constructed scale
value is 1000 to the power of level
.
level | The level integer of the scale value. |
|
constexprdefault |
Copy constructor.
|
default |
Move constructor.
|
default |
Destructor.
|
constexpr |
Returns 1000 to the power of level()
, rounded if necessary.
|
constexpr |
Returns the level integer.
|
constexpr |
Returns true
if the scale
value does not equal rhs
.
|
constexpr |
Returns a copy of the scale
value.
Returns a scale
value with level()
increased by rhs
.
scale & sydevs::scale::operator++ | ( | ) |
Increments (prefix) the level integer.
scale sydevs::scale::operator++ | ( | int | ) |
Increments (postfix) the level integer.
|
constexpr |
Returns the negation of the scale
value.
Returns a scale
value with level()
decreased by rhs
.
Returns level()
minus rhs.level()
.
scale & sydevs::scale::operator-- | ( | ) |
Decrements (prefix) the level integer.
scale sydevs::scale::operator-- | ( | int | ) |
Decrements (postfix) the level integer.
Returns 1000 to the power of level()
divided by 1000 to the power of rhs.level()
.
|
constexpr |
Returns true
if the scale
value is less than rhs
.
|
constexpr |
Returns true
if the scale
value is at most rhs
.
|
constexpr |
Returns true
if the scale
value equals rhs
.
|
constexpr |
Returns true
if the scale
value is greater than rhs
.
|
constexpr |
Returns true
if the scale
value is at least rhs
.
char sydevs::scale::symbol | ( | ) | const |
Provdes the metric prefix symbol.
The metric prefix symbol is the single-character as indicated at http://en.wikipedia.org/wiki/Metric_prefix for level() >= -8
and level() <= 8
. If the level integer is outside this range, or if it is zero, then integer 0
is returned.
0
.