LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DetectorClocksStandardTestHelpers.h
Go to the documentation of this file.
1 
17 #ifndef LARDATA_DETECTORINFO_DETECTORCLOCKSSTANDARDTESTHELPERS_H
18 #define LARDATA_DETECTORINFO_DETECTORCLOCKSSTANDARDTESTHELPERS_H 1
19 
20 // LArSoft libraries
23 
24 // framework and utility libraries
25 #include "fhiclcpp/ParameterSet.h"
27 
28 // C/C++ standard libraries
29 #include <string>
30 #include <memory> // std::unique_ptr<>
31 
32 
33 namespace testing {
34 
42  template <>
43  struct ProviderSetupClass<detinfo::DetectorClocksStandard> {
44 
45  static std::unique_ptr<detinfo::DetectorClocksStandard> setup
46  (fhicl::ParameterSet const& pset)
47  {
48  // some feedback about whether we are using the right configuration
49  std::string ServiceProviderPath;
50  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
51  std::string ServiceProviderName = ServiceProviderPath;
52  size_t iSlash = ServiceProviderPath.rfind('/');
53  if (iSlash != std::string::npos)
54  ServiceProviderName.erase(0, iSlash + 1);
55 
56  if (ServiceProviderName == "DetectorClocksServiceStandard") {
57  LOG_TRACE("setupProvider")
58  << "Verified service implementation for DetectorClocksService: '"
59  << ServiceProviderPath << "'";
60  }
61  else {
62  mf::LogWarning("setupProvider")
63  << "This set up is for a DetectorClocksStandard provider.\n"
64  "Your configuration specifies a '" << ServiceProviderPath
65  << "' service implementation"
66  " that is not known to use that provider.";
67  }
68  }
69 
70  //
71  // create the new DetectorClocksStandard service provider
72  //
73  auto detClocks
74  = std::make_unique<detinfo::DetectorClocksStandard>(pset);
75 
76  //
77  // all done
78  //
79  return detClocks;
80  } // setup()
81 
82  }; // ProviderSetupClass<DetectorClocksStandard>
83 
84 
110  template <typename TestEnv>
111  struct SimpleEnvironmentSetupClass<detinfo::DetectorClocksStandard, TestEnv> {
113  {
116  (env, "DetectorClocksService");
117  }
118  };
119 
120 
121 } // namespace testing
122 
123 
124 #endif // LARDATA_DETECTORINFO_DETECTORCLOCKSSTANDARDTESTHELPERS_H
LArSoft test utilities.
Helper classes to be used together with LArSoft&#39;s unit test.
static std::unique_ptr< Prov > setup(Args &&...args)
Instantiates a new provider with specified arguments for constructor.
Environment helper to set up a service provider.
Class to create and set up a new provider.
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
General LArSoft Utilities.
Conversion of times between different formats and references.
Prov * SimpleEnvironmentStandardSetupByName(TestEnv &env, std::string service_name)
Basic implementation of a environment setup helper.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
#define LOG_TRACE(id)