Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
ReferenceDatumFactory Class Reference

#include <ored/portfolio/referencedatafactory.hpp>

+ Inheritance diagram for ReferenceDatumFactory:
+ Collaboration diagram for ReferenceDatumFactory:

Public Types

typedef std::map< std::string, std::function< QuantLib::ext::shared_ptr< AbstractReferenceDatumBuilder >()> > map_type
 

Public Member Functions

QuantLib::ext::shared_ptr< ReferenceDatumbuild (const std::string &refDatumType)
 
void addBuilder (const std::string &refDatumType, std::function< QuantLib::ext::shared_ptr< AbstractReferenceDatumBuilder >()> builder, const bool allowOverwrite=false)
 

Private Attributes

boost::shared_mutex mutex_
 
map_type map_
 

Friends

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

Detailed Description

Definition at line 53 of file referencedatafactory.hpp.

Member Typedef Documentation

◆ map_type

typedef std::map<std::string, std::function<QuantLib::ext::shared_ptr<AbstractReferenceDatumBuilder>()> > map_type

Definition at line 58 of file referencedatafactory.hpp.

Member Function Documentation

◆ build()

QuantLib::ext::shared_ptr< ReferenceDatum > build ( const std::string &  refDatumType)

Definition at line 28 of file referencedatafactory.cpp.

28 {
29 boost::shared_lock<boost::shared_mutex> lock(mutex_);
30 auto it = map_.find(refDatumType);
31 if (it == map_.end())
32 return nullptr;
33 return it->second()->build();
34}

◆ addBuilder()

void addBuilder ( const std::string &  refDatumType,
std::function< QuantLib::ext::shared_ptr< AbstractReferenceDatumBuilder >()>  builder,
const bool  allowOverwrite = false 
)

Definition at line 36 of file referencedatafactory.cpp.

38 {
39 boost::unique_lock<boost::shared_mutex> lock(mutex_);
40 QL_REQUIRE(map_.insert(std::make_pair(refDatumType, builder)).second,
41 "ReferenceDatumFactory::addBuilder(" << refDatumType << "): builder for key already exists.");
42}

Friends And Related Function Documentation

◆ QuantLib::Singleton< ReferenceDatumFactory, std::integral_constant< bool, true > >

friend class QuantLib::Singleton< ReferenceDatumFactory, std::integral_constant< bool, true > >
friend

Definition at line 50 of file referencedatafactory.hpp.

Member Data Documentation

◆ mutex_

boost::shared_mutex mutex_
private

Definition at line 67 of file referencedatafactory.hpp.

◆ map_

map_type map_
private

Definition at line 68 of file referencedatafactory.hpp.