quantity::Quantity< T, ST > Class Template Reference

Quantity base class definition. More...

#include <Quantity.h>

Inheritance diagram for quantity::Quantity< T, ST >:

Inheritance graph
[legend]

List of all members.

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)


Detailed Description

template<typename T, typename ST = double>
class quantity::Quantity< T, ST >

Quantity base class definition.

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.


Member Typedef Documentation

template<typename T, typename ST = double>
typedef T quantity::Quantity< T, ST >::QT

make the QuantityType available

Definition at line 453 of file Quantity.h.

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
typedef QuantityTraits<QT>::UnitType quantity::Quantity< T, ST >::UT

template<typename T, typename ST = double>
typedef QuantityTraits<QT>::UnitList quantity::Quantity< T, ST >::UL

template<typename T, typename ST = double>
typedef unit::ValidUnit<typename QuantityTraits<QT>::DefaultUnit, UL>::RET quantity::Quantity< T, ST >::DU

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
typedef Quantity<T, ST> quantity::Quantity< T, ST >::Q [private]

the Quantity itself

Definition at line 478 of file Quantity.h.


Constructor & Destructor Documentation

template<typename T, typename ST = double>
quantity::Quantity< T, ST >::Quantity ( void   )  [inline]

default constructor

Definition at line 494 of file Quantity.h.

template<typename T, typename ST = double>
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.


Member Function Documentation

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
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().

template<typename T, typename ST = double>
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().

template<typename T, typename ST = double>
virtual ST quantity::Quantity< T, ST >::standard_value ( void   )  const [pure virtual]

template<typename T, typename ST = double>
virtual ST quantity::Quantity< T, ST >::value ( void   )  const [pure virtual]

template<typename T, typename ST = double>
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().

template<typename T, typename ST = double>
bool quantity::Quantity< T, ST >::isDimensionless ( void   )  const [inline]

return the dimensionality of the quantity

dynamic access

Definition at line 541 of file Quantity.h.

template<typename T, typename ST = double>
virtual std::string quantity::Quantity< T, ST >::unitsymbol ( void   )  const [pure virtual]

template<typename T, typename ST = double>
virtual std::string quantity::Quantity< T, ST >::unitname ( void   )  const [pure virtual]

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
virtual std::ostream& quantity::Quantity< T, ST >::print_value ( std::ostream &  os  )  const [pure virtual]

template<typename T, typename ST = double>
virtual void quantity::Quantity< T, ST >::operator>> ( std::string &  str  )  const [pure virtual]

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
virtual std::ostream& quantity::Quantity< T, ST >::operator>> ( std::ostream &  os  )  const [pure virtual]

template<typename T, typename ST = double>
template<typename Archive>
void quantity::Quantity< T, ST >::serialize ( Archive &  ar,
const unsigned  int 
) [inline, private]


Friends And Related Function Documentation

template<typename T, typename ST = double>
friend class boost::serialization::access [friend]

template<typename T, typename ST = double>
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.

template<typename T, typename ST = double>
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.


Member Data Documentation

template<typename T, typename ST = double>
const bool quantity::Quantity< T, ST >::Dimensionless = Dim::IsDimensionless [static, private]

template<typename T, typename ST = double>
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().

template<typename T, typename ST = double>
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().


The documentation for this class was generated from the following file:

Generated on Wed Apr 11 18:07:11 2012 for Quantities by  doxygen 1.5.6