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

AnalyticFactory. More...

#include <orea/app/analytics/analyticfactory.hpp>

+ Inheritance diagram for AnalyticFactory:
+ Collaboration diagram for AnalyticFactory:

Public Member Functions

std::map< std::string, std::pair< std::set< std::string >, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > > getBuilders () const
 
std::pair< std::string, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > getBuilder (const std::string &analyticType) const
 
void addBuilder (const std::string &className, const std::set< std::string > &subAnalytics, const QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > &builder, const bool allowOverwrite=false)
 
std::pair< std::string, QuantLib::ext::shared_ptr< Analytic > > build (const std::string &subAnalytic, const QuantLib::ext::shared_ptr< ore::analytics::InputParameters > &inputs) const
 Build, throws for unknown className. More...
 

Private Attributes

std::map< std::string, std::pair< std::set< std::string >, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > > builders_
 
boost::shared_mutex mutex_
 

Detailed Description

AnalyticFactory.

Definition at line 69 of file analyticfactory.hpp.

Member Function Documentation

◆ getBuilders()

std::map< std::string, std::pair< std::set< std::string >, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > > getBuilders ( ) const

Definition at line 28 of file analyticfactory.cpp.

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

◆ getBuilder()

std::pair< std::string, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > getBuilder ( const std::string &  analyticType) const

Definition at line 34 of file analyticfactory.cpp.

34 {
35 boost::shared_lock<boost::shared_mutex> lock(mutex_);
36 // check if matching main analytic
37 auto b = builders_.find(analyticName);
38 if (b != builders_.end())
39 return std::make_pair(b->first, b->second.second);
40
41 // then check subanalytics
42 for (const auto& ba : builders_) {
43 if (ba.second.first.size() > 0) {
44 auto sa = ba.second.first.find(analyticName);
45 if (sa != ba.second.first.end())
46 return std::make_pair(ba.first, ba.second.second);
47 }
48 }
49 WLOG("AnalyticFactory::getBuilder(" << analyticName << "): no builder found");
50 return std::make_pair(analyticName, nullptr);
51}
#define WLOG(text)
+ Here is the caller graph for this function:

◆ addBuilder()

void addBuilder ( const std::string &  className,
const std::set< std::string > &  subAnalytics,
const QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > &  builder,
const bool  allowOverwrite = false 
)

Definition at line 53 of file analyticfactory.cpp.

54 {
55 boost::unique_lock<boost::shared_mutex> lock(mutex_);
56 QL_REQUIRE(builders_.insert(std::make_pair(className, std::make_pair(subAnalytics, builder))).second ||
57 allowOverwrite,
58 "AnalyticFactory: duplicate builder for className '" << className << "'.");
59}

◆ build()

std::pair< std::string, QuantLib::ext::shared_ptr< Analytic > > build ( const std::string &  subAnalytic,
const QuantLib::ext::shared_ptr< ore::analytics::InputParameters > &  inputs 
) const

Build, throws for unknown className.

Definition at line 61 of file analyticfactory.cpp.

62 {
63 auto builder = getBuilder(subAnalytic);
64 QuantLib::ext::shared_ptr<Analytic> a;
65 if (builder.second)
66 a = builder.second->build(inputs);
67 return std::make_pair(builder.first, a);
68}
std::pair< std::string, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > getBuilder(const std::string &analyticType) const
+ Here is the call graph for this function:

Member Data Documentation

◆ builders_

std::map<std::string, std::pair<std::set<std::string>, QuantLib::ext::shared_ptr<AbstractAnalyticBuilder> > > builders_
private

Definition at line 71 of file analyticfactory.hpp.

◆ mutex_

boost::shared_mutex mutex_
mutableprivate

Definition at line 72 of file analyticfactory.hpp.