SBDQuantityType< Unit, Value > Class Template Reference

This template class defines physical quantity types. More...

Public Types

typedef SBDQuantityType< Unit, Value > Type
 The quantity type.
 
typedef Unit UnitType
 The unit type of the quantity.
 
typedef Value ValueType
 The value type of the quantity.
 

Static Public Attributes

static const SBDQuantityType< Unit, Value > zero
 The zero value.
 

Constructors

 SBDQuantityType ()
 Constructs a physical quantity with default value.
 
 SBDQuantityType (Value v)
 Constructs a physical quantity with value v.
 
 SBDQuantityType (const SBDQuantityType< Unit, Value > &q)
 Constructs a physical quantity from quantity q.
 

Value

Value const & getValue () const
 Returns the value.
 
void getValue (double *array) const
 Stores the value as a double in array[0].
 
void getValue (float *array) const
 Stores the value as a float in array[0].
 
void setValue (const Value &v)
 Sets the value to v.
 

Operators

SBDQuantityType< Unit, Value > & operator= (const SBDQuantityType< Unit, Value > &q)
 Copy the physical quantity q.
 
SBDQuantityType< Unit, Value > & operator= (double d)
 Assign the double d to the physical quantity (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > operator- () const
 Returns the opposite of the physical quantity.
 
SBDQuantityType< Unit, Value > operator+ (const SBDQuantityType< Unit, Value > &q) const
 Returns the sum of this physical quantity with physical quantity q.
 
SBDQuantityType< Unit, Value > operator+ (double d) const
 Returns the sum of this physical quantity with double d (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > & operator+= (const SBDQuantityType< Unit, Value > &q)
 Adds physical quantity q to this physical quantity.
 
SBDQuantityType< Unit, Value > & operator+= (double d)
 Add double d to this physical quantity (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > operator- (const SBDQuantityType< Unit, Value > &q) const
 Returns the difference between this physical quantity and physical quantity q.
 
SBDQuantityType< Unit, Value > operator- (double d) const
 Returns the difference between this physical quantity and double d (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > & operator-= (const SBDQuantityType< Unit, Value > &q)
 Subtracts physical quantity q from this physical quantity.
 
SBDQuantityType< Unit, Value > & operator-= (double d)
 Subtracts double d from this physical quantity (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > operator* (double d) const
 Returns the product of this physical quantity with double d.
 
SBDQuantityType< Unit, Value > & operator*= (double d)
 Multiplies this physical quantity with double d.
 
template<typename UnitB >
SBDQuantityType< Unit, Value > & operator*= (const SBDQuantityType< UnitB, Value > &q)
 Multiplies this physical quantity with physical quantity q (for dimensionless physical quantities only)
 
SBDQuantityType< Unit, Value > operator/ (double d) const
 Returns the division of this physical quantity by double d.
 
SBDQuantityType< Unit, Value > & operator/= (double d)
 Divides this physical quantity by double d.
 
template<typename UnitB >
SBDQuantityType< Unit, Value > & operator/= (const SBDQuantityType< UnitB, Value > &q)
 Divides this physical quantity by physical quantity q (for dimensionless physical quantities only)
 
template<typename UnitB >
SBDQuantityType< typename SBDQuantityUnitMultiplication< Unit, UnitB >::UnitType, Value > operator* (const SBDQuantityType< UnitB, Value > &q) const
 Returns the product of this physical quantity with physical quantity q.
 
template<typename UnitB >
SBDQuantityType< typename SBDQuantityUnitDivision< Unit, UnitB >::UnitType, Value > operator/ (const SBDQuantityType< UnitB, Value > &q) const
 Returns the division of this physical quantity by physical quantity q.
 
template<typename UnitB >
 operator SBDQuantityType< UnitB, Value > () const
 Converts this physical quantity to unit UnitB.
 
template<typename UnitB >
bool operator== (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is equal to physical quantity q.
 
template<typename UnitB >
bool operator!= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is different from physical quantity q.
 
template<typename UnitB >
bool operator< (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is smaller than physical quantity q.
 
template<typename UnitB >
bool operator> (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is larger than physical quantity q.
 
template<typename UnitB >
bool operator<= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is smaller than or equal to physical quantity q.
 
template<typename UnitB >
bool operator>= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is larger than or equal to physical quantity q.
 
bool operator== (double d) const
 Returns true if this physical quantity is equal to double d (for dimensionless physical quantities only)
 
bool operator!= (double d) const
 Returns true if this physical quantity is different from double d (for dimensionless physical quantities only)
 
bool operator< (double d) const
 Returns true if this physical quantity is smaller than double d (for dimensionless physical quantities only)
 
bool operator> (double d) const
 Returns true if this physical quantity is larger than double d (for dimensionless physical quantities only)
 
bool operator<= (double d) const
 Returns true if this physical quantity is smaller than or equal to double d (for dimensionless physical quantities only)
 
bool operator>= (double d) const
 Returns true if this physical quantity is larger than or equal to double d (for dimensionless physical quantities only)
 

Useful functions

void print (bool fullName=false) const
 Prints the physical quantity (with a full unit name when fullName is true)
 
std::string toStdString (bool fullName=false) const
 Converts the physical quantity to a string (with a full unit name when fullName is true)
 

Detailed Description

template<typename Unit, typename Value = double>
class SBDQuantityType< Unit, Value >

Template Parameters
UnitThe unit type of the physical quantity
ValueThe value type of the physical quantity

This template class is used to define physical quantity types, i.e. types that represent values associated to units. Precisely, a physical quantity has a both a value of type Value (e.g. double), and a unit type.

SBQuantity::force f=SBQuantity::nanonewton(17.0); // f = 17 nanonewton
SBQuantity::length l=SBQuantity::picometer(8.0); // l = 8 picometer
SBQuantity::energy w=f*l; // w = 136 zeptojoule

Most of the time, developers of SAMSON Elements do not have to use this template, but may directly use some predefined types, e.g. SBQuantity::nanonewton, SBQuantity::angstrom, etc.

Please refer to the description of SAMSON's unit system for more information.

Short name: SBQuantityType

See also
SAMSON's unit system
The SBDType library