27#include <ql/patterns/singleton.hpp>
29#include <boost/make_shared.hpp>
30#include <boost/thread/lock_types.hpp>
31#include <boost/thread/shared_mutex.hpp>
47 virtual QuantLib::ext::shared_ptr<Trade>
build()
const = 0;
56 virtual QuantLib::ext::shared_ptr<Trade>
build()
const override {
return QuantLib::ext::make_shared<T>(); }
63class TradeFactory :
public QuantLib::Singleton<TradeFactory, std::integral_constant<bool, true>> {
64 std::map<std::string, QuantLib::ext::shared_ptr<AbstractTradeBuilder>>
builders_;
68 std::map<std::string, QuantLib::ext::shared_ptr<AbstractTradeBuilder>>
getBuilders()
const;
69 QuantLib::ext::shared_ptr<AbstractTradeBuilder>
getBuilder(
const std::string& tradeType)
const;
70 void addBuilder(
const std::string& tradeType,
const QuantLib::ext::shared_ptr<AbstractTradeBuilder>& builder,
71 const bool allowOverwrite =
false);
74 QuantLib::ext::shared_ptr<Trade>
build(
const std::string& className)
const;
virtual QuantLib::ext::shared_ptr< Trade > build() const =0
virtual ~AbstractTradeBuilder()
Template TradeBuilder class.
virtual QuantLib::ext::shared_ptr< Trade > build() const override
void addBuilder(const std::string &tradeType, const QuantLib::ext::shared_ptr< AbstractTradeBuilder > &builder, const bool allowOverwrite=false)
std::map< std::string, QuantLib::ext::shared_ptr< AbstractTradeBuilder > > builders_
boost::shared_mutex mutex_
QuantLib::ext::shared_ptr< AbstractTradeBuilder > getBuilder(const std::string &tradeType) const
QuantLib::ext::shared_ptr< Trade > build(const std::string &className) const
Build, throws for unknown className.
std::map< std::string, QuantLib::ext::shared_ptr< AbstractTradeBuilder > > getBuilders() const
Serializable Credit Default Swap.