#include <ored/portfolio/legdatafactory.hpp>
Public Types | |
typedef std::map< std::string, std::function< QuantLib::ext::shared_ptr< LegAdditionalData >()> > | map_type |
Public Member Functions | |
QuantLib::ext::shared_ptr< LegAdditionalData > | build (const std::string &legType) |
void | addBuilder (const std::string &legType, std::function< QuantLib::ext::shared_ptr< LegAdditionalData >()> builder, const bool allowOverwrite=false) |
Private Attributes | |
boost::shared_mutex | mutex_ |
map_type | map_ |
Friends | |
class | QuantLib::Singleton< LegDataFactory, std::integral_constant< bool, true > > |
Leg data factory class
This class is a repository of functions that can build instances of LegAdditionalData
. The functions are keyed on the leg data type that they can build. An instance of this factory class can be asked to build a particular instance of the LegAdditionalData class via a call to build(const std::string& legType)
with the correct legType
name. For example, a call to build("Fixed")
should return a FixedLegData
instance if the fixed leg data building function has been added to the factory.
It is up to each class derived from LegAdditionalData
to register itself with the LegDataFactory
via the LegDataRegister
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 leg type key.
Definition at line 65 of file legdatafactory.hpp.
typedef std::map<std::string, std::function<QuantLib::ext::shared_ptr<LegAdditionalData>()> > map_type |
The container type used to store the leg data type key and the function that will be used to build a default instance of that leg data type.
Definition at line 73 of file legdatafactory.hpp.
QuantLib::ext::shared_ptr< LegAdditionalData > build | ( | const std::string & | legType | ) |
A call to build
should return an instance of LegAdditionalData
corresponding to the required legType
. For example, a call to build("Fixed")
should return a FixedLegData
instance.
legType
has not been added to the factory then a call to this method for that legType
will return a nullptr
Definition at line 29 of file legdatafactory.cpp.
void addBuilder | ( | const std::string & | legType, |
std::function< QuantLib::ext::shared_ptr< LegAdditionalData >()> | builder, | ||
const bool | allowOverwrite = false |
||
) |
Add a builder function builder
for a given legType
Definition at line 37 of file legdatafactory.cpp.
|
friend |
Definition at line 49 of file legdatafactory.hpp.
|
private |
Definition at line 89 of file legdatafactory.hpp.
|
private |
Definition at line 90 of file legdatafactory.hpp.