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

#include <ored/portfolio/bond.hpp>

+ Inheritance diagram for BondFactory:
+ Collaboration diagram for BondFactory:

Public Member Functions

BondBuilder::Result build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData, const std::string &securityId) const
 
void addBuilder (const std::string &referenceDataType, const QuantLib::ext::shared_ptr< BondBuilder > &builder, const bool allowOverwrite=false)
 

Private Attributes

map< std::string, QuantLib::ext::shared_ptr< BondBuilder > > builders_
 
boost::shared_mutex mutex_
 

Detailed Description

Definition at line 204 of file bond.hpp.

Member Function Documentation

◆ build()

BondBuilder::Result build ( const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceData,
const std::string &  securityId 
) const

Definition at line 331 of file bond.cpp.

333 {
334 boost::shared_lock<boost::shared_mutex> lock(mutex_);
335 for (auto const& b : builders_) {
336 if (referenceData->hasData(b.first, securityId)) {
337 auto tmp = b.second->build(engineFactory, referenceData, securityId);
338 tmp.builderLabel = b.first;
339 return tmp;
340 }
341 }
342
343 QL_FAIL("BondFactory: could not build bond '"
344 << securityId
345 << "': no reference data given or no suitable builder registered. Check if bond is set up in the reference "
346 "data and that there is a builder for the reference data type.");
347}
map< std::string, QuantLib::ext::shared_ptr< BondBuilder > > builders_
Definition: bond.hpp:205
boost::shared_mutex mutex_
Definition: bond.hpp:206

◆ addBuilder()

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

Definition at line 349 of file bond.cpp.

350 {
351 boost::unique_lock<boost::shared_mutex> lock(mutex_);
352 QL_REQUIRE(builders_.insert(std::make_pair(referenceDataType, builder)).second || allowOverwrite,
353 "BondFactory::addBuilder(" << referenceDataType << "): builder for key already exists.");
354}

Member Data Documentation

◆ builders_

map<std::string, QuantLib::ext::shared_ptr<BondBuilder> > builders_
private

Definition at line 205 of file bond.hpp.

◆ mutex_

boost::shared_mutex mutex_
mutableprivate

Definition at line 206 of file bond.hpp.