Variable.h File Reference

defines quantities with a variable value More...

#include "Quantities/Quantity/Quantity.h"
#include "Quantities/Quantity/QuantityError.h"
#include "Quantities/Quantity/Generic.h"
#include "Quantities/Quantity/Dynamic.h"
#include "loki/Typelist.h"
#include "loki/NullType.h"
#include "loki/HierarchyGenerators.h"
#include <boost/serialization/base_object.hpp>

Include dependency graph for Variable.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  quantity

Classes

struct  quantity::AssignmentError< false >
 helper template AssignmentError, no AssignmentError occurred More...
struct  quantity::OperationError< false >
 helper template OperationError, no OperationError occurred More...
struct  quantity::SameDimensioned< Q1< Quantity< QT1, ST1 >, DQT1 >, Q2< Quantity< QT2, ST2 >, DQT2 > >
 test whether two quantities share a common dimension: More...
struct  quantity::CheckSecondDimension< Q1< Quantity< QT1, ST1 >, DQT1 >, Q2< Quantity< QT2, ST2 >, DQT2 > >
struct  quantity::OverwriteNameString< QT, DQT >
 return the overwriting name string More...
struct  quantity::UseNameString< QT >
 return the default name string More...
struct  quantity::Name< QT, DQT >
 return the name of the variable More...
struct  quantity::OverwriteSymbolString< QT, DQT >
 return the overwriting symbol string More...
struct  quantity::UseSymbolString< QT >
 return the default symbol string More...
struct  quantity::Symbol< QT, DQT >
 return the symbol of the variable More...
class  quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >
 Variable: specialization. More...
struct  quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >::PlusGenerated< M1, QT1, ST1, SU1, DQT1 >
 addition helper More...
struct  quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >::Plus< Q >
 addition helper More...
struct  quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >::MinusGenerated< M1, QT1, ST1, SU1, DQT1 >
 subtraction helper More...
struct  quantity::Variable< Quantity< QT, ST >, DerivedQuantity< QT, DQSU, DQT > >::Minus< Q >
 subtraction helper More...
struct  quantity::GenerateVariable< Q1< Quantity< QT1, ST >, DQT1 >, Q2< Quantity< QT2, ST >, DQT2 > >
 generate a new Variable with combined dimensions More...
struct  quantity::GenerateVariable< Q< Quantity< QT, ST >, DQT >, Loki::NullType >
 generate a new Variable with negated dimension More...
struct  quantity::GenerateVariable< Q< Quantity< QT, ST >, DQT >, BSUtilities::Rational< N, D > >
 generate a new Variable with multiplied dimension More...

Defines

#define QUANTITY_COMPARISON_OPERATORS(mode, opName, opType)
 definition of comparison operators
#define QUANTITY_VARIABLE_DIMENSIONLESS_MATHFCT(function, helper)
 definition of mathematical functions producing a dimensionless result

Functions

template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
GenerateVariable< Q< Quantity
< QT, ST >, DerivedQuantity
< QT, SU, DQT >
>, BSUtilities::Rational
< 1, 2 > >::Mult 
quantity::sqrt (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity)
 the sqrt function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT, int I>
GenerateVariable< Q< Quantity
< QT, ST >, DerivedQuantity
< QT, SU, DQT >
>, BSUtilities::Rational< I,
long(1)> >::Mult 
quantity::pow (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity, typename Loki::Int2Type< I >)
 the pow function with static integer exponent
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT, long N, long D>
GenerateVariable< Q< Quantity
< QT, ST >, DerivedQuantity
< QT, SU, DQT >
>, BSUtilities::Rational< N,
D > >::Mult 
quantity::pow (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity, const BSUtilities::Rational< N, D > &)
 the pow function with static rational exponent
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT, typename T>
Dynamic< ST > quantity::pow (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity, const T &exp)
 the pow function with dynamic exponents
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::abs (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &variable)
 abs function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::ceil (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &variable)
 ceil function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::floor (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &variable)
 floor function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::frexp (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &variable, int *exponent)
 frexp function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::ldexp (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &variable, int exponent)
 ldexp function
template<template< typename, typename > class Q1, template< typename, typename > class Q2, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::fmod (const Q1< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity1, const Q2< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity2)
 fmod function
template<template< typename, typename > class Q1, template< typename, typename > class Q2, typename QT, typename ST, typename SU, typename DQT1, class DQT2>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU,
DQT1 > > 
quantity::fmod (const Q1< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT1 > > &quantity1, const Q2< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT2 > > &quantity2)
 fmod function
template<template< typename, typename > class Q1, typename QT1, typename ST, typename SU1, typename DQT1, template< typename, typename > class Q2, typename QT2, typename SU2, typename DQT2>
Variable< Quantity< QT1, ST >
, DerivedQuantity< QT1, SU1,
DQT1 > > 
quantity::fmod (const Q1< Quantity< QT1, ST >, DerivedQuantity< QT1, SU1, DQT1 > > &quantity1, const Q2< Quantity< QT2, ST >, DerivedQuantity< QT2, SU2, DQT2 > > &quantity2)
 fmod function, general
template<template< typename, typename > class Q, typename QT, typename ST, typename SU, typename DQT>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU, DQT > > 
quantity::modf (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > &quantity, Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU, DQT > > *integral)
 modf function
