Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
PhQ::SubstanceAmount< NumericType > Class Template Reference

Amount of substance. Typically measured in moles (mol). More...

#include "SubstanceAmount.hpp"

Public Member Functions

 SubstanceAmount ()=default
 Default constructor. Constructs a substance amount with an uninitialized value. More...
 
 SubstanceAmount (const NumericType value, const Unit::SubstanceAmount unit)
 Constructor. Constructs a substance amount with a given value expressed in a given substance amount unit. More...
 
 ~SubstanceAmount () noexcept=default
 Destructor. Destroys this substance amount. More...
 
constexpr SubstanceAmount (const SubstanceAmount< NumericType > &other)=default
 Copy constructor. Constructs a substance amount by copying another one. More...
 
template<typename OtherNumericType >
constexpr SubstanceAmount (const SubstanceAmount< OtherNumericType > &other)
 Copy constructor. Constructs a substance amount by copying another one. More...
 
constexpr SubstanceAmount (SubstanceAmount< NumericType > &&other) noexcept=default
 Move constructor. Constructs a substance amount by moving another one. More...
 
constexpr SubstanceAmount< NumericType > & operator= (const SubstanceAmount< NumericType > &other)=default
 Copy assignment operator. Assigns this substance amount by copying another one. More...
 
template<typename OtherNumericType >
constexpr SubstanceAmount< NumericType > & operator= (const SubstanceAmount< OtherNumericType > &other)
 Copy assignment operator. Assigns this substance amount by copying another one. More...
 
