Logo
Reference manual - version ored_version
Public Types | Public Member Functions | Friends | List of all members
CalibrationInstrumentFactory Class Reference

#include <ored/model/calibrationinstrumentfactory.hpp>

+ Inheritance diagram for CalibrationInstrumentFactory:

Public Types

typedef std::map< std::string, std::function< boost::shared_ptr< CalibrationInstrument >)> > map_type
 

Public Member Functions

boost::shared_ptr< CalibrationInstrumentbuild (const std::string &instrumentType)
 
void addBuilder (const std::string &instrumentType, std::function< boost::shared_ptr< CalibrationInstrument >()> builder, const bool allowOverwrite=false)
 

Friends

class QuantLib::Singleton< CalibrationInstrumentFactory, std::integral_constant< bool, true > >
 

Detailed Description

Calibration instrument factory class

This class is a repository of functions that can build instances of CalibrationInstrument. The functions are keyed on the calibration instrument type that they can build. An instance of this factory class can be asked to build a particular instance of the CalibrationInstrument class via a call to build(const std::string& instrumentType) with the correct calibration instrument type, instrumentType. For example, a call to build("CpiCapFloor") should return a CpiCapFloor instance if the CpiCapFloor calibration instrument building function has been added to the factory.

It is up to each class derived from CalibrationInstrument to register itself with the CalibrationInstrumentFactory via the CalibrationInstrumentRegister class below. All registration does is add a function that can build an instance of that class to the factory and store it against its calibration instrument type key.

Member Typedef Documentation

◆ map_type

typedef std::map<std::string, std::function<boost::shared_ptr<CalibrationInstrument>)> > map_type

The container type used to store the calibration instrument type key and the function that will be used to build a default instance of that calibration instrument type.

Member Function Documentation

◆ build()

boost::shared_ptr<CalibrationInstrument> build ( const std::string &  instrumentType)

A call to build should return an instance of CalibrationInstrument corresponding to the required instrumentType. For example, a call to build("CpiCapFloor") should return a CpiCapFloor instance.

Warning:
If the instrumentType has not been added to the factory then a call to this method for that instrumentType will return a nullptr

◆ addBuilder()

void addBuilder ( const std::string &  instrumentType,
std::function< boost::shared_ptr< CalibrationInstrument >()>  builder,
const bool  allowOverwrite = false 
)

Add a builder function builder for a given instrumentType