LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DetectorPropertiesStandardTestHelpers.h
Go to the documentation of this file.
1 
17 #ifndef LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_H
18 #define LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_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 
55  template <>
56  struct ProviderSetupClass<detinfo::DetectorPropertiesStandard> {
57 
58  static std::unique_ptr<detinfo::DetectorPropertiesStandard> setup
59  (
60  fhicl::ParameterSet const& pset,
62  )
63  {
64  // some feedback about whether we are using the right configuration
65  std::string ServiceProviderPath;
66  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
67  std::string ServiceProviderName = ServiceProviderPath;
68  size_t iSlash = ServiceProviderPath.rfind('/');
69  if (iSlash != std::string::npos)
70  ServiceProviderName.erase(0, iSlash + 1);
71 
72  if (ServiceProviderName == "DetectorPropertiesServiceStandard") {
73  LOG_TRACE("ProviderSetup") << "Verified service implementation for "
74  "DetectorPropertiesService"
75  ": '" << ServiceProviderPath << "'";
76  }
77  else {
78  // this means you should not be using the simple set up...
79  mf::LogWarning("setupProvider")
80  << "This set up is for a DetectorPropertiesStandard provider.\n"
81  "Your configuration specifies a '" << ServiceProviderPath
82  << "' service implementation"
83  " that is not known to use that provider.";
84  }
85  }
86 
87  //
88  // create the new DetectorPropertiesStandard service provider
89  //
90  // we choose to ignore a configuration parameter that is known to be used
91  // by the art services but unknown to the provider; in this way we can use
92  // for this test the same configuration as for art-based tests.
93  //
94  std::set<std::string> ignore_keys({ "InheritNumberTimeSamples" });
95  return std::make_unique<detinfo::DetectorPropertiesStandard>
96  (pset, providers, ignore_keys);
97  } // setup()
98 
99  }; // ProviderSetupClass<DetectorPropertiesStandard>
100 
101 
130  template <typename TestEnv>
132  <detinfo::DetectorPropertiesStandard, TestEnv>
133  {
135  {
136  auto* detp = env.template SetupProviderFor
138  (
139  env.ServiceParameters("DetectorPropertiesService"),
140  env.template ProviderPackFor<detinfo::DetectorPropertiesStandard>()
141  );
142  return detp;
143  } // setup()
144 
145  }; // SimpleEnvironmentSetupClass<detinfo::DetectorPropertiesStandard>
146 
147 
148 } // namespace testing
149 
150 
151 #endif // LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_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.
Container for a list of pointers to providers.
Definition: ProviderPack.h:114
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define LOG_TRACE(id)