19 #define BOOST_TEST_MODULE ( ServiceUtil_test )
26 #include "canvas/Utilities/Exception.h"
27 #include "art/Framework/Services/Registry/ServiceScope.h"
30 #include <boost/test/unit_test.hpp>
42 template <
typename Prov
ider>
63 template struct ServiceProviderRequirementsChecker<MyProvider>;
65 template struct ServiceRequirementsChecker<MyService>;
84 template <
typename Service>
99 static constexpr art::ServiceScope scope_val
100 = art::ServiceScope::LEGACY;
104 static constexpr art::ServiceScope scope_val
105 = art::ServiceScope::LEGACY;
109 static constexpr art::ServiceScope scope_val
110 = art::ServiceScope::LEGACY;
156 GlobalServices.
myServicePtr = std::make_unique<MyService>();
157 BOOST_CHECK_EXCEPTION(lar::providerFrom<MyService>(), art::Exception,
158 [](art::Exception
const&
e)
159 {
return e.categoryCode() == art::errors::NotFound; }
164 GlobalServices.
myServicePtr = std::make_unique<MyService>(&prov);
165 BOOST_TEST(lar::providerFrom<MyService>() == &prov);
179 GlobalServices.
myServicePtr = std::make_unique<MyService>(&prov);
183 auto provPack1 = lar::providersFrom<MyService>();
184 BOOST_TEST(provPack1.get<
MyProvider>() == &prov);
185 BOOST_CHECK_EXCEPTION(lar::providersFrom<MyOtherService>(), art::Exception,
186 [](art::Exception
const&
e)
187 {
return e.categoryCode() == art::errors::NotFound; }
189 BOOST_CHECK_EXCEPTION(
190 (lar::providersFrom<MyService, MyOtherService>()), art::Exception,
191 [](art::Exception
const& e)
192 {
return e.categoryCode() == art::errors::NotFound; }
200 = std::make_unique<YetAnotherService>(&yaprov);
203 = lar::providersFrom<MyService, MyOtherService, YetAnotherService>();
206 BOOST_TEST(lar::providerFrom<MyService>() == &prov);
207 BOOST_TEST(lar::providerFrom<MyOtherService>() == &oprov);
208 BOOST_TEST(lar::providerFrom<YetAnotherService>() == &yaprov);
An empty class that can't be copied nor moved.
Utilities related to art service access.
Defines classes that can't be copied nor moved.
std::unique_ptr< MyService > myServicePtr
const std::string instance
std::unique_ptr< MyOtherService > myOtherServicePtr
std::unique_ptr< YetAnotherService > yetAnotherServicePtr
provider_type const * provider() const
GlobalServicesClass GlobalServices
Service & operator*() const
MyServiceTemplate(Provider *ptr=nullptr)
ProviderPack< Providers...> makeProviderPack(Providers const *...providers)
Function to create a ProviderPack from the function arguments.
Service * operator->() const