Falaise
4.0.1
SuperNEMO Software Toolkit
|
Class representing a value and physical unit. More...
#include <falaise/config/quantity.h>
Public Member Functions | |
quantity ()=default | |
Default constructor. More... | |
quantity (double value, std::string const &unit) | |
Construct a quantity from a value and unit. More... | |
virtual | ~quantity ()=default |
Destructor. More... | |
double | operator() () const |
Convert quantity to double value in the CLHEP::Units numeric scaling system. More... | |
double | value () const |
Return the value for the quantity in its units. More... | |
double | value_in (std::string const &unit) const |
Return value for the quantity in given units. More... | |
std::string const & | unit () const |
Return datatools::units tag for the quantity's unit. More... | |
std::string const & | dimension () const |
Return datatools::unit tag for the quantity's dimension. More... | |
Class representing a value and physical unit.
quantity is a simple holder for datatools::properties values that are marked with an explicit unit. In properties files, these are declared as
where length
is the dimension, and m
is the explicit unit. quantity composes this value, unit, and dimension into a single object allowing these to be queried and the value directly converted to the internal CLHEP::Units numeric representation. For example:
In general, you should not use quantity directly, but rather the typed System of Units concrete classes for the physical quantities you need (e.g. length_t for length parameters). quantity only validates that the unit is known to datatools::units, whereas the System of Units types provide strict dimensional correctness.
|
default |
Default constructor.
Initializes as an effectively zero value dimensionless parameter
falaise::config::quantity::quantity | ( | double | value, |
std::string const & | unit | ||
) |
Construct a quantity from a value and unit.
[in] | value | Numeric value in units of unit |
[in] | unit | datatools::units::unit tag |
falaise::config::unknown_unit_error | if unit is not supported by datatools::units |
|
virtualdefault |
Destructor.
|
inline |
Return datatools::unit tag for the quantity's dimension.
|
inline |
Convert quantity to double
value in the CLHEP::Units numeric scaling system.
For example:
|
inline |
Return datatools::units tag for the quantity's unit.
|
inline |
Return the value for the quantity in its units.
For example:
double falaise::config::quantity::value_in | ( | std::string const & | unit | ) | const |
Return value for the quantity in given units.