Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CachingEngineBuilder< T, U, Args > Class Template Referenceabstract

Abstract template EngineBuilder class that can cache engines and coupon pricers. More...

#include <ored/portfolio/builders/cachingenginebuilder.hpp>

+ Inheritance diagram for CachingEngineBuilder< T, U, Args >:
+ Collaboration diagram for CachingEngineBuilder< T, U, Args >:

Public Member Functions

 CachingEngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
QuantLib::ext::shared_ptr< U > engine (Args... params)
 Return a PricingEngine or a FloatingRateCouponPricer. More...
 
void reset () override
 reset the builder (e.g. clear cache) More...
 
- Public Member Functions inherited from EngineBuilder
 EngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
virtual ~EngineBuilder ()
 Virtual destructor. More...
 
const string & model () const
 Return the model name. More...
 
const string & engine () const
 Return the engine name. More...
 
const set< string > & tradeTypes () const
 Return the possible trade types. More...
 
const string & configuration (const MarketContext &key)
 Return a configuration (or the default one if key not found) More...
 
virtual void reset ()
 reset the builder (e.g. clear cache) More...
 
void init (const QuantLib::ext::shared_ptr< Market > market, const map< MarketContext, string > &configurations, const map< string, string > &modelParameters, const map< string, string > &engineParameters, const std::map< std::string, std::string > &globalParameters={})
 Initialise this Builder with the market and parameters to use. More...
 
const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > & modelBuilders () const
 return model builders More...
 
std::string engineParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 
std::string modelParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 

Protected Member Functions

virtual T keyImpl (Args...)=0
 
virtual QuantLib::ext::shared_ptr< U > engineImpl (Args...)=0
 

Protected Attributes

map< T, QuantLib::ext::shared_ptr< U > > engines_
 
- Protected Attributes inherited from EngineBuilder
string model_
 
string engine_
 
set< string > tradeTypes_
 
QuantLib::ext::shared_ptr< Marketmarket_
 
map< MarketContext, string > configurations_
 
map< string, string > modelParameters_
 
map< string, string > engineParameters_
 
std::map< std::string, std::string > globalParameters_
 
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders_
 

Detailed Description

template<class T, class U, typename... Args>
class ore::data::CachingEngineBuilder< T, U, Args >

Abstract template EngineBuilder class that can cache engines and coupon pricers.

Subclasses must implement two protected methods:

The first template argument is the cache key type (e.g. a std::string) The second template argument is PricingEngine or FloatingRateCouponPricer The remaining variable arguments are to be passed to engine() and engineImpl(), these are the specific parameters required to build an engine or coupon pricer for this trade type.

Definition at line 51 of file cachingenginebuilder.hpp.

Constructor & Destructor Documentation

◆ CachingEngineBuilder()

CachingEngineBuilder ( const string &  model,
const string &  engine,
const set< string > &  tradeTypes 
)

Constructor that takes a model and engine name

Parameters
modelthe model name
enginethe engine name
tradeTypesa set of trade types

Definition at line 58 of file cachingenginebuilder.hpp.

const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
const string & model() const
Return the model name.
EngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)

Member Function Documentation

◆ engine()

QuantLib::ext::shared_ptr< U > engine ( Args...  params)

Return a PricingEngine or a FloatingRateCouponPricer.

Definition at line 62 of file cachingenginebuilder.hpp.

62 {
63 T key = keyImpl(params...);
64 if (engines_.find(key) == engines_.end()) {
65 // build first (in case it throws)
66 QuantLib::ext::shared_ptr<U> engine = engineImpl(params...);
67 // then add to map
68 engines_[key] = engine;
69 }
70 return engines_[key];
71 }
virtual QuantLib::ext::shared_ptr< U > engineImpl(Args...)=0
map< T, QuantLib::ext::shared_ptr< U > > engines_
virtual T keyImpl(Args...)=0
+ Here is the call graph for this function:

◆ reset()

void reset ( )
overridevirtual

reset the builder (e.g. clear cache)

Reimplemented from EngineBuilder.

Definition at line 73 of file cachingenginebuilder.hpp.

73{ engines_.clear(); }

◆ keyImpl()

virtual T keyImpl ( Args...  )
protectedpure virtual
+ Here is the caller graph for this function:

◆ engineImpl()

virtual QuantLib::ext::shared_ptr< U > engineImpl ( Args...  )
protectedpure virtual
+ Here is the caller graph for this function:

Member Data Documentation

◆ engines_

map<T, QuantLib::ext::shared_ptr<U> > engines_
protected

Definition at line 79 of file cachingenginebuilder.hpp.