21#include <ql/errors.hpp>
29 boost::shared_lock<boost::shared_mutex> lock(
mutex_);
35 boost::shared_lock<boost::shared_mutex> lock(
mutex_);
39 return std::make_pair(b->first, b->second.second);
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);
49 WLOG(
"AnalyticFactory::getBuilder(" << analyticName <<
"): no builder found");
50 return std::make_pair(analyticName,
nullptr);
54 const QuantLib::ext::shared_ptr<AbstractAnalyticBuilder>& builder,
const bool allowOverwrite) {
55 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
56 QL_REQUIRE(
builders_.insert(std::make_pair(className, std::make_pair(subAnalytics, builder))).second ||
58 "AnalyticFactory: duplicate builder for className '" << className <<
"'.");
62 const QuantLib::ext::shared_ptr<ore::analytics::InputParameters>& inputs)
const {
64 QuantLib::ext::shared_ptr<Analytic> a;
66 a = builder.second->build(inputs);
67 return std::make_pair(builder.first, a);
std::pair< std::string, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > getBuilder(const std::string &analyticType) const
std::map< std::string, std::pair< std::set< std::string >, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > > getBuilders() 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::map< std::string, std::pair< std::set< std::string >, QuantLib::ext::shared_ptr< AbstractAnalyticBuilder > > > builders_
boost::shared_mutex mutex_
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.