7 #include <boost/config.hpp>
8 #include <boost/type_index.hpp>
9 #include <boost/container/flat_map.hpp>
19 using BaseServicePtr = std::unique_ptr<dbs_base>;
31 return obtain_service_explicit<ConcreteService>();
34 template <
typename ConcreteService,
typename... TDependencies>
37 auto it = _dbs.find(boost::typeindex::type_id<ConcreteService>());
40 it = _dbs.insert(std::make_pair(boost::typeindex::type_id<ConcreteService>(),
41 BaseServicePtr(
new ConcreteService(_db_core, dependencies...))))
45 BaseServicePtr& ret = it->second;
46 return static_cast<ConcreteService&
>(*ret);
50 mutable boost::container::flat_map<boost::typeindex::type_index, BaseServicePtr> _dbs;
tracks the blockchain state in an extensible manner
dbservice_dbs_factory()=delete
ConcreteService & obtain_service_explicit(TDependencies &... dependencies) const
virtual ~dbservice_dbs_factory()
ConcreteService & obtain_service() const