#include <Constant.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 Constant< BQ, DerivedQuantity< QT, SU, DQT > > | C |
the constant type | |
typedef Variable< BQ, DerivedQuantity< QT, SU, DQT > > | V |
the corresponding variable type | |
Public Member Functions | |
Constant (void) | |
default constructor | |
Constant (const ST value) | |
constructor with a value | |
Constant (const ST &value, const std::string &namestring, const std::string &symbolstring) | |
constructor with a value, name and symbol strings | |
template<typename NU> | |
Constant (const ST &value, const NU &) | |
constructor with a value and a unit object | |
template<typename NU> | |
Constant (const ST &value, const NU &, const std::string &namestring, const std::string &symbolstring) | |
constructor with a value, a unit object, name and symbol strings | |
Constant (const ST value, const std::string &symbol) | |
constructor from different unit given by std::string | |
Constant (const ST new_value, const char *symbol) | |
constructor from different unit given by string constant | |
template<template< typename, typename > class SM, typename SST> | |
Constant (const SM< Quantity< QT, SST >, DQT > &quantity) | |
copy constructor | |
template<template< typename, typename > class SM, typename SST, typename SSU, typename SDQT> | |
Constant (const SM< Quantity< QT, SST >, DerivedQuantity< QT, SSU, SDQT > > &quantity) | |
copy constructor from quantity with different unit (conversion) | |
template<template< typename, typename > class SM, typename SDIM, typename SST, typename SSU, typename SDQT> | |
Constant (const SM< Quantity< GenericClass< SDIM >, SST >, DerivedQuantity< GenericClass< SDIM >, SSU, SDQT > > &quantity) | |
copy constructor from quantity with different unit (conversion) | |
template<template< typename, typename > class SM, typename SQT, typename SST, typename SSU, typename SDQT> | |
Constant (const SM< Quantity< SQT, SST >, DerivedQuantity< SQT, SSU, SDQT > > &quantity) | |
copy constructor for some other quantity | |
Constant (const Dynamic< ST > &dynamic) | |
copy construction from Dynamic | |
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; | |
GenerateVariable< C, BSUtilities::Rational < 1 > >::Mult | operator+ (void) const |
unary operator+ | |
GenerateVariable< C, BSUtilities::Rational < 1 > >::Mult | operator- (void) const |
unary operator- | |
template<class Q> | |
V | operator+ (const Q &new_variable) const |
binary operator+ | |
template<class Q> | |
V | operator- (const Q &new_variable) const |
binary operator- | |
V | operator * (const ST factor) const |
operator* for multiplication with ST | |
V | operator/ (const ST factor) const |
operator/ for division by ST | |
template<class Q> | |
GenerateVariable < Constant, Q >::Add | operator * (const Q &factor) |
multiplication of constant with a quantity | |
template<class Q> | |
GenerateVariable < Constant, Q >::Sub | operator/ (const Q &factor) |
division of a constant by a quantity | |
template<long N, long D> | |
GenerateVariable < Constant, 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 < Constant, 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 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 < Constant, 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; | |
Private Member Functions | |
template<template< typename, typename > class Q1, typename QT1, typename ST1, typename SDQT> | |
Constant & | operator= (const Q1< Quantity< QT1, ST1 >, SDQT > &) |
assignment to Constant from any Quantity | |
template<typename TQ> | |
Constant & | operator= (const TQ &) |
assignment from other type | |
template<typename Archive> | |
void | serialize (Archive &ar, const unsigned int) |
serialization of Constant | |
Private Attributes | |
ST | _value |
the value of the Constant in the storage unit; | |
Friends | |
class | boost::serialization::access |
allow access of serialization library | |
V | operator * (const ST factor, const C &variable) |
left hand multiplication by ST | |
GenerateVariable < Constant, Loki::NullType > ::Inv | operator/ (const ST numerator, const Constant &factor) |
division of a number by a constant |
version for base quantity being a Quantity; template parameters:
The Constant class is derived from the base quantity.
Definition at line 65 of file Constant.h.
typedef QuantityTraits<QT>::Dimension quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::DIM |
typedef QuantityTraits<QT>::UnitType quantity::Constant< 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 76 of file Constant.h.
typedef QuantityTraits<QT>::UnitList quantity::Constant< 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 81 of file Constant.h.
typedef QuantityTraits<QT>::DefaultUnit quantity::Constant< 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 86 of file Constant.h.
typedef unit::CheckUnit<unit::Unit<UT>, SU>::Check quantity::Constant< 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 95 of file Constant.h.
typedef Quantity<QT, ST> quantity::Constant< 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 101 of file Constant.h.
typedef Constant<BQ, DerivedQuantity<QT, SU, DQT> > quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::C |
typedef Variable<BQ, DerivedQuantity<QT, SU, DQT> > quantity::Constant< 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 constant
Definition at line 112 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | void | ) | [inline] |
default constructor
Set the value to 0 (or equivalent) in terms of storage type. It is assumed that this value is in the storage unit. The name and symbol strings on the base Quantity object are set according to the OverWrite instructions given in the DerivedQuantityTraits template.
Definition at line 135 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST | value | ) | [inline] |
constructor with a value
Set the value to value (in storage type ST). It is assumed that this value is in the storage unit. The name and symbol strings on the base Quantity object are set according to the OverWrite instructions given in the DerivedQuantityTraits template.
Definition at line 145 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST & | value, | |
const std::string & | namestring, | |||
const std::string & | symbolstring | |||
) | [inline] |
constructor with a value, name and symbol strings
Set the value to value (in storage type ST). It is assumed that the value is in the storage unit. The default name and symbol as defined by the QuantityTraits and DerivedQuantityTraits templates are overwritten by the name and symbol arguments. The qualifiers BQ:: for name() and symbol() are necessary to avoid gcc compiler errors.
Definition at line 157 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST & | value, | |
const NU & | ||||
) | [inline] |
constructor with a value and a unit object
Set the value to value (in storage type ST). The name and symbol strings on the base Quantity object are set according to the OverWrite instructions given in the DerivedQuantityTraits template. It is assumed that this value is in unit NU. It is converted into the storage unit.
Definition at line 169 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST & | value, | |
const NU & | , | |||
const std::string & | namestring, | |||
const std::string & | symbolstring | |||
) | [inline] |
constructor with a value, a unit object, name and symbol strings
Set the value to value (in storage type ST). The default name and symbol as defined in BQ are overwritten by the name and symbol arguments. The name and symbol in the DerivedQuantityTraits traits template are not considered, even if the Overwrite bools are true. The qualifiers BQ:: for name() and symbol() are necessary to avoid gcc compiler errors. It is assumed that the value is in unit NU. It is converted into the storage unit.
Definition at line 183 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST | value, | |
const std::string & | symbol | |||
) | [inline] |
constructor from different unit given by std::string
takes a std:string defining the symbol of the unit as the second argument; the symbol is checked at run time for dynamic access; the value is first standardized on the base of the unit determined, and recalculated into the storage unit; first initializes base class; findBySymbol may throw a UnitMismatch exception.
Definition at line 196 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const ST | new_value, | |
const char * | symbol | |||
) | [inline] |
constructor from different unit given by string constant
takes a std:string defining the symbol of the unit as the second argument; the symbol is checked at run time for dynamic access; the value is first standardized on the base of the unit determined, and recalculated into the storage unit; first initializes base class; findBySymbol may throw a UnitMismatch exception.
Definition at line 215 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const SM< Quantity< QT, SST >, DQT > & | quantity | ) | [inline] |
copy constructor
copy from a source object of same base and derived quantity types; Initialize the base quantity BQ, then copy the value, the name and symbol string of variable. Any mode, works if copy construction between ST and SST works.
Definition at line 242 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const SM< Quantity< QT, SST >, DerivedQuantity< QT, SSU, SDQT > > & | quantity | ) | [inline] |
copy constructor from quantity with different unit (conversion)
specialized version for same quantity type QT; it may have different storage type or unit, or a different DerivedQuantityType. then we can be sure that the value of the source quantity can be recalculated into the unit of the target Constant; the result of this calculation is used in an initializer. The name and the symbol of the quantity are copied in the body of the function. The form of SM<> must satisfy the template parameter sequence for a Variable or other classes similarly derived fom Quantity; this prohibits the conversion from general objects (string etc.).
Definition at line 260 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const SM< Quantity< GenericClass< SDIM >, SST >, DerivedQuantity< GenericClass< SDIM >, SSU, SDQT > > & | quantity | ) | [inline] |
copy constructor from quantity with different unit (conversion)
specialized version for a source quantity derived from Quantity with a unit list typical for a generated quantity using a GenericUnit; this special case is the only exception when a quantity of different base unit type can be converted into the target Constant, provided the dimensions of the two objects are equal. This is tested with CheckSecondDimension.
Definition at line 277 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const SM< Quantity< SQT, SST >, DerivedQuantity< SQT, SSU, SDQT > > & | quantity | ) | [inline] |
copy constructor for some other quantity
this copy constructor only succeeds if the target quantity is a generated variable object, and the dimensions of the source and the target base quantities is identical. It allows copy construction of a generated variable from a commensurate source quantity. All other target quantities do not fit into this pattern, and in these cases, at compile time VariableError<true> is attempted to be instantiated, which never succeeds. Consequently, in these cases, a compile time error is emitted. Such a copy construction should only work, if a specialized version of a copy constructor is provided.
Definition at line 302 of file Constant.h.
quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::Constant | ( | const Dynamic< ST > & | dynamic | ) | [inline] |
copy construction from Dynamic
this copy constructor has to do run-time checking of the dimensional information in Dynamic; division by the Gcd brings all components of the seven dimension Rationals in Constant to the canonical values.
Definition at line 318 of file Constant.h.
References quantity::Dynamic< ST >::isCommensurable(), and quantity::Dynamic< ST >::value().
Constant& quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator= | ( | const Q1< Quantity< QT1, ST1 >, SDQT > & | ) | [inline, private] |
assignment to Constant from any Quantity
only declaration, never defined and private in order to prevent assignment to a Constant
Constant& quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator= | ( | const TQ & | ) | [inline, private] |
assignment from other type
only declaration, never defined and private in order to prevent assignment to a Constant
ST quantity::Constant< 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 362 of file Constant.h.
ST quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::standard_value | ( | void | ) | const [inline, virtual] |
return the value in the standard unit;
The stored _value is standardized using the Standardize () function for the storage unit
Implements quantity::Quantity< QT, ST >.
Definition at line 368 of file Constant.h.
Variable<Quantity<QT, ST>, DerivedQuantity<QT, NU, DQT> > quantity::Constant< 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 constant 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 379 of file Constant.h.
std::string quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::unitsymbol | ( | void | ) | const [inline, virtual] |
return the storage unit symbol;
! return the value in a unit with symbol string symbolstring; ! The string is checked at run time, this allows dynamic access.
the symbol is interrogated from the storage unit; dynamic access.
Implements quantity::Quantities.
Definition at line 408 of file Constant.h.
static std::string quantity::Constant< 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 413 of file Constant.h.
std::string quantity::Constant< 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 418 of file Constant.h.
static std::string quantity::Constant< 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 423 of file Constant.h.
GenerateVariable<C, BSUtilities::Rational<1> >::Mult quantity::Constant< 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 438 of file Constant.h.
GenerateVariable<C, BSUtilities::Rational<1> >::Mult quantity::Constant< 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 449 of file Constant.h.
V quantity::Constant< 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 460 of file Constant.h.
V quantity::Constant< 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 470 of file Constant.h.
V quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator * | ( | const ST | factor | ) | const [inline] |
operator* for multiplication with ST
generates new object; can be chained as in a * b * c;
Definition at line 478 of file Constant.h.
V quantity::Constant< 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 493 of file Constant.h.
GenerateVariable<Constant, Q>::Add quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator * | ( | const Q & | factor | ) | [inline] |
multiplication of 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 506 of file Constant.h.
GenerateVariable<Constant, Q>::Sub quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::operator/ | ( | const Q & | factor | ) | [inline] |
division of a 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 520 of file Constant.h.
GenerateVariable<Constant, BSUtilities::Rational<N, D> >::Mult quantity::Constant< 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 dimensions of the first argument multiplied by Rational<N, D>; used as object.pow (r); standardized value to be used, since the transient variable assumes a standardization factor of unity. used as object.pow (r);
Definition at line 570 of file Constant.h.
References quantity::pow().
Dynamic<ST> quantity::Constant< 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 dimensions 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 596 of file Constant.h.
References quantity::pow().
GenerateVariable<Constant, BSUtilities::Rational<1, 2> >::Mult quantity::Constant< 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 609 of file Constant.h.
References quantity::sqrt().
std::ostream& quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::print_value | ( | std::ostream & | os | ) | const [inline, virtual] |
print the value and the unit of the 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 621 of file Constant.h.
void quantity::Constant< 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 627 of file Constant.h.
References BSUtilities::Conversion< T >::to_string().
std::ostream& quantity::Constant< 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 635 of file Constant.h.
void quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::serialize | ( | Archive & | ar, | |
const unsigned | int | |||
) | [inline, private] |
serialization of Constant
uses boost::serialization
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 646 of file Constant.h.
GenerateVariable<Constant, BSUtilities::Rational<I, long(1 quantity::Constant< 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; used as object.pow (r); standardized value to be used, since the transient variable assumes a standardization factor of unity. used as object.pow (r);
Definition at line 585 of file Constant.h.
References quantity::pow().
friend class boost::serialization::access [friend] |
allow access of serialization library
Reimplemented from quantity::Quantity< QT, ST >.
Definition at line 640 of file Constant.h.
GenerateVariable<Constant, Loki::NullType>::Inv operator/ | ( | const ST | numerator, | |
const Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > & | factor | |||
) | [friend] |
division of a number by a constant
the type of the result is generated through GenerateVariable by negating the dimension of the variable;
Definition at line 532 of file Constant.h.
ST quantity::Constant< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > >::_value [private] |
the value of the Constant in the storage unit;
This data member is private, and can only be accessed through the member functions value (); being set during construction of an object.
Definition at line 120 of file Constant.h.