constexpr SubstanceAmount< NumericType > & operator= (SubstanceAmount< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this substance amount by moving another one. More...
 
constexpr SubstanceAmount< NumericType > operator+ (const SubstanceAmount< NumericType > &substance_amount) const
 
constexpr SubstanceAmount< NumericType > operator- (const SubstanceAmount< NumericType > &substance_amount) const
 
constexpr SubstanceAmount< NumericType > operator* (const NumericType number) const
 
constexpr SubstanceAmount< NumericType > operator/ (const NumericType number) const
 
constexpr NumericType operator/ (const SubstanceAmount< NumericType > &substance_amount) const noexcept
 
constexpr void operator+= (const SubstanceAmount< NumericType > &substance_amount) noexcept
 
constexpr void operator-= (const SubstanceAmount< NumericType > &substance_amount) noexcept
 
constexpr void operator*= (const NumericType number) noexcept
 
constexpr void operator/= (const NumericType number) noexcept
 
constexpr double Value () const noexcept
 Value of this physical quantity expressed in its standard unit of measure. More...
 
double Value (const Unit::SubstanceAmount unit) const
 Value of this physical quantity expressed in a given unit of measure. More...
 
constexpr double StaticValue () const
 Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time. More...
 
constexpr double & MutableValue () noexcept
 Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value. More...
 
constexpr void SetValue (const double value) noexcept
 Sets the value of this physical quantity expressed in its standard unit of measure to the given value. More...
 
std::string Print () const
 Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string Print (const Unit::SubstanceAmount unit) const
 Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string JSON () const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string JSON (const Unit::SubstanceAmount unit) const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string XML () const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string XML (const Unit::SubstanceAmount unit) const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string YAML () const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string YAML (const Unit::SubstanceAmount unit) const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure. More...
 

Static Public Member Functions

static constexpr SubstanceAmount< NumericType > Zero ()
 Statically creates a substance amount of zero. More...
 
template<Unit::SubstanceAmount Unit>
static constexpr SubstanceAmount< NumericType > Create (const NumericType value)
 Statically creates a substance amount with a given value expressed in a given substance amount unit. More...
 
static constexpr const PhQ::DimensionsDimensions ()
 Physical dimension set of this physical quantity. More...
 
static constexpr Unit::SubstanceAmount Unit ()
 Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure. More...
 

Protected Attributes

double value
 Value of this physical quantity expressed in its standard unit of measure. More...
 

Private Member Functions

constexpr SubstanceAmount (const NumericType value)
 Constructor. Constructs a substance amount with a given value expressed in the standard substance amount unit. More...
 

Detailed Description

template<typename NumericType = double>
class PhQ::SubstanceAmount< NumericType >

Amount of substance. Typically measured in moles (mol).

Definition at line 39 of file SubstanceAmount.hpp.

Constructor & Destructor Documentation

◆ SubstanceAmount() [1/6]

template<typename NumericType = double>
PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( )
default

Default constructor. Constructs a substance amount with an uninitialized value.

◆ SubstanceAmount() [2/6]

template<typename NumericType = double>
PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( const NumericType  value,
const Unit::SubstanceAmount< NumericType >  unit 
)
inline

Constructor. Constructs a substance amount with a given value expressed in a given substance amount unit.

Definition at line 46 of file SubstanceAmount.hpp.

◆ ~SubstanceAmount()

template<typename NumericType = double>
PhQ::SubstanceAmount< NumericType >::~SubstanceAmount ( )
defaultnoexcept

Destructor. Destroys this substance amount.

◆ SubstanceAmount() [3/6]

template<typename NumericType = double>
constexpr PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( const SubstanceAmount< NumericType > &  other)
constexprdefault

Copy constructor. Constructs a substance amount by copying another one.

◆ SubstanceAmount() [4/6]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( const SubstanceAmount< OtherNumericType > &  other)
inlineexplicitconstexpr

Copy constructor. Constructs a substance amount by copying another one.

Definition at line 57 of file SubstanceAmount.hpp.

◆ SubstanceAmount() [5/6]

template<typename NumericType = double>
constexpr PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( SubstanceAmount< NumericType > &&  other)
constexprdefaultnoexcept

Move constructor. Constructs a substance amount by moving another one.

◆ SubstanceAmount() [6/6]

template<typename NumericType = double>
constexpr PhQ::SubstanceAmount< NumericType >::SubstanceAmount ( const NumericType  value)
inlineexplicitconstexprprivate

Constructor. Constructs a substance amount with a given value expressed in the standard substance amount unit.

Definition at line 134 of file SubstanceAmount.hpp.

Member Function Documentation

◆ Create()

template<typename NumericType = double>
template<Unit::SubstanceAmount Unit>
static constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::Create ( const NumericType  value)
inlinestaticconstexpr

Statically creates a substance amount with a given value expressed in a given substance amount unit.

Definition at line 87 of file SubstanceAmount.hpp.

References PhQ::DimensionalScalar< Unit::SubstanceAmount, double >::value.

◆ Dimensions()

static constexpr const PhQ::Dimensions& PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Dimensions ( )
inlinestaticconstexprinherited

Physical dimension set of this physical quantity.

Definition at line 54 of file DimensionalScalar.hpp.

◆ JSON() [1/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::JSON ( ) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 107 of file DimensionalScalar.hpp.

◆ JSON() [2/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::JSON ( const Unit::SubstanceAmount  unit) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 117 of file DimensionalScalar.hpp.

◆ MutableValue()

constexpr double & PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::MutableValue ( )
inlineconstexprnoexceptinherited

Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value.

Definition at line 83 of file DimensionalScalar.hpp.

◆ operator*()

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::operator* ( const NumericType  number) const
inlineconstexpr

◆ operator*=()

template<typename NumericType = double>
constexpr void PhQ::SubstanceAmount< NumericType >::operator*= ( const NumericType  number)
inlineconstexprnoexcept

◆ operator+()

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::operator+ ( const SubstanceAmount< NumericType > &  substance_amount) const
inlineconstexpr

◆ operator+=()

template<typename NumericType = double>
constexpr void PhQ::SubstanceAmount< NumericType >::operator+= ( const SubstanceAmount< NumericType > &  substance_amount)
inlineconstexprnoexcept

◆ operator-()

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::operator- ( const SubstanceAmount< NumericType > &  substance_amount) const
inlineconstexpr

◆ operator-=()

template<typename NumericType = double>
constexpr void PhQ::SubstanceAmount< NumericType >::operator-= ( const SubstanceAmount< NumericType > &  substance_amount)
inlineconstexprnoexcept

◆ operator/() [1/2]

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::operator/ ( const NumericType  number) const
inlineconstexpr

◆ operator/() [2/2]

template<typename NumericType = double>
constexpr NumericType PhQ::SubstanceAmount< NumericType >::operator/ ( const SubstanceAmount< NumericType > &  substance_amount) const
inlineconstexprnoexcept

◆ operator/=()

template<typename NumericType = double>
constexpr void PhQ::SubstanceAmount< NumericType >::operator/= ( const NumericType  number)
inlineconstexprnoexcept

◆ operator=() [1/3]

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType>& PhQ::SubstanceAmount< NumericType >::operator= ( const SubstanceAmount< NumericType > &  other)
constexprdefault

Copy assignment operator. Assigns this substance amount by copying another one.

◆ operator=() [2/3]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr SubstanceAmount<NumericType>& PhQ::SubstanceAmount< NumericType >::operator= ( const SubstanceAmount< OtherNumericType > &  other)
inlineconstexpr

Copy assignment operator. Assigns this substance amount by copying another one.

Definition at line 69 of file SubstanceAmount.hpp.

References PhQ::DimensionalScalar< UnitType, NumericType >::Value(), and PhQ::DimensionalScalar< Unit::SubstanceAmount, double >::value.

◆ operator=() [3/3]

template<typename NumericType = double>
constexpr SubstanceAmount<NumericType>& PhQ::SubstanceAmount< NumericType >::operator= ( SubstanceAmount< NumericType > &&  other)
constexprdefaultnoexcept

Move assignment operator. Assigns this substance amount by moving another one.

◆ Print() [1/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Print ( ) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 95 of file DimensionalScalar.hpp.

◆ Print() [2/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Print ( const Unit::SubstanceAmount  unit) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure.

Definition at line 101 of file DimensionalScalar.hpp.

◆ SetValue()

constexpr void PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::SetValue ( const double  value)
inlineconstexprnoexceptinherited

Sets the value of this physical quantity expressed in its standard unit of measure to the given value.

Definition at line 89 of file DimensionalScalar.hpp.

◆ StaticValue()

constexpr double PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::StaticValue ( ) const
inlineconstexprinherited

Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time.

Definition at line 77 of file DimensionalScalar.hpp.

◆ Unit()

static constexpr Unit::SubstanceAmount PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Unit ( )
inlinestaticconstexprinherited

Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure.

Definition at line 60 of file DimensionalScalar.hpp.

◆ Value() [1/2]

constexpr double PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Value ( ) const
inlineconstexprnoexceptinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 65 of file DimensionalScalar.hpp.

◆ Value() [2/2]

double PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::Value ( const Unit::SubstanceAmount  unit) const
inlineinherited

Value of this physical quantity expressed in a given unit of measure.

Definition at line 70 of file DimensionalScalar.hpp.

◆ XML() [1/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::XML ( ) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 127 of file DimensionalScalar.hpp.

◆ XML() [2/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::XML ( const Unit::SubstanceAmount  unit) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 137 of file DimensionalScalar.hpp.

◆ YAML() [1/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::YAML ( ) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 147 of file DimensionalScalar.hpp.

◆ YAML() [2/2]

std::string PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::YAML ( const Unit::SubstanceAmount  unit) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 157 of file DimensionalScalar.hpp.

◆ Zero()

template<typename NumericType = double>
static constexpr SubstanceAmount<NumericType> PhQ::SubstanceAmount< NumericType >::Zero ( )
inlinestaticconstexpr

Statically creates a substance amount of zero.

Definition at line 80 of file SubstanceAmount.hpp.

Member Data Documentation

◆ value

double PhQ::DimensionalScalar< Unit::SubstanceAmount , double >::value
protectedinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 221 of file DimensionalScalar.hpp.


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