template<template< typename, typename > class Q, typename QT, typename ST, typename SU1, typename DQT1, typename SU2, typename DQT2>
Variable< Quantity< QT, ST >
, DerivedQuantity< QT, SU1,
DQT1 > > 
quantity::modf (const Q< Quantity< QT, ST >, DerivedQuantity< QT, SU1, DQT1 > > &quantity, Variable< Quantity< QT, ST >, DerivedQuantity< QT, SU2, DQT2 > > *integral)
 modf function
template<template< typename, typename > class Q, typename QT1, typename SU1, typename DQT1, typename QT2, typename SU2, typename DQT2, typename ST>
Variable< Quantity< QT1, ST >
, DerivedQuantity< QT1, SU1,
DQT1 > > 
quantity::modf (const Q< Quantity< QT1, ST >, DerivedQuantity< QT1, SU1, DQT1 > > &quantity, Variable< Quantity< QT2, ST >, DerivedQuantity< QT2, SU2, DQT2 > > *integral)
 modf function
template<template< typename, typename > class M1, typename QT1, typename ST1, typename SU1, typename DQT1, template< typename, typename > class M2, typename QT2, typename ST2, typename SU2, typename DQT2>
GenerateVariable< M1< Quantity
< QT1, ST1 >, DerivedQuantity
< QT1, SU1, DQT1 > >, M2
< Quantity< QT2, ST2 >
, DerivedQuantity< QT1, SU2,
DQT2 > > >::Sub 
quantity::atan2 (const M1< Quantity< QT1, ST1 >, DerivedQuantity< QT1, SU1, DQT1 > > &quantity, const M2< Quantity< QT2, ST2 >, DerivedQuantity< QT1, SU2, DQT2 > > &quantity2)
 alternative arc tangent function


Detailed Description

defines quantities with a variable value

Definition in file Variable.h.


Define Documentation

#define QUANTITY_COMPARISON_OPERATORS ( mode,
opName,
opType   ) 

Value:

bool opName (const mode &rhs) const \
    {return _value opType rhs.value ();} \
  template <template<typename, typename> class RM, typename RST, typename RSU, typename RDQT> \
    bool opName (const RM<Quantity<QT, RST>, DerivedQuantity<QT, RSU, RDQT> > &rhs) const \
      {return standard_value () opType rhs.standard_value ();} \
  template <template<typename, typename> class RM, \
                                 typename RQT, typename RST, typename RSU, typename RDQT> \
    bool opName (const RM<Quantity<RQT, RST>, DerivedQuantity<RQT, RSU, RDQT> > &rhs) const \
      {return (*this opType V(rhs));} \
  bool opName (const Dynamic<ST> &dynamic) const \
    {if (dynamic.isCommensurable (*this)) \
       return standard_value () opType dynamic.value (); \
     else \
       {throw DimensionMismatch ();} }
definition of comparison operators

this macro expands into four function definitions for a particular comparison operator: comparison with a quantity object of the same type, comparison with a derived quantity of the same base quantity (template), comparison with an unrelated object which has a conversion defined (template), and comparison with a commensurable dynamic quantity object (currently of the same storage type). The macro takes three arguments: the mode of the left hand side object, the name of the comparison in `operator' nomenclature, and the type of the comparison. The second and third argument have to designate the same comparison operation. It is necessary to list them both, since an operator name can not be generated by the macro preprocessor by concatenation. The following operations should be implemented: ==, !=, >, <, >=, <=.

Definition at line 1325 of file Variable.h.

#define QUANTITY_VARIABLE_DIMENSIONLESS_MATHFCT ( function,
helper   ) 

Value:

template<typename QT, typename ST> struct helper {static ST exec (const Quantity<QT, ST> &quantity) \
{return ST(std::function (quantity.value ()));}}; \
template<template<typename, typename> class M, typename QT, typename ST, typename SU, typename DQT> \
inline typename GenerateVariable<M<Quantity<QT, ST>, DerivedQuantity<QT, SU, DQT> >, \
BSUtilities::Rational<0> >::Mult \
function (const M<Quantity<QT, ST>, DerivedQuantity<QT, SU, DQT> > &quantity) \
{return typename GenerateVariable<M<Quantity<QT, ST>, DerivedQuantity<QT, SU, DQT> >, \
BSUtilities::Rational<0> >::Mult (BSUtilities::IF<CheckDimensionality<Quantity<QT, ST> >::RET, \
typename helper<QT, ST>::helper, Dummy>::RET::exec (quantity));}
definition of mathematical functions producing a dimensionless result

this macro expands into two template definitions: a helper function and a function taking the respective quantity as an argument and returning the result of the mathematical operation. The macro takes two arguments: the name of the operation and the name of the helper function. A call to the operation is only successful, if the quantity is dimensionless. This is tested through helper struct CheckDimensionality, which returns true if Quantity is dimensionless. In this case, the respective helper is called. On the other hand, if the quantity is NOT dimensionless CheckDimensionality produces a compile time error by trying to instantiate struct Dummy, which is declared, but never defined. The helper function calls the respective operation in namespace std with the untransformed value of the quantity, i.e. no standardization is performed. Return type is a GeneratedVariable by multiplication with rational 0, i.e. all dimension components are zero, ensuring that the return quantity is dimensionless.

Definition at line 2004 of file Variable.h.


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