#include <Quantity.h>
Public Types | |
typedef QT | QuantityType |
make the QuantityType available | |
typedef QuantityTraits< QT > ::Dimension | Dim |
make the contents of QuantityTraits<QT> available: Dimension | |
typedef QuantityTraits< QT > ::UnitType | UT |
make the contents of QuantityTraits<QT> available: UnitType | |
typedef QuantityTraits< QT > ::UnitList | UL |
make the contents of QuantityTraits<QT> available: UnitList | |
typedef QuantityTraits< QT > ::DefaultUnit | DU |
make the contents of QuantityTraits<QT> available: Dimension | |
typedef QuantityTraits< QT > ::DefaultDerivedQuantityType | DDQ |
make the contents of QuantityTraits<QT> available: DefaultDerivedQuantity | |
typedef AllUnitsTemplate< UT, UL > | AllUnits |
make all units in UL known | |
typedef DefaultUnitTemplate < UT, DU > | DefaultUnit |
make the default unit known | |
typedef ST | StorageType |
Public Member Functions | |
Quantity (void) | |
default constructor | |
virtual | ~Quantity (void) |
destructor | |
virtual void | name (const std::string &name) |
set the name | |
virtual void | symbol (const std::string &symbol) |
set the symbol | |
virtual std::string | name (void) const |
return the name | |
virtual std::string | symbol (void) const |
return the symbol | |
virtual ST | standard_value (void) const =0 |
return the value in the standard unit | |
virtual ST | value (void) const =0 |
return the value in the storage unit | |
bool | isDimensionless (void) const |
return the dimensionality of the quantity | |
std::ostream & | print (std::ostream &os) const |
print a quantity | |
virtual std::ostream & | print_value (std::ostream &os) const =0 |
print value and unit of the quantity | |
virtual void | operator>> (std::string &str) const =0 |
output of a quantity into a string | |
operator std::string () const | |
conversion into std::string | |
virtual std::ostream & | operator>> (std::ostream &os) const =0 |
print variable to the left of operator in output stream | |
Static Public Member Functions | |
static bool | IsDimensionless (void) |
return the dimensionality of the quantity | |
Protected Member Functions | |
unit::Unit< UT > * | findBySymbol (const std::string &unitsymbol) |
find a unit from a string; | |
Static Protected Member Functions | |
template<typename U> | |
static ST | standard (const ST value, const U &) |
standardize a value, which is given in unit U | |
template<typename U> | |
static ST | reverse (const ST value, const U &unit) |
reverse standardize a value into unit U | |
Protected Attributes | |
std::string | namestring |
the name of the quantity | |
std::string | symbolstring |
the symbol of the quantity | |
Private Types | |
typedef Quantity< QT, ST > | Q |
the Quantity itself | |
Private Member Functions | |
template<typename Archive> | |
void | serialize (Archive &ar, const unsigned int) |
serialization of Quantity | |
Static Private Attributes | |
static const bool | Dimensionless = Dim::IsDimensionless |
the dimensionality of the Quantity | |
Friends | |
class | boost::serialization::access |
allow access of serialization library | |
std::ostream & | operator<< (std::ostream &os, const Quantity &quantity) |
output of a quantity in an output stream | |
void | operator<< (std::string &str, const Quantity &quantity) |
output of a quantity into a string (placed before the operator) |
new implementation: parametrized by a quantity type QT and the storage type ST (default: double); it is assumed that QuantityTraits<QT> provides the following interface: Dimension - the dimension object of the quantity UnitType - the base type of all units associated with the quantity UnitList - the list of all units associated with the quantity in the form of a Loki::Typelist; all units in this list must be subclassed from UnitType DefaultUnit - the default unit, must be a member of UnitList
Definition at line 1048 of file Quantity.h.
typedef QT quantity::Quantity< QT, ST >::QuantityType |
typedef QuantityTraits<QT>::Dimension quantity::Quantity< QT, ST >::Dim |
make the contents of QuantityTraits<QT> available: Dimension
Definition at line 1055 of file Quantity.h.
typedef QuantityTraits<QT>::UnitType quantity::Quantity< QT, ST >::UT |
make the contents of QuantityTraits<QT> available: UnitType
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1057 of file Quantity.h.
typedef QuantityTraits<QT>::UnitList quantity::Quantity< QT, ST >::UL |
make the contents of QuantityTraits<QT> available: UnitList
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1059 of file Quantity.h.
typedef QuantityTraits<QT>::DefaultUnit quantity::Quantity< QT, ST >::DU |
make the contents of QuantityTraits<QT> available: Dimension
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1061 of file Quantity.h.
typedef QuantityTraits<QT>::DefaultDerivedQuantityType quantity::Quantity< QT, ST >::DDQ |
make the contents of QuantityTraits<QT> available: DefaultDerivedQuantity
Definition at line 1063 of file Quantity.h.
typedef Quantity<QT, ST> quantity::Quantity< QT, ST >::Q [private] |
typedef AllUnitsTemplate<UT, UL> quantity::Quantity< QT, ST >::AllUnits |
make all units in UL known
uses the AllUnits template, which checks that all elements in the Typelist are subclassed from Unit<UT>.
Definition at line 1126 of file Quantity.h.
typedef DefaultUnitTemplate<UT, DU> quantity::Quantity< QT, ST >::DefaultUnit |
make the default unit known
uses the DefaultUnitTemplate, which checks that DU is subclassed from Unit<UT>.
Definition at line 1132 of file Quantity.h.
typedef ST quantity::Quantity< QT, ST >::StorageType |
Definition at line 1134 of file Quantity.h.
quantity::Quantity< QT, ST >::Quantity | ( | void | ) | [inline] |
virtual quantity::Quantity< QT, ST >::~Quantity | ( | void | ) | [inline, virtual] |
destructor
Since this is a polymorphic class, the destructor should be virtual; it is empty.
Definition at line 1120 of file Quantity.h.
unit::Unit<UT>* quantity::Quantity< QT, ST >::findBySymbol | ( | const std::string & | unitsymbol | ) | [inline, protected] |
find a unit from a string;
use UnitPointerBySymbol; allow protected access by derived classes.
Definition at line 1087 of file Quantity.h.
static ST quantity::Quantity< QT, ST >::standard | ( | const ST | value, | |
const U & | ||||
) | [inline, static, protected] |
static ST quantity::Quantity< QT, ST >::reverse | ( | const ST | value, | |
const U & | unit | |||
) | [inline, static, protected] |
virtual void quantity::Quantity< QT, ST >::name | ( | const std::string & | name | ) | [inline, virtual] |
set the name
change the namestring of the quantity to name
Reimplemented in quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1139 of file Quantity.h.
References quantity::Quantity< QT, ST >::namestring.
virtual void quantity::Quantity< QT, ST >::symbol | ( | const std::string & | symbol | ) | [inline, virtual] |
set the symbol
change the symbolstring of the quantity to symbol
Reimplemented in quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1144 of file Quantity.h.
References quantity::Quantity< QT, ST >::symbolstring.
virtual std::string quantity::Quantity< QT, ST >::name | ( | void | ) | const [inline, virtual] |
return the name
return the namestring as a std::string
Reimplemented in quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1149 of file Quantity.h.
References quantity::Quantity< QT, ST >::namestring.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual std::string quantity::Quantity< QT, ST >::symbol | ( | void | ) | const [inline, virtual] |
return the symbol
return the symbolstring as a std::string
Reimplemented in quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1154 of file Quantity.h.
References quantity::Quantity< QT, ST >::symbolstring.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual ST quantity::Quantity< QT, ST >::standard_value | ( | void | ) | const [pure virtual] |
return the value in the standard unit
pure virtual, must be overridden in all descendants of Quantity
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Referenced by quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator/().
virtual ST quantity::Quantity< QT, ST >::value | ( | void | ) | const [pure virtual] |
return the value in the storage unit
pure virtual, must be overridden in all descendants of Quantity
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
static bool quantity::Quantity< QT, ST >::IsDimensionless | ( | void | ) | [inline, static] |
return the dimensionality of the quantity
static access
Definition at line 1169 of file Quantity.h.
References quantity::Quantity< QT, ST >::Dimensionless.
Referenced by quantity::Quantity< QT, ST >::isDimensionless(), and quantity::Quantity< GenericClass< DIM >, ST >::isDimensionless().
bool quantity::Quantity< QT, ST >::isDimensionless | ( | void | ) | const [inline, virtual] |
return the dimensionality of the quantity
dynamic access
Implements quantity::Quantities.
Definition at line 1174 of file Quantity.h.
References quantity::Quantity< QT, ST >::IsDimensionless().
std::ostream& quantity::Quantity< QT, ST >::print | ( | std::ostream & | os | ) | const [inline] |
print a quantity
outputs the object it is called on through the output stream os; needs not be called from used code, rather, a call to operator<< is more often used; the output depends on the status stored in the PrintStatus singleton: the name and the symbol of the quantity are only printed if the corresponding status flags in PrintStatus are set to true; if the corresponding flag is set to false, the default empty string is used; if either the name of the symbol is to be printed, an equal sign is added to the output stream, otherwise, the equal string is also left empty; the name, symbol and equal sign are placed on the ostream in this order, before the pure virtual member function print_value is called, which does the same for the value and unit of the quantity.
Definition at line 1201 of file Quantity.h.
References quantity::Quantity< QT, ST >::name(), quantity::Quantity< QT, ST >::print_value(), PS, and quantity::Quantity< QT, ST >::symbol().
virtual std::ostream& quantity::Quantity< QT, ST >::print_value | ( | std::ostream & | os | ) | const [pure virtual] |
print value and unit of the quantity
this pure virtual function must be overridden by classes derived from Quantity.
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual void quantity::Quantity< QT, ST >::operator>> | ( | std::string & | str | ) | const [pure virtual] |
quantity::Quantity< QT, ST >::operator std::string | ( | ) | const [inline] |
conversion into std::string
generates a new string and outputs the this object into this string, which is then returned; uses operator>> for output.
Definition at line 1238 of file Quantity.h.
virtual std::ostream& quantity::Quantity< QT, ST >::operator>> | ( | std::ostream & | os | ) | const [pure virtual] |
print variable to the left of operator in output stream
this pure virtual function must be overridden by classes derived from Quantity.
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
void quantity::Quantity< QT, ST >::serialize | ( | Archive & | ar, | |
const unsigned | int | |||
) | [inline, private] |
serialization of Quantity
uses boost::serialization
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1259 of file Quantity.h.
friend class boost::serialization::access [friend] |
allow access of serialization library
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >.
Definition at line 1252 of file Quantity.h.
std::ostream& operator<< | ( | std::ostream & | os, | |
const Quantity< QT, ST > & | quantity | |||
) | [friend] |
output of a quantity in an output stream
this friend function chains directly to the print () member function; it is needed, to allow syntax like os << quantity i.e., the quantity is the second argument of operator<<.
Definition at line 1183 of file Quantity.h.
void operator<< | ( | std::string & | str, | |
const Quantity< QT, ST > & | quantity | |||
) | [friend] |
output of a quantity into a string (placed before the operator)
Definition at line 1229 of file Quantity.h.
const bool quantity::Quantity< QT, ST >::Dimensionless = Dim::IsDimensionless [static, private] |
the dimensionality of the Quantity
Definition at line 1067 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::IsDimensionless(), and quantity::Quantity< GenericClass< DIM >, ST >::IsDimensionless().
std::string quantity::Quantity< QT, ST >::namestring [protected] |
the name of the quantity
set when initializing a derived quantity to the default name, the overwrite value, or a value given by the user
Definition at line 1077 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::name(), quantity::Quantity< GenericClass< DIM >, ST >::name(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
std::string quantity::Quantity< QT, ST >::symbolstring [protected] |
the symbol of the quantity
set when initializing a derived quantity to the default symbol, the overwrite value, or a value given by the user
Definition at line 1082 of file Quantity.h.
Referenced by quantity::Quantity< GenericClass< DIM >, ST >::print(), quantity::Quantity< QT, ST >::symbol(), and quantity::Quantity< GenericClass< DIM >, ST >::symbol().