#include <UniqueConstant.h>
Public Types | |
typedef QuantityTraits< QT > ::Dimension | DIM |
the dimension | |
typedef QuantityTraits< QT > ::UnitType | UT |
the unit type | |
typedef QuantityTraits< QT > ::UnitList | UL |
the unit list | |
typedef QuantityTraits< QT > ::DefaultUnit | DU |
the default unit | |
typedef unit::CheckUnit < unit::Unit< UT >, SU >::Check | StorageUnit |
the storage unit | |
typedef Quantity< QT, ST > | BQ |
the base quantity type | |
typedef UniqueConstant< BQ, DerivedQuantity< QT, SU, DQT > > | UC |
the unique constant type | |
typedef Variable< BQ, DerivedQuantity< QT, SU, DQT > > | V |
the corresponding variable type | |
Public Member Functions | |
ST | value (void) const |
return the value in the storage unit; | |
ST | standard_value (void) const |
return the value in the standard unit; | |
template<typename NU> | |
Variable< Quantity < QT, ST >, DerivedQuantity< QT, NU, DQT > > | value (const NU &) const |
return the value in a unit NU (conversion) | |
std::string | unitsymbol (void) const |
return the storage unit symbol; | |
std::string | unitname (void) const |
return the storage unit name; | |
std::string | name (void) const |
return the name; | |
std::string | symbol (void) const |
return the symbol; | |
GenerateVariable< UC, BSUtilities::Rational < 1 > >::Mult | operator+ (void) const |
unary operator+ | |
GenerateVariable< UC, BSUtilities::Rational < 1 > >::Mult | operator- (void) const |
unary operator- | |
template<class Q> | |
V | operator+ (const Q &new_variable) const |
operator+ | |
template<class Q> | |
V | operator- (const Q &new_variable) const |
binary operator- | |
V | operator * (const ST factor) const |
operator* for right hand side multiplication with ST | |
V | operator/ (const ST factor) const |
operator/ for division by ST | |
template<class Q> | |
GenerateVariable < UniqueConstant, Q > ::Add | operator * (const Q &factor) |
multiplication of singleton constant with a quantity | |
template<class Q> | |
GenerateVariable < UniqueConstant, Q > ::Sub | operator/ (const Q &factor) |
division of a singleton constant by a quantity | |
template<long N, long D> | |
GenerateVariable < UniqueConstant, BSUtilities::Rational < N, D > >::Mult | pow (const BSUtilities::Rational< N, D > &) const |
the pow function with rational exponent | |
template<class T> | |
Dynamic< ST > | pow (const T &exp) const |
the pow function with dynamic exponent | |
GenerateVariable < UniqueConstant, BSUtilities::Rational< 1, 2 > >::Mult | sqrt (void) const |
the sqrt function | |
std::ostream & | print_value (std::ostream &os) const |
print the value and the unit of the singleton constant | |
void | operator>> (std::string &str) const |
store the value and unit of the variable in a std::string | |
std::ostream & | operator>> (std::ostream &os) const |
print the variable | |
template<int I> | |
GenerateVariable < UniqueConstant, BSUtilities::Rational < I, long(1 | pow (const typename Loki::Int2Type< I >) const )> >::Mult |
the pow function with static integer exponent | |
Static Public Member Functions | |
static std::string | Unitsymbol (void) |
return the storage unit symbol; | |
static std::string | Unitname (void) |
return the storage unit name; | |
Protected Member Functions | |
void | name (const std::string &namestring) |
set the name | |
void | symbol (const std::string &symbolstring) |
set the symbol | |
Private Member Functions | |
UniqueConstant (void) | |
default constructor | |
UniqueConstant (const UniqueConstant &) | |
copy constructor | |
~UniqueConstant (void) | |
destructor | |
UniqueConstant & | operator= (const UniqueConstant &) |
assignment operator | |
void | operator & () |
adress-of operator | |
template<typename Archive> | |
void | serialize (Archive &ar, const unsigned int) |
serialization of UniqueConstant | |
Private Attributes | |
ST | _value |
the value of the UniqueConstant in the storage unit; | |
Static Private Attributes | |
static const ST | default_value_ |
the value of the UniqueConstant in the default unit; | |
Friends | |
class | Loki::CreateUsingNew< UC > |
declare the default creation policy a friend | |
class | boost::serialization::access |
allow access of boost::serialization library | |
V | operator * (const ST factor, const UC &variable) |
left hand multiplication by ST | |
GenerateVariable < UniqueConstant, Loki::NullType > ::Inv | operator/ (const ST numerator, const UniqueConstant &factor) |
division of a number by a singleton constant |
version for base quantity being a Quantity; template parameters:
The UniqueConstant class is derived from the base quantity.
Definition at line 67 of file UniqueConstant.h.
typedef QuantityTraits<QT>::Dimension quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::DIM |
the dimension
taken from the quantity traits template
Definition at line 73 of file UniqueConstant.h.
typedef QuantityTraits<QT>::UnitType quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::UT |
the unit type
taken from the quantity traits template
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 78 of file UniqueConstant.h.
typedef QuantityTraits<QT>::UnitList quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::UL |
the unit list
taken from the quantity traits template
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 83 of file UniqueConstant.h.
typedef QuantityTraits<QT>::DefaultUnit quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::DU |
the default unit
taken from the quantity traits template
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 88 of file UniqueConstant.h.
typedef unit::CheckUnit<unit::Unit<UT>, SU>::Check quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::StorageUnit |
the storage unit
check the DerivedQuantityType StorageUnit and if ok, make it known as Unit. StorageUnit is checked to be subclassed from Unit<UT>. This ensures that it (a) is a unit, (b) is a descendant of Unit<UT>, and (c) can be instantiated; since CheckUnit returns the test unit, this is typedef'ed for further use.
Definition at line 97 of file UniqueConstant.h.
typedef Quantity<QT, ST> quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::BQ |
the base quantity type
the Quantity which is used as the abstract base class for this quantity;
Definition at line 103 of file UniqueConstant.h.
typedef UniqueConstant<BQ, DerivedQuantity<QT, SU, DQT> > quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::UC |
the unique constant type
make the unique constant known as UC
Definition at line 108 of file UniqueConstant.h.
typedef Variable<BQ, DerivedQuantity<QT, SU, DQT> > quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::V |
the corresponding variable type
this is the type of a Variable which has the same base and derived quantity features as the unique constant
Definition at line 114 of file UniqueConstant.h.
quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::UniqueConstant | ( | void | ) | [inline, private] |
default constructor
assume the value to be in the storage unit; private for singleton to avoid sneaky construction; construction possible through friend class CreateUsingNew<>. Construction from other units is not possible, i.e. the value MUST be given in the storage unit; The name and the symbol given in the DerivedQuantityTraits template can not be overwritten by a constructor.
Definition at line 149 of file UniqueConstant.h.
quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::UniqueConstant | ( | const UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > & | ) | [inline, private] |
copy constructor
initialize base quantity BQ and the value. private for singleton to avoid sneaky copy, thus, cannot be called.
Definition at line 157 of file UniqueConstant.h.
quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::~UniqueConstant | ( | void | ) | [inline, private] |
destructor
private to avoid sneaky destruction af Singleton
Definition at line 172 of file UniqueConstant.h.
UniqueConstant& quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator= | ( | const UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > & | ) | [private] |
assignment operator
private for Singleton; never defined
void quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator & | ( | ) | [private] |
adress-of operator
private for Singleton; never defined
ST quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::value | ( | void | ) | const [inline, virtual] |
return the value in the storage unit;
The stored value is returned without recalculation.
Implements quantity::Quantity< QT, ST >.
Definition at line 206 of file UniqueConstant.h.
ST quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::standard_value | ( | void | ) | const [inline, virtual] |
return the value in the standard unit;
The stored _value is first standardized using the Standardize () function for storage unit
Implements quantity::Quantity< QT, ST >.
Definition at line 212 of file UniqueConstant.h.
Variable<Quantity<QT, ST>, DerivedQuantity<QT, NU, DQT> > quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::value | ( | const NU & | ) | const [inline] |
return the value in a unit NU (conversion)
The value is returned in a variable object with storage unit NU. The stored _value is first standardized using the Standardize () function for the storage unit, and then converted into NU, which is checked against AllUnits; only the type of NU is used. The storage type of the return variable is ST.
Definition at line 223 of file UniqueConstant.h.
void quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::name | ( | const std::string & | namestring | ) | [inline, protected, virtual] |
set the name
! return the value in a unit with symbol string symbolstring; ! The string is checked at run time, this allows dynamic access.
change the namestring of the quantity to name; protected for UniqueConstant by default; override the virtual function in BQ.
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 255 of file UniqueConstant.h.
void quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::symbol | ( | const std::string & | symbolstring | ) | [inline, protected, virtual] |
set the symbol
change the symbolstring of the quantity to symbol; protected for UniqueConstant by default; override the virtual function in BQ.
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 262 of file UniqueConstant.h.
std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::unitsymbol | ( | void | ) | const [inline, virtual] |
return the storage unit symbol;
the symbol is interrogated from the storage unitU; dynamic access.
Implements quantity::Quantities.
Definition at line 268 of file UniqueConstant.h.
static std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Unitsymbol | ( | void | ) | [inline, static] |
return the storage unit symbol;
the symbol is interrogated from the storage unit; static access.
Definition at line 273 of file UniqueConstant.h.
std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::unitname | ( | void | ) | const [inline, virtual] |
return the storage unit name;
the name is interrogated from the storage unit; dynamic access.
Implements quantity::Quantities.
Definition at line 278 of file UniqueConstant.h.
static std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Unitname | ( | void | ) | [inline, static] |
return the storage unit name;
the name is interrogated from the storage unit; static access.
Definition at line 283 of file UniqueConstant.h.
std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::name | ( | void | ) | const [inline, virtual] |
return the name;
the name is interrogated from the base quantity; dynamic access.
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 288 of file UniqueConstant.h.
std::string quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::symbol | ( | void | ) | const [inline, virtual] |
return the symbol;
the symbol is interrogated from the base quantity; dynamic access.
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 293 of file UniqueConstant.h.
GenerateVariable<UC, BSUtilities::Rational<1> >::Mult quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator+ | ( | void | ) | const [inline] |
unary operator+
returns a generated variable object with the same dimension and other characteristics and same value.
Definition at line 308 of file UniqueConstant.h.
GenerateVariable<UC, BSUtilities::Rational<1> >::Mult quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator- | ( | void | ) | const [inline] |
unary operator-
returns a generated variable object with the same dimension and other characteristics and same value with changed sign.
Definition at line 317 of file UniqueConstant.h.
V quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator+ | ( | const Q & | new_variable | ) | const [inline] |
V quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator- | ( | const Q & | new_variable | ) | const [inline] |
binary operator-
can be chained as in a - b - c; forwards to addition to Variable
Definition at line 336 of file UniqueConstant.h.
V quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator * | ( | const ST | factor | ) | const [inline] |
operator* for right hand side multiplication with ST
generates new object; can be chained as in a * b * c;
Definition at line 344 of file UniqueConstant.h.
V quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator/ | ( | const ST | factor | ) | const [inline] |
operator/ for division by ST
generates new object; can be chained as in a * b / c;
Definition at line 359 of file UniqueConstant.h.
GenerateVariable<UniqueConstant, Q>::Add quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator * | ( | const Q & | factor | ) | [inline] |
multiplication of singleton constant with a quantity
the type of the result is generated through GenerateVariable by adding the dimensions of the two quantities; only GenerateVariable with two quantities as arguments does have an Add typedef, thus, Q does not need to be specified.
Definition at line 372 of file UniqueConstant.h.
GenerateVariable<UniqueConstant, Q>::Sub quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator/ | ( | const Q & | factor | ) | [inline] |
division of a singleton constant by a quantity
the type of the result is generated through GenerateVariable by subtracting the dimensions of the two quantities; only GenerateVariable with two quantities as arguments does have an Sub typedef, thus, Q does not need to be specified.
Definition at line 387 of file UniqueConstant.h.
References quantity::Quantity< QT, ST >::standard_value().
GenerateVariable<UniqueConstant, BSUtilities::Rational<N, D> >::Mult quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::pow | ( | const BSUtilities::Rational< N, D > & | ) | const [inline] |
the pow function with rational exponent
returns a transient variable with the dimension of the first argument multiplied by Rational<N, D>; standardized value to be used, since the transient variable assumes a standardization factor of unity. used as object.pow (r);
Definition at line 437 of file UniqueConstant.h.
References quantity::pow().
Dynamic<ST> quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::pow | ( | const T & | exp | ) | const [inline] |
the pow function with dynamic exponent
returns a transient Dynamic variable with the dimension of the first argument multiplied by exp; used as object.pow (r); forwards action to pow function with quantity and dynamic exponent (friend functions in Dynamic for specific T's).
Definition at line 462 of file UniqueConstant.h.
References quantity::pow().
GenerateVariable<UniqueConstant, BSUtilities::Rational<1, 2> >::Mult quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::sqrt | ( | void | ) | const [inline] |
the sqrt function
returns a transient variable with the dimension of the first argument multiplied by 0.5; standardized value to be used, since the transient variable assumes a standardization factor of unity. used as object.sqrt ();
Definition at line 475 of file UniqueConstant.h.
References quantity::sqrt().
std::ostream& quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::print_value | ( | std::ostream & | os | ) | const [inline, virtual] |
print the value and the unit of the singleton constant
places these items on the ostream os and returns the reference to the os object, thus allowing chaining of operator<< calls.
Implements quantity::Quantity< QT, ST >.
Definition at line 486 of file UniqueConstant.h.
void quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator>> | ( | std::string & | str | ) | const [inline, virtual] |
store the value and unit of the variable in a std::string
converts to a string by template Conversion
Implements quantity::Quantity< QT, ST >.
Definition at line 492 of file UniqueConstant.h.
References BSUtilities::Conversion< T >::to_string().
std::ostream& quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator>> | ( | std::ostream & | os | ) | const [inline, virtual] |
print the variable
used if the variable is placed to the left of operator>>; calls print_value () indirectly through Quantity<>::print, thus including name and symbol of quantity if requested.
Implements quantity::Quantity< QT, ST >.
Definition at line 500 of file UniqueConstant.h.
void quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::serialize | ( | Archive & | ar, | |
const unsigned | int | |||
) | [inline, private] |
serialization of UniqueConstant
uses boost::serialization
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 511 of file UniqueConstant.h.
GenerateVariable<UniqueConstant, BSUtilities::Rational<I, long(1 quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::pow | ( | const typename Loki::Int2Type< I > | ) | const [inline] |
the pow function with static integer exponent
returns a transient variable with the dimensions of the first argument multiplied by I; standardized value to be used, since the transient variable assumes a standardization factor of unity. used as object.pow (r);
Definition at line 451 of file UniqueConstant.h.
References quantity::pow().
friend class Loki::CreateUsingNew< UC > [friend] |
declare the default creation policy a friend
necessary to allow private default constructor; CreateUsingNew is part of Alexandrescu's Loki library.
Definition at line 120 of file UniqueConstant.h.
friend class boost::serialization::access [friend] |
allow access of boost::serialization library
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 505 of file UniqueConstant.h.
GenerateVariable<UniqueConstant, Loki::NullType>::Inv operator/ | ( | const ST | numerator, | |
const UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > & | factor | |||
) | [friend] |
division of a number by a singleton constant
the type of the result is generated through GenerateVariable by negating the dimension of the variable;
Definition at line 400 of file UniqueConstant.h.
const ST quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::default_value_ [static, private] |
the value of the UniqueConstant in the default unit;
This data member is private, and can only be accessed through the member functions value (); must be defined outside of class as a specialization for each UniqueConstant<BQ, DerivedQuantity<QT, SU, DQT> >.
Definition at line 128 of file UniqueConstant.h.
ST quantity::UniqueConstant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::_value [private] |
the value of the UniqueConstant in the storage unit;
This data member is private, and can only be accessed through the member functions value ().
Definition at line 134 of file UniqueConstant.h.