QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Public Types | List of all members
UnitOfMeasureConversion Class Reference

#include <unitofmeasureconversion.hpp>

+ Collaboration diagram for UnitOfMeasureConversion:

Classes

struct  Data
 

Public Types

enum  Type { Direct , Derived }
 

Public Member Functions

Constructors
 UnitOfMeasureConversion ()=default
 
 UnitOfMeasureConversion (const CommodityType &commodityType, const UnitOfMeasure &source, const UnitOfMeasure &target, Real conversionFactor)
 
Inspectors
const UnitOfMeasuresource () const
 the source UOM. More...
 
const UnitOfMeasuretarget () const
 the target UOM. More...
 
const CommodityTypecommodityType () const
 the commodity type. More...
 
Type type () const
 the type More...
 
Real conversionFactor () const
 the conversion factor More...
 
const std::string & code () const
 

Utility methods

ext::shared_ptr< Datadata_
 
Quantity convert (const Quantity &quantity) const
 apply the conversion factor to a cash amount More...
 
static UnitOfMeasureConversion chain (const UnitOfMeasureConversion &r1, const UnitOfMeasureConversion &r2)
 chain two conversion factors More...
 
 UnitOfMeasureConversion (const UnitOfMeasureConversion &r1, const UnitOfMeasureConversion &r2)
 

Detailed Description

Definition at line 35 of file unitofmeasureconversion.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Direct 

given directly by the user

Derived 

derived from conversion factors between other uoms

Definition at line 37 of file unitofmeasureconversion.hpp.

Constructor & Destructor Documentation

◆ UnitOfMeasureConversion() [1/3]

◆ UnitOfMeasureConversion() [2/3]

UnitOfMeasureConversion ( const CommodityType commodityType,
const UnitOfMeasure source,
const UnitOfMeasure target,
Real  conversionFactor 
)

the conversionFactor \( r \) is given with the convention that a unit of the source is worth \( r \) units of the target.

Definition at line 28 of file unitofmeasureconversion.cpp.

+ Here is the call graph for this function:

◆ UnitOfMeasureConversion() [3/3]

UnitOfMeasureConversion ( const UnitOfMeasureConversion r1,
const UnitOfMeasureConversion r2 
)
protected

Definition at line 38 of file unitofmeasureconversion.cpp.

Member Function Documentation

◆ source()

const UnitOfMeasure & source ( ) const

the source UOM.

Definition at line 112 of file unitofmeasureconversion.hpp.

+ Here is the caller graph for this function:

◆ target()

const UnitOfMeasure & target ( ) const

the target UOM.

Definition at line 116 of file unitofmeasureconversion.hpp.

+ Here is the caller graph for this function:

◆ commodityType()

const CommodityType & commodityType ( ) const

the commodity type.

Definition at line 108 of file unitofmeasureconversion.hpp.

+ Here is the caller graph for this function:

◆ type()

the type

Definition at line 124 of file unitofmeasureconversion.hpp.

◆ conversionFactor()

Real conversionFactor ( ) const

the conversion factor

Definition at line 120 of file unitofmeasureconversion.hpp.

+ Here is the caller graph for this function:

◆ code()

const std::string & code ( ) const

Definition at line 128 of file unitofmeasureconversion.hpp.

◆ convert()

Quantity convert ( const Quantity quantity) const

apply the conversion factor to a cash amount

Definition at line 61 of file unitofmeasureconversion.cpp.

+ Here is the call graph for this function:

◆ chain()

UnitOfMeasureConversion chain ( const UnitOfMeasureConversion r1,
const UnitOfMeasureConversion r2 
)
static

chain two conversion factors

Definition at line 94 of file unitofmeasureconversion.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ data_

ext::shared_ptr<Data> data_
protected

Definition at line 83 of file unitofmeasureconversion.hpp.