Go to the documentation of this file. 1 #ifndef art_Framework_Services_Registry_detail_declaration_helper_macros_h 2 #define art_Framework_Services_Registry_detail_declaration_helper_macros_h 19 #define ART_DETAIL_STRINGIZED_VALUE(value) #value 20 #define ART_DETAIL_STRINGIZED_TYPE(svc) ART_DETAIL_STRINGIZED_VALUE(svc) 22 #define DEFINE_ART_SERVICE_MAKER(svc, scopeArg) \ 23 std::unique_ptr<ServiceWrapperBase> make(fhicl::ParameterSet const& pset, \ 24 ActivityRegistry& reg, \ 25 detail::SharedResources& resources) \ 26 const final override \ 28 if constexpr (is_shared(ServiceScope::scopeArg) && \ 29 detail::handle_allowed_v<svc>) { \ 30 resources.registerSharedResource(SharedResource<svc>); \ 31 } else if constexpr (is_legacy(ServiceScope::scopeArg)) { \ 32 ensure_only_one_thread(pset); \ 34 return std::make_unique<ServiceWrapper<svc>>(pset, reg); \ 38 #define DEFINE_ART_SERVICE_HELPER_CREATE(svc) \ 39 static std::unique_ptr<ServiceHelperBase> createHelper() \ 41 return std::make_unique<ServiceHelper<svc>>(); \ 45 #define ART_DETAIL_DECLARE_SERVICE(svc, scopeArg) \ 46 namespace art::detail { \ 48 struct ServiceHelper<svc> : public ServiceImplHelper, \ 49 public ServiceLGMHelper, \ 50 public ServiceLGRHelper { \ 51 DEFINE_ART_SERVICE_TYPEID(svc) \ 52 DEFINE_ART_SERVICE_SCOPE(scopeArg) \ 53 DEFINE_ART_SERVICE_RETRIEVER(svc) \ 54 DEFINE_ART_SERVICE_MAKER(svc, scopeArg) \ 56 is_interface_impl() const override \ 64 #define ART_DETAIL_DECLARE_SERVICE_INTERFACE(iface, scopeArg) \ 65 namespace art::detail { \ 67 struct ServiceHelper<iface> : public ServiceInterfaceHelper, \ 68 public ServiceLGRHelper { \ 69 DEFINE_ART_SERVICE_TYPEID(iface) \ 70 DEFINE_ART_SERVICE_SCOPE(scopeArg) \ 71 DEFINE_ART_SERVICE_RETRIEVER(iface) \ 76 #define ART_DETAIL_DECLARE_SERVICE_INTERFACE_IMPL(svc, iface, scopeArg) \ 77 namespace art::detail { \ 79 struct ServiceHelper<svc> : public ServiceInterfaceImplHelper, \ 80 public ServiceLGMHelper, \ 81 public ServiceLGRHelper { \ 82 DEFINE_ART_SERVICE_TYPEID(svc) \ 83 DEFINE_ART_SERVICE_SCOPE(scopeArg) \ 84 DEFINE_ART_SERVICE_RETRIEVER(svc) \ 85 DEFINE_ART_SERVICE_MAKER(svc, scopeArg) \ 87 get_interface_typeid() const final override \ 89 return TypeID{typeid(iface)}; \ 91 std::unique_ptr<ServiceWrapperBase> \ 93 std::shared_ptr<ServiceWrapperBase> const& swb) const final override \ 95 return std::dynamic_pointer_cast<ServiceWrapper<svc>>(swb) \ 98 static_assert(is_shared(ServiceHelper<iface>::scope_val) || \ 99 is_legacy(ServiceHelper<svc>::scope_val), \ 100 "\n\nart error: An implementation that inherits from a " \ 101 "LEGACY interface\n" \ 102 " must be a LEGACY service\n\n"); \