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

TradeFactory. More...

#include <ored/portfolio/tradefactory.hpp>

+ Inheritance diagram for TradeFactory:
+ Collaboration diagram for TradeFactory:

Public Member Functions

std::map< std::string, QuantLib::ext::shared_ptr< AbstractTradeBuilder > > getBuilders () const
 
QuantLib::ext::shared_ptr< AbstractTradeBuildergetBuilder (const std::string &tradeType) const
 
void addBuilder (const std::string &tradeType, const QuantLib::ext::shared_ptr< AbstractTradeBuilder > &builder, const bool allowOverwrite=false)
 
QuantLib::ext::shared_ptr< Tradebuild (const std::string &className) const
 Build, throws for unknown className. More...
 

Private Attributes

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

Detailed Description

TradeFactory.

Definition at line 63 of file tradefactory.hpp.

Member Function Documentation

◆ getBuilders()

std::map< std::string, QuantLib::ext::shared_ptr< AbstractTradeBuilder > > getBuilders ( ) const

Definition at line 29 of file tradefactory.cpp.

29 {
30 boost::shared_lock<boost::shared_mutex> lock(mutex_);
31 return builders_;
32}
std::map< std::string, QuantLib::ext::shared_ptr< AbstractTradeBuilder > > builders_
boost::shared_mutex mutex_

◆ getBuilder()

QuantLib::ext::shared_ptr< AbstractTradeBuilder > getBuilder ( const std::string &  tradeType) const

Definition at line 34 of file tradefactory.cpp.

34 {
35 boost::shared_lock<boost::shared_mutex> lock(mutex_);
36 auto b = builders_.find(className);
37 QL_REQUIRE(b != builders_.end(), "TradeFactory::getBuilder(" << className << "): no builder found");
38 return b->second;
39}
+ Here is the caller graph for this function:

◆ addBuilder()

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

Definition at line 41 of file tradefactory.cpp.

42 {
43 boost::unique_lock<boost::shared_mutex> lock(mutex_);
44 QL_REQUIRE(builders_.insert(std::make_pair(className, builder)).second || allowOverwrite,
45 "TradeFactory: duplicate builder for className '" << className << "'.");
46}

◆ build()

QuantLib::ext::shared_ptr< Trade > build ( const std::string &  className) const

Build, throws for unknown className.

Definition at line 48 of file tradefactory.cpp.

48{ return getBuilder(className)->build(); }
QuantLib::ext::shared_ptr< AbstractTradeBuilder > getBuilder(const std::string &tradeType) const
+ Here is the call graph for this function:

Member Data Documentation

◆ builders_

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

Definition at line 64 of file tradefactory.hpp.

◆ mutex_

boost::shared_mutex mutex_
mutableprivate

Definition at line 65 of file tradefactory.hpp.