LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ProviderTestHelpers.h
Go to the documentation of this file.
1 
21 #ifndef LARCORE_TESTUTILS_PROVIDERTESTHELPERS_H
22 #define LARCORE_TESTUTILS_PROVIDERTESTHELPERS_H 1
23 
24 
25 // C/C++ standard libraries
26 #include <functional> // std::function<>
27 #include <memory> // std::unique_ptr<>, std::make_unique()
28 #include <string>
29 #include <utility> // std::forward()
30 
31 
33 namespace testing {
34 
35 
37  template <typename Prov, typename... Args>
38  using setupProvider_t = std::function<std::unique_ptr<Prov>(Args...)>;
39 
40 
42  template <typename Prov>
44 
46  template <typename... Args>
47  static std::unique_ptr<Prov> setup(Args&&... args)
48  { return std::make_unique<Prov>(std::forward<Args>(args)...); }
49 
50  }; // DefaultSetupProviderClass()
51 
52 
79  template <typename Prov>
81 
82 
99  template <typename Prov, typename... Args>
100  std::unique_ptr<Prov> setupProvider(Args&&... args)
101  { return ProviderSetupClass<Prov>::setup(std::forward<Args>(args)...); }
102 
103 
154  template <typename Prov, typename TestEnv>
156 
157 
205  template <typename Prov, typename Interface, typename TestEnv>
207  (TestEnv& env, std::string service_name)
208  {
209  return
210  env.template SetupProviderFromServiceFor<Interface, Prov>(service_name);
211  }
212 
213  // overload for providers with no shared interface
214  template <typename Prov, typename TestEnv>
216  (TestEnv& env, std::string service_name)
217  { return env.template SetupProviderFromService<Prov>(service_name); }
218 
219 
233  template <typename Prov, typename TestEnv>
234  Prov* simpleEnvironmentSetup(TestEnv& env)
236 
237 
238 } // namespace testing
239 
240 #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.