1 #ifndef art_Framework_Services_Registry_ServicesManager_h 2 #define art_Framework_Services_Registry_ServicesManager_h 13 #include "cetlib/HorizontalRule.h" 14 #include "cetlib/LibraryManager.h" 15 #include "cetlib/bold_fontify.h" 16 #include "cetlib_except/demangle.h" 29 class ActivityRegistry;
30 class ProcessConfiguration;
31 class ProducingServiceSignals;
33 class SharedResources;
52 return services_.find(
TypeID{
typeid(T)}) !=
cend(services_);
55 void getParameterSets(std::vector<fhicl::ParameterSet>& out)
const;
61 std::vector<std::string> registerProducts(
70 void put(std::unique_ptr<T>&& premade_service);
72 template <
typename SERVICE,
typename... ARGS>
73 void addSystemService(ARGS&&... args);
79 std::map<TypeID, detail::ServiceCacheEntry> services_{};
80 std::vector<TypeID> requestedCreationOrder_{};
81 std::stack<std::shared_ptr<detail::ServiceWrapperBase>>
82 actualCreationOrder_{};
83 std::vector<std::string> configErrMsgs_{};
90 auto it = services_.find(
TypeID{
typeid(T)});
91 if (it == services_.end()) {
93 <<
"ServicesManager unable to find the service of type '" 94 << cet::demangle_symbol(
typeid(T).name()) <<
"'.\n";
96 return it->second.get<T>(actReg_, resources_, actualCreationOrder_);
103 std::unique_ptr<detail::ServiceHelperBase> service_helper(
105 TypeID const id{
typeid(T)};
106 auto it = services_.find(
id);
107 if (it != services_.end()) {
109 <<
"The system has manually added service of type " 110 << cet::demangle_symbol(
id.name())
111 <<
", but the service system already has a configured service of that " 116 actualCreationOrder_.push(swb);
121 template <
typename SERVICE,
typename... ARGS>
125 put(std::make_unique<SERVICE>(std::forward<ARGS>(args)...));
128 constexpr cet::HorizontalRule rule{100};
131 << rule(
'=') <<
"\n\n" 132 <<
"!! The following service has been misconfigured: !!" 134 << rule(
'-') <<
"\n\nservice_type: " 135 << cet::bold_fontify(cet::demangle_symbol(
typeid(SERVICE).name()))
138 << rule(
'=') <<
"\n\n";
ActivityRegistry & actReg_
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
std::vector< BranchDescription > ProductDescriptions
void addSystemService(ARGS &&...args)
void put(std::unique_ptr< T > &&premade_service)
detail::SharedResources & resources_
std::shared_ptr< ServiceWrapperBase > WrapperBase_ptr
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
char const * what() const noexcept override
static std::string const & service()