19 #ifndef LARCORE_COREUTILS_SERVICEUTIL_H
20 #define LARCORE_COREUTILS_SERVICEUTIL_H
27 #include "art/Framework/Services/Registry/ServiceHandle.h"
28 #include "canvas/Utilities/Exception.h"
29 #include "cetlib_except/demangle.h"
32 #include <type_traits>
39 template <
typename PROVIDER>
42 template <
typename... Services>
79 using Service_t = std::add_const_t<T>;
80 using Provider_t =
typename Service_t::provider_type;
85 art::ServiceHandle<Service_t>
h;
86 Provider_t
const*
const pProvider { h->provider() };
88 throw art::Exception(art::errors::NotFound)
89 <<
"ServiceHandle <" << cet::demangle_symbol(
typeid(Service_t).
name())
90 <<
"> offered a null provider";
125 template <
typename... Services>
140 template <
typename... Services>
149 template <
typename PROVIDER>
157 "Service provider classes must not be copiable"
161 "Service provider classes must not be copiable"
165 "Service provider classes must not be movable"
169 "Service provider classes must not be movable"
175 template <
typename SERVICE>
190 "provider() method has unsupported signature"
197 template <
typename First,
typename... Others>
200 typename First::provider_type,
typename Others::provider_type...
206 lar::providerFrom<First>()
212 template <
typename Service>
223 #endif //#LARCORE_COREUTILS_SERVICEUTIL_H
typename SERVICE::provider_type provider_type
provider_type const *(SERVICE::*)() const provider_func_type
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
Defines classes that can't be copied nor moved.
lar::ProviderPack< typename Services::provider_type...> providersFrom_t
Type of a provider pack with a provider from each of the Services.
ProviderPack< Providers...> makeProviderPack(Providers const *...providers)
Function to create a ProviderPack from the function arguments.
Compiles only if PROVIDER class satisfied service provider requirements.
auto providersFrom()
Returns a lar::ProviderPack with providers from all services.
Container for a list of pointers to providers.
Data structure containing constant pointers to classes.
provider_type provider_type
ServiceProviderRequirementsChecker< provider_type > provider_checker
Checker for the provider.