QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Related Functions | List of all members
UnitOfMeasure Class Reference

Unit of measure specification More...

#include <ql/experimental/commodities/unitofmeasure.hpp>

+ Inheritance diagram for UnitOfMeasure:
+ Collaboration diagram for UnitOfMeasure:

Classes

struct  Data
 

Public Types

enum  Type { Mass , Volume , Energy , Quantity }
 

Public Member Functions

 UnitOfMeasure ()=default
 default constructor More...
 
 UnitOfMeasure (const std::string &name, const std::string &code, Type unitType)
 
Inspectors
const std::string & name () const
 name, e.g, "Barrels" More...
 
const std::string & code () const
 code, e.g, "BBL", "MT" More...
 
Type unitType () const
 unit type (mass, volume...) More...
 

Related Functions

(Note that these are not member functions.)

bool operator== (const UnitOfMeasure &, const UnitOfMeasure &)
 
bool operator!= (const UnitOfMeasure &, const UnitOfMeasure &)
 
std::ostream & operator<< (std::ostream &, const UnitOfMeasure &)
 

Other information

ext::shared_ptr< Datadata_
 
static std::map< std::string, ext::shared_ptr< UnitOfMeasure::Data > > unitsOfMeasure_
 
bool empty () const
 is this a usable instance? More...
 
const Roundingrounding () const
 
const UnitOfMeasuretriangulationUnitOfMeasure () const
 unit used for triangulation when required More...
 

Detailed Description

Unit of measure specification

Definition at line 37 of file unitofmeasure.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Mass 
Volume 
Energy 
Quantity 

Definition at line 39 of file unitofmeasure.hpp.

Constructor & Destructor Documentation

◆ UnitOfMeasure() [1/2]

UnitOfMeasure ( )
default

default constructor

Instances built via this constructor have undefined behavior. Such instances can only act as placeholders and must be reassigned to a valid currency before being used.

◆ UnitOfMeasure() [2/2]

UnitOfMeasure ( const std::string &  name,
const std::string &  code,
UnitOfMeasure::Type  unitType 
)

Definition at line 37 of file unitofmeasure.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ name()

const std::string & name ( ) const

name, e.g, "Barrels"

Definition at line 105 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

◆ code()

const std::string & code ( ) const

code, e.g, "BBL", "MT"

Definition at line 109 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

◆ unitType()

UnitOfMeasure::Type unitType ( ) const

unit type (mass, volume...)

Definition at line 113 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

◆ empty()

bool empty ( ) const

is this a usable instance?

Definition at line 121 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

◆ rounding()

const Rounding & rounding ( ) const

Definition at line 117 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

◆ triangulationUnitOfMeasure()

const UnitOfMeasure & triangulationUnitOfMeasure ( ) const

unit used for triangulation when required

Definition at line 126 of file unitofmeasure.hpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator==()

bool operator== ( const UnitOfMeasure ,
const UnitOfMeasure  
)
related

Definition at line 130 of file unitofmeasure.hpp.

+ Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const UnitOfMeasure ,
const UnitOfMeasure  
)
related

Definition at line 134 of file unitofmeasure.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const UnitOfMeasure  
)
related

Definition at line 26 of file unitofmeasure.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ data_

ext::shared_ptr<Data> data_
protected

Definition at line 70 of file unitofmeasure.hpp.

◆ unitsOfMeasure_

std::map< std::string, ext::shared_ptr< UnitOfMeasure::Data > > unitsOfMeasure_
staticprivate

Definition at line 73 of file unitofmeasure.hpp.