LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ProviderTestHelpers.h
Go to the documentation of this file.
1 
20 #ifndef LARCORE_TESTUTILS_PROVIDERTESTHELPERS_H
21 #define LARCORE_TESTUTILS_PROVIDERTESTHELPERS_H 1
22 
23 // C/C++ standard libraries
24 #include <functional> // std::function<>
25 #include <memory> // std::unique_ptr<>, std::make_unique()
26 #include <string>
27 #include <utility> // std::forward()
28 
30 namespace testing {
31 
33  template <typename Prov, typename... Args>
34  using setupProvider_t = std::function<std::unique_ptr<Prov>(Args...)>;
35 
37  template <typename Prov>
39 
41  template <typename... Args>
42  static std::unique_ptr<Prov> setup(Args&&... args)
43  {
44  return std::make_unique<Prov>(std::forward<Args>(args)...);
45  }
46 
47  }; // DefaultSetupProviderClass()
48 
75  template <typename Prov>
77 
94  template <typename Prov, typename... Args>
95  std::unique_ptr<Prov> setupProvider(Args&&... args)
96  {
97  return ProviderSetupClass<Prov>::setup(std::forward<Args>(args)...);
98  }
99 
150  template <typename Prov, typename TestEnv>
152 
200  template <typename Prov, typename Interface, typename TestEnv>
201  inline Prov* SimpleEnvironmentStandardSetupByName(TestEnv& env, std::string service_name)
202  {
203  return env.template SetupProviderFromServiceFor<Interface, Prov>(service_name);
204  }
205 
206  // overload for providers with no shared interface
207  template <typename Prov, typename TestEnv>
208  inline Prov* SimpleEnvironmentStandardSetupByName(TestEnv& env, std::string service_name)
209  {
210  return env.template SetupProviderFromService<Prov>(service_name);
211  }
212 
226  template <typename Prov, typename TestEnv>
227  Prov* simpleEnvironmentSetup(TestEnv& env)
228  {
230  }
231 
232 } // namespace testing
233 
234 #endif // LARCORE_TESTUTILS_PROVIDERTESTHELPERS_H
LArSoft test utilities.
std::function< std::unique_ptr< Prov >(Args...)> setupProvider_t
Generic setup provider function type.
static std::unique_ptr< Prov > setup(Args &&...args)
Instantiates a new provider with specified arguments for constructor.
Prov * simpleEnvironmentSetup(TestEnv &env)
Sets up a provider in a specified test environment.
Environment helper to set up a service provider.
A default implementation for provider setup class.
Class to create and set up a new provider.
std::unique_ptr< Prov > setupProvider(Args &&...args)
Function calling ProviderSetupClass<>::setup for the specified provider.
Prov * SimpleEnvironmentStandardSetupByName(TestEnv &env, std::string service_name)
Basic implementation of a environment setup helper.