LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 <memory> // std::unique_ptr<>
30 #include <string>
31 
32 namespace testing {
33 
41  template <>
42  struct ProviderSetupClass<detinfo::DetectorClocksStandard> {
43 
44  static std::unique_ptr<detinfo::DetectorClocksStandard> setup(fhicl::ParameterSet const& pset)
45  {
46  // some feedback about whether we are using the right configuration
47  std::string ServiceProviderPath;
48  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
49  std::string ServiceProviderName = ServiceProviderPath;
50  size_t iSlash = ServiceProviderPath.rfind('/');
51  if (iSlash != std::string::npos) ServiceProviderName.erase(0, iSlash + 1);
52 
53  if (ServiceProviderName == "DetectorClocksServiceStandard") {
54  MF_LOG_TRACE("setupProvider")
55  << "Verified service implementation for DetectorClocksService: '" << ServiceProviderPath
56  << "'";
57  }
58  else {
59  mf::LogWarning("setupProvider")
60  << "This set up is for a DetectorClocksStandard provider.\n"
61  "Your configuration specifies a '"
62  << ServiceProviderPath
63  << "' service implementation"
64  " that is not known to use that provider.";
65  }
66  }
67 
68  //
69  // create the new DetectorClocksStandard service provider
70  //
71  auto detClocks = std::make_unique<detinfo::DetectorClocksStandard>(pset);
72 
73  //
74  // all done
75  //
76  return detClocks;
77  } // setup()
78 
79  }; // ProviderSetupClass<DetectorClocksStandard>
80 
106  template <typename TestEnv>
107  struct SimpleEnvironmentSetupClass<detinfo::DetectorClocksStandard, TestEnv> {
109  {
112  TestEnv>(env, "DetectorClocksService");
113  }
114  };
115 
116 } // namespace testing
117 
118 #endif // LARDATA_DETECTORINFO_DETECTORCLOCKSSTANDARDTESTHELPERS_H
LArSoft test utilities.
Helper classes to be used together with LArSoft&#39;s unit test.
Environment helper to set up a service provider.
#define MF_LOG_TRACE(id)
Class to create and set up a new provider.
static std::unique_ptr< detinfo::DetectorClocksStandard > setup(fhicl::ParameterSet const &pset)
General LArSoft Utilities.
Class used for the conversion of times between different formats and references.
Prov * SimpleEnvironmentStandardSetupByName(TestEnv &env, std::string service_name)
Basic implementation of a environment setup helper.
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:267
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.