1 #ifndef art_Framework_Services_Registry_ServicesManager_h 2 #define art_Framework_Services_Registry_ServicesManager_h 18 #include "cetlib_except/demangle.h" 31 class ActivityRegistry;
32 class MasterProductRegistry;
33 struct ProcessConfiguration;
34 class ProducingServiceSignals;
35 class ServicesManager;
51 cet::LibraryManager
const&,
56 typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val !=
57 ServiceScope::PER_SCHEDULE>>
61 typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val ==
62 ServiceScope::PER_SCHEDULE>>
71 return factory_.find(
TypeID(
typeid(T))) != factory_.end();
75 typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val !=
76 ServiceScope::PER_SCHEDULE>>
77 void put(std::unique_ptr<T>&& premade_service);
80 template <
typename SP,
81 typename = std::enable_if_t<
83 ServiceScope::PER_SCHEDULE>>
84 void put(std::vector<SP>&& premade_services);
99 using SHBCREATOR_t = std::unique_ptr<detail::ServiceHelperBase> (*)();
100 using NameIndex = std::map<std::string, detail::ServiceCache::iterator>;
103 void fillCache_(
ParameterSets const& psets, cet::LibraryManager
const& lm);
105 std::pair<detail::ServiceCache::iterator, bool> insertImpl_(
107 std::unique_ptr<detail::ServiceHelperBase>&& helper);
110 std::unique_ptr<detail::ServiceHelperBase>&& helper,
120 std::vector<std::string> configErrMsgs_{};
126 template <
typename T,
typename>
131 auto it = factory_.find(
TypeID{
typeid(T)});
132 if (it == factory_.end())
134 <<
"art::ServicesManager unable to find the service of type '" 135 << cet::demangle_symbol(
typeid(T).name()) <<
"'.\n";
136 return it->second.get<T>(registry_, actualCreationOrder_);
139 template <
typename T,
typename>
144 auto it = factory_.find(
TypeID{
typeid(T)});
145 if (it == factory_.end())
147 <<
"art::ServicesManager unable to find the service of type '" 148 << cet::demangle_symbol(
typeid(T).name()) <<
"'.\n";
149 return it->second.get<T>(registry_, actualCreationOrder_, sID);
152 template <
typename T,
typename>
156 std::unique_ptr<detail::ServiceHelperBase> service_helper(
158 TypeID const id{
typeid(T)};
160 if (it != factory_.end()) {
162 <<
"The system has manually added service of type " 163 << cet::demangle_symbol(
id.name())
164 <<
", but the service system already has a configured service" 165 <<
" of that type\n";
169 std::move(premade_service)));
170 actualCreationOrder_.push(swb);
175 template <
typename SP,
typename>
179 using element_type =
typename SP::element_type;
180 std::unique_ptr<detail::ServiceHelperBase> service_helper(
182 TypeID const id{
typeid(element_type)};
184 if (it != factory_.end()) {
186 <<
"The system has manually added service of type " 187 << cet::demangle_symbol(
id.name())
188 <<
", but the service system already has a configured service" 189 <<
" of that type\n";
194 std::move(premade_services)));
195 actualCreationOrder_.push(swb);
std::vector< fhicl::ParameterSet > ParameterSets
std::vector< BranchDescription > ProductDescriptions
std::map< TypeID, detail::ServiceCacheEntry > ServiceCache
std::stack< WrapperBase_ptr > ServiceStack
void put(std::unique_ptr< T > &&premade_service)
std::shared_ptr< detail::ServiceWrapperBase > WrapperBase_ptr
std::map< std::string, detail::ServiceCache::iterator > NameIndex
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
art::ActivityRegistry & registry_
std::vector< TypeID > TypeIDs