#include <Quantity.h>
Public Types | |
typedef T | QT |
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 unit::ValidUnit < typename QuantityTraits< QT > ::DefaultUnit, UL >::RET | DU |
make the contents of QuantityTraits<QT> available: DefaultUnit | |
typedef QuantityTraits< QT > ::DefaultDerivedQuantityType | DDQ |
make the contents of QuantityTraits<QT> available: DefaultDerivedQuantity | |
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 | |
virtual std::string | unitsymbol (void) const =0 |
return the symbol of the storage unit | |
virtual std::string | unitname (void) const =0 |
return the name of the storage unit | |
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 Attributes | |
std::string | namestring |
the name of the quantity | |
std::string | symbolstring |
the symbol of the quantity | |
Private Types | |
typedef Quantity< T, 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) |
parametrized by a quantity type T and the storage type ST (default: double); it is assumed that QuantityTraits<T> 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 add ... DefaultDerivedQuantityType add ... NameString() add ... SymbolString()
Definition at line 449 of file Quantity.h.
typedef T quantity::Quantity< T, ST >::QT |
typedef QuantityTraits<QT>::Dimension quantity::Quantity< T, ST >::Dim |
make the contents of QuantityTraits<QT> available: Dimension
Definition at line 456 of file Quantity.h.
typedef QuantityTraits<QT>::UnitType quantity::Quantity< T, ST >::UT |
make the contents of QuantityTraits<QT> available: UnitType
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Definition at line 459 of file Quantity.h.
typedef QuantityTraits<QT>::UnitList quantity::Quantity< T, ST >::UL |
make the contents of QuantityTraits<QT> available: UnitList
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Definition at line 462 of file Quantity.h.
typedef unit::ValidUnit<typename QuantityTraits<QT>::DefaultUnit, UL>::RET quantity::Quantity< T, ST >::DU |
make the contents of QuantityTraits<QT> available: DefaultUnit
checks that DefaultUnit is a valid unit in UL
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Definition at line 468 of file Quantity.h.
typedef QuantityTraits<QT>::DefaultDerivedQuantityType quantity::Quantity< T, ST >::DDQ |
make the contents of QuantityTraits<QT> available: DefaultDerivedQuantity
Definition at line 471 of file Quantity.h.
typedef Quantity<T, ST> quantity::Quantity< T, ST >::Q [private] |
quantity::Quantity< T, ST >::Quantity | ( | void | ) | [inline] |
virtual quantity::Quantity< T, ST >::~Quantity | ( | void | ) | [inline, virtual] |
destructor
Since this is a polymorphic class, the destructor should be virtual; it is empty.
Definition at line 500 of file Quantity.h.
virtual void quantity::Quantity< T, 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, DQSU, DQT > >.
Definition at line 505 of file Quantity.h.
virtual void quantity::Quantity< T, 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, DQSU, DQT > >.
Definition at line 510 of file Quantity.h.
virtual std::string quantity::Quantity< T, 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, DQSU, DQT > >.
Definition at line 516 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual std::string quantity::Quantity< T, 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, DQSU, DQT > >.
Definition at line 521 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual ST quantity::Quantity< T, 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, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Referenced by quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >::operator/().
virtual ST quantity::Quantity< T, 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, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
static bool quantity::Quantity< T, ST >::IsDimensionless | ( | void | ) | [inline, static] |
return the dimensionality of the quantity
static access
Definition at line 536 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::isDimensionless(), and quantity::Quantity< GenericClass< DIM >, ST >::isDimensionless().
bool quantity::Quantity< T, ST >::isDimensionless | ( | void | ) | const [inline] |
virtual std::string quantity::Quantity< T, ST >::unitsymbol | ( | void | ) | const [pure virtual] |
return the symbol of the storage unit
pure virtual, must be overridden in all descendants of Quantity
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
virtual std::string quantity::Quantity< T, ST >::unitname | ( | void | ) | const [pure virtual] |
return the name of the storage unit
pure virtual, must be overridden in all descendants of Quantity
Implemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
std::ostream& quantity::Quantity< T, 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 578 of file Quantity.h.
virtual std::ostream& quantity::Quantity< T, 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, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Referenced by quantity::Quantity< QT, ST >::print(), and quantity::Quantity< GenericClass< DIM >, ST >::print().
virtual void quantity::Quantity< T, ST >::operator>> | ( | std::string & | str | ) | const [pure virtual] |
quantity::Quantity< T, 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 615 of file Quantity.h.
virtual std::ostream& quantity::Quantity< T, 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, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
void quantity::Quantity< T, ST >::serialize | ( | Archive & | ar, | |
const unsigned | int | |||
) | [inline, private] |
serialization of Quantity
uses boost::serialization
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Definition at line 636 of file Quantity.h.
friend class boost::serialization::access [friend] |
allow access of serialization library
Reimplemented in quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >, and quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >.
Definition at line 629 of file Quantity.h.
std::ostream& operator<< | ( | std::ostream & | os, | |
const Quantity< T, 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 560 of file Quantity.h.
void operator<< | ( | std::string & | str, | |
const Quantity< T, ST > & | quantity | |||
) | [friend] |
output of a quantity into a string (placed before the operator)
Definition at line 606 of file Quantity.h.
const bool quantity::Quantity< T, ST >::Dimensionless = Dim::IsDimensionless [static, private] |
the dimensionality of the Quantity
Definition at line 475 of file Quantity.h.
Referenced by quantity::Quantity< QT, ST >::IsDimensionless(), and quantity::Quantity< GenericClass< DIM >, ST >::IsDimensionless().
std::string quantity::Quantity< T, 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 485 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< T, 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 490 of file Quantity.h.
Referenced by quantity::Quantity< GenericClass< DIM >, ST >::print(), quantity::Quantity< QT, ST >::symbol(), and quantity::Quantity< GenericClass< DIM >, ST >::symbol().