Logo
Reference manual - version ored_version
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 >:

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.
void reset () override
 reset the builder (e.g. clear cache)
Public Member Functions inherited from EngineBuilder
 EngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
virtual ~EngineBuilder ()
 Virtual destructor.
const stringmodel () const
 Return the model name.
const stringengine () const
 Return the engine name.
const set< string > & tradeTypes () const
 Return the possible trade types.
const stringconfiguration (const MarketContext &key) const
 Return a configuration (or the default one if key not found).
void init (EngineFactory *const engineFactory, 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.
virtual std::string engineParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
virtual std::string modelParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const std::map< std::string, std::string > globalParameters () const
EngineFactoryengineFactory () const
 return model builders

Protected Member Functions

virtual T keyImpl (Args...)=0
virtual QuantLib::ext::shared_ptr< U > engineImpl (Args...)=0
Protected Member Functions inherited from EngineBuilder
std::string getParameter (const std::map< std::string, std::string > &m, const std::string &p, const std::vector< std::string > &qs, const bool mandatory, const std::string &defaultValue) const

Protected Attributes

map< T, QuantLib::ext::shared_ptr< U > > engines_
Protected Attributes inherited from EngineBuilder
string model_
string engine_
set< stringtradeTypes_
EngineFactoryengineFactory_
QuantLib::ext::shared_ptr< Marketmarket_
map< MarketContext, stringconfigurations_
map< string, stringmodelParameters_
map< string, stringengineParameters_
std::map< std::string, std::string > globalParameters_

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:

  • keyImpl() returns a key that is used to cache
  • engineImpl() return a new pricing engine or coupon pricer. When the engine() method is called the CachingEngineBuilder first looks in it's cache to see if it has an engine or coupon pricer for this key already if so it is returned, otherwise a new engine or coupon pricer is created, stored and returned.

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.

Constructor & Destructor Documentation

◆ CachingEngineBuilder()

template<class T, class U, typename... Args>
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

Member Function Documentation

◆ reset()

template<class T, class U, typename... Args>
void reset ( )
overridevirtual

reset the builder (e.g. clear cache)

Reimplemented from EngineBuilder.