#include <ored/model/calibrationinstrumentfactory.hpp>
Public Types | |
typedef std::map< std::string, std::function< QuantLib::ext::shared_ptr< CalibrationInstrument >()> > | map_type |
Public Member Functions | |
QuantLib::ext::shared_ptr< CalibrationInstrument > | build (const std::string &instrumentType) |
void | addBuilder (const std::string &instrumentType, std::function< QuantLib::ext::shared_ptr< CalibrationInstrument >()> builder, const bool allowOverwrite=false) |
Private Attributes | |
boost::shared_mutex | mutex_ |
map_type | map_ |
Friends | |
class | QuantLib::Singleton< CalibrationInstrumentFactory, std::integral_constant< bool, true > > |
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.
Definition at line 67 of file calibrationinstrumentfactory.hpp.
typedef std::map<std::string, std::function<QuantLib::ext::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.
Definition at line 76 of file calibrationinstrumentfactory.hpp.
QuantLib::ext::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.
instrumentType
has not been added to the factory then a call to this method for that instrumentType
will return a nullptr
Definition at line 27 of file calibrationinstrumentfactory.cpp.
void addBuilder | ( | const std::string & | instrumentType, |
std::function< QuantLib::ext::shared_ptr< CalibrationInstrument >()> | builder, | ||
const bool | allowOverwrite = false |
||
) |
Add a builder function builder
for a given instrumentType
Definition at line 35 of file calibrationinstrumentfactory.cpp.
|
friend |
Definition at line 49 of file calibrationinstrumentfactory.hpp.
|
private |
Definition at line 94 of file calibrationinstrumentfactory.hpp.
|
private |
Definition at line 95 of file calibrationinstrumentfactory.hpp.