Environment for a geometry test. More...
#include <geometry_unit_test_base.h>
Public Types | |
using | SharedGeoPtr_t = GeoResources_t::ResourcePtr_t |
using | SharedGeoPtr_t = GeoResources_t::ResourcePtr_t |
Public Types inherited from testing::BasicTesterEnvironment< ConfigurationClass > | |
using | Configuration_t = ConfigurationClass |
using | Configuration_t = ConfigurationClass |
Public Member Functions | |
GeometryTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~GeometryTesterEnvironment () |
Destructor: closing remarks. More... | |
GeometryTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~GeometryTesterEnvironment () |
Destructor: closing remarks. More... | |
GeometryTesterEnvironment (ConfigurationClass const &cfg_obj, bool bSetup=true) | |
Setup from a configuration. More... | |
GeometryTesterEnvironment (ConfigurationClass &&cfg_obj, bool bSetup=true) | |
gar::geo::GeometryCore const * | Geometry () const |
Returns a pointer to the geometry. More... | |
SharedGeoPtr_t | SharedGeometry () const |
GeometryTesterEnvironment (ConfigurationClass const &cfg_obj, bool bSetup=true) | |
Setup from a configuration. More... | |
GeometryTesterEnvironment (ConfigurationClass &&cfg_obj, bool bSetup=true) | |
geo::GeometryCore const * | Geometry () const |
Returns a pointer to the geometry. More... | |
SharedGeoPtr_t | SharedGeometry () const |
Public Member Functions inherited from testing::TesterEnvironment< ConfigurationClass > | |
template<typename Prov , typename... Args> | |
Prov * | SetupProvider (Args...args) |
Sets a service provider up by calling its testing::setupProvider() More... | |
template<typename Prov > | |
Prov * | SetupProviderFromService (std::string name) |
Sets a service provider up by calling its testing::setupProvider() More... | |
template<typename Prov > | |
Prov * | AcquireProvider (std::unique_ptr< Prov > &&prov) |
Acquires a service provider. More... | |
template<typename Interface , typename Prov , typename... Args> | |
Prov * | SetupProviderFor (Args...args) |
Sets a provider up, recording it as implementation of Interface. More... | |
template<typename Interface , typename Prov > | |
Prov * | SetupProviderFromServiceFor (std::string name) |
Sets a provider up, recording it as implementation of Interface. More... | |
template<typename Interface , typename Prov > | |
Prov * | AcquireProviderFor (std::unique_ptr< Prov > &&prov) |
Acquires a service provider implementing an interface. More... | |
template<typename Prov > | |
Prov * | SimpleProviderSetup () |
Oversimplified provider setup. More... | |
template<typename Prov > | |
void | DropProvider () |
Removes and destroys the specified provider. More... | |
template<typename Prov > | |
Prov const * | Provider () const |
Return the specified provider (throws if not available) More... | |
template<typename... Provs> | |
void | FillProviderPack (gar::ProviderPack< Provs... > &pack) const |
Fills the specified provider pack with providers. More... | |
template<typename Prov > | |
Prov::providers_type | ProviderPackFor () const |
Returns a provider pack for the specified provider. More... | |
template<typename Prov , typename... Args> | |
Prov * | SetupProvider (Args &&...args) |
Sets a service provider up by calling its testing::setupProvider() More... | |
template<typename Prov , typename... Args> | |
Prov * | SetupProviderFromService (std::string name, Args &&...args) |
Sets a service provider up by calling its testing::setupProvider() More... | |
template<typename Prov > | |
Prov * | AcquireProvider (std::unique_ptr< Prov > &&prov) |
Acquires a service provider. More... | |
template<typename Interface , typename Prov , typename... Args> | |
Prov * | SetupProviderFor (Args &&...args) |
Sets a provider up, recording it as implementation of Interface. More... | |
template<typename Interface , typename Prov , typename... Args> | |
Prov * | SetupProviderFromServiceFor (std::string name, Args &&...args) |
Sets a provider up, recording it as implementation of Interface. More... | |
template<typename Interface , typename Prov > | |
Prov * | AcquireProviderFor (std::unique_ptr< Prov > &&prov) |
Acquires a service provider implementing an interface. More... | |
template<typename Prov > | |
Prov * | SimpleProviderSetup () |
Oversimplified provider setup. More... | |
template<typename Prov > | |
void | DropProvider () |
Removes and destroys the specified provider. More... | |
template<typename Prov > | |
Prov const * | Provider () const |
Return the specified provider (throws if not available) More... | |
template<typename... Provs> | |
void | FillProviderPack (lar::ProviderPack< Provs... > &pack) const |
Fills the specified provider pack with providers. More... | |
template<typename Prov > | |
Prov::providers_type | ProviderPackFor () const |
Returns a provider pack for the specified provider. More... | |
Public Member Functions inherited from testing::BasicTesterEnvironment< ConfigurationClass > | |
BasicTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~BasicTesterEnvironment () |
Destructor: closing remarks. More... | |
BasicTesterEnvironment (bool bSetup=true) | |
Constructor: sets everything up and declares the test started. More... | |
virtual | ~BasicTesterEnvironment () |
Destructor: closing remarks. More... | |
BasicTesterEnvironment (Configuration_t const &cfg_obj, bool bSetup=true) | |
Setup from a configuration. More... | |
BasicTesterEnvironment (Configuration_t &&cfg_obj, bool bSetup=true) | |
fhicl::ParameterSet const & | Parameters () const |
Returns the full configuration. More... | |
fhicl::ParameterSet | ServiceParameters (std::string service_name) const |
Returns the configuration of the specified service. More... | |
fhicl::ParameterSet | TesterParameters (std::string test_name) const |
Returns the configuration of the specified test. More... | |
fhicl::ParameterSet | TesterParameters () const |
Returns the configuration of the main test (undefined if no main test) More... | |
fhicl::ParameterSet const & | Parameters () const |
Returns the full configuration. More... | |
fhicl::ParameterSet | ServiceParameters (std::string service_name) const |
Returns the configuration of the specified service. More... | |
fhicl::ParameterSet | TesterParameters (std::string test_name) const |
Returns the configuration of the specified test. More... | |
fhicl::ParameterSet | TesterParameters () const |
Returns the configuration of the main test (undefined if no main test) More... | |
BasicTesterEnvironment (Configuration_t const &configurer, bool bSetup=true) | |
Setup from a configuration. More... | |
BasicTesterEnvironment (Configuration_t &&configurer, bool bSetup=true) | |
Static Public Member Functions | |
static gar::geo::GeometryCore const * | GlobalGeometry () |
static SharedGeoPtr_t | SharedGlobalGeometry () |
Returns the current global geometry instance (may be nullptr if none) More... | |
static geo::GeometryCore const * | GlobalGeometry () |
static SharedGeoPtr_t | SharedGlobalGeometry () |
Returns the current global geometry instance (may be nullptr if none) More... | |
Static Public Member Functions inherited from testing::BasicTesterEnvironment< ConfigurationClass > | |
static fhicl::ParameterSet | CompileParameterSet (std::string cfg) |
Compiles a parameter set from a string. More... | |
static fhicl::ParameterSet | CompileParameterSet (std::string cfg) |
Protected Types | |
using | ChannelMapClass = typename ConfigurationClass::ChannelMapClass |
using | ChannelMapClass = typename ConfigurationClass::ChannelMapClass |
Protected Member Functions | |
virtual void | Setup () |
The complete initialization, ran at construction by default. More... | |
virtual std::unique_ptr< gar::geo::GeometryCore > | CreateNewGeometry () const |
Creates a new geometry. More... | |
virtual void | SetupGeometry () |
Sets up the geometry (creates and registers it) More... | |
virtual void | Setup () |
The complete initialization, ran at construction by default. More... | |
virtual std::unique_ptr< geo::GeometryCore > | CreateNewGeometry () const |
Creates a new geometry. More... | |
virtual void | SetupGeometry () |
Sets up the geometry (creates and registers it) More... | |
virtual void | RegisterGeometry (SharedGeoPtr_t new_geom) |
Get ownership of the specified geometry and registers it as global. More... | |
virtual void | RegisterGeometry (gar::geo::GeometryCore const *new_geom) |
virtual void | RegisterGeometry (SharedGeoPtr_t new_geom) |
Get ownership of the specified geometry and registers it as global. More... | |
virtual void | RegisterGeometry (geo::GeometryCore const *new_geom) |
Protected Member Functions inherited from testing::BasicTesterEnvironment< ConfigurationClass > | |
Configuration_t const & | Config () const |
Returns a read-only version of the configuration. More... | |
virtual void | Configure () |
Reads and translates the configuration. More... | |
virtual fhicl::ParameterSet | DefaultParameters () const |
Creates a full configuration for the test. More... | |
Configuration_t const & | Config () const |
Returns a read-only version of the configuration. More... | |
virtual void | Configure () |
Reads and translates the configuration. More... | |
virtual fhicl::ParameterSet | DefaultParameters () const |
Creates a full configuration for the test. More... | |
virtual void | SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const |
Sets up the message facility. More... | |
virtual void | SetupMessageFacility () const |
virtual void | SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const |
Sets up the message facility. More... | |
virtual void | SetupMessageFacility () const |
Private Types | |
using | TesterEnvironment_t = TesterEnvironment< ConfigurationClass > |
Base class. More... | |
using | GeoResources_t = TestSharedGlobalResource< gar::geo::GeometryCore const > |
this implements the singleton interface More... | |
using | TesterEnvironment_t = TesterEnvironment< ConfigurationClass > |
Base class. More... | |
using | GeoResources_t = TestSharedGlobalResource< geo::GeometryCore const > |
this implements the singleton interface More... | |
Private Attributes | |
ConfigurationClass | config |
instance of the configurer More... | |
SharedGeoPtr_t | geom |
pointer to the geometry More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from testing::BasicTesterEnvironment< ConfigurationClass > | |
static fhicl::ParameterSet | ParseParameters (std::string config_path) |
Fills the test configuration from file or from default. More... | |
static fhicl::ParameterSet | ParseParameters (std::string config_path) |
Fills the test configuration from file or from default. More... | |
Protected Attributes inherited from testing::TesterEnvironment< ConfigurationClass > | |
ProviderList | providers |
list of available providers More... | |
Environment for a geometry test.
ConfigurationClass | a class providing compile-time configuration |
The test environment is set up on construction.
The environment provides:
This class or a derived one can be used as global fixture for unit tests that require the presence of geometry (in the form of gar::geo::GeometryCore instance).
Unfortunately Boost does not give any control on the initialization of the object, so everything must be ready to go as hard coded. The ConfigurationClass class tries to alleviate that. That is another, small static class that GeometryTesterEnvironment uses to get its parameters.
The requirements for the ConfigurationClass are:
ChannelMapClass
: concrete type of channel mapping algorithm classstd::string ApplicationName()
: the application namestd::string ConfigurationPath()
: path to the configuration filestd::string GeometryParameterSetPath()
: FHiCL path to the configuration of the geometry; in art is "services.Geometry"
std::string TesterParameterSetPath()
: FHiCL path to the configuration of the geometrystd::string DefaultGeometryConfiguration()
returning a FHiCL string to be parsed to extract the default geometry configurationstd::string DefaultTesterConfiguration()
returning a FHiCL string to be parsed to extract the default test configurationWhether the configuration comes from a file or from the two provided defaults, it is always expected within the parameter set paths: the default configuration must also contain that path.
Note that there is no room for polymorphism here since the setup happens on construction. Some methods are declared virtual in order to allow to tweak some steps of the set up, but it's not trivial to create a derived class that works correctly: the derived class must declare a new default constructor, and that default constructor must call the protected constructor (GeometryTesterEnvironment<ConfigurationClass>(no_setup))
ConfigurationClass | a class providing compile-time configuration |
The test environment is set up on construction.
The environment provides:
This class or a derived one can be used as global fixture for unit tests that require the presence of geometry (in the form of geo::GeometryCore instance).
Unfortunately Boost does not give any control on the initialization of the object, so everything must be ready to go as hard coded. The ConfigurationClass class tries to alleviate that. That is another, small static class that GeometryTesterEnvironment uses to get its parameters.
The requirements for the ConfigurationClass are:
ChannelMapClass
: concrete type of channel mapping algorithm classstd::string ApplicationName()
: the application namestd::string ConfigurationPath()
: path to the configuration filestd::string GeometryParameterSetPath()
: FHiCL path to the configuration of the geometry; in art is "services.Geometry"
std::string TesterParameterSetPath()
: FHiCL path to the configuration of the geometrystd::string DefaultGeometryConfiguration()
returning a FHiCL string to be parsed to extract the default geometry configurationstd::string DefaultTesterConfiguration()
returning a FHiCL string to be parsed to extract the default test configurationWhether the configuration comes from a file or from the two provided defaults, it is always expected within the parameter set paths: the default configuration must also contain that path.
Note that there is no room for polymorphism here since the setup happens on construction. Some methods are declared virtual in order to allow to tweak some steps of the set up, but it's not trivial to create a derived class that works correctly: the derived class must declare a new default constructor, and that default constructor must call the protected constructor (GeometryTesterEnvironment<ConfigurationClass>(no_setup))
Definition at line 191 of file geometry_unit_test_base.h.
|
protected |
Definition at line 258 of file geometry_unit_test_base.h.
|
protected |
Definition at line 258 of file geometry_unit_test_base.h.
|
private |
this implements the singleton interface
Definition at line 199 of file geometry_unit_test_base.h.
|
private |
this implements the singleton interface
Definition at line 199 of file geometry_unit_test_base.h.
using testing::GeometryTesterEnvironment< ConfigurationClass >::SharedGeoPtr_t = GeoResources_t::ResourcePtr_t |
Definition at line 202 of file geometry_unit_test_base.h.
using testing::GeometryTesterEnvironment< ConfigurationClass >::SharedGeoPtr_t = GeoResources_t::ResourcePtr_t |
Definition at line 202 of file geometry_unit_test_base.h.
|
private |
Base class.
Definition at line 196 of file geometry_unit_test_base.h.
|
private |
Base class.
Definition at line 196 of file geometry_unit_test_base.h.
|
inline |
Constructor: sets everything up and declares the test started.
The configuration is from a default-constructed ConfigurationClass. This is suitable for use as Boost unit test fixture.
Definition at line 210 of file geometry_unit_test_base.h.
|
inline |
Setup from a configuration.
configurer | an instance of ConfigurationClass |
The configuration is from the specified configurer class.
This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.
In the r-value-reference constructor, the configurer is moved.
Definition at line 228 of file geometry_unit_test_base.h.
|
inline |
Definition at line 231 of file geometry_unit_test_base.h.
|
virtual |
Destructor: closing remarks.
Definition at line 289 of file geometry_unit_test_base.h.
|
inline |
Constructor: sets everything up and declares the test started.
The configuration is from a default-constructed ConfigurationClass. This is suitable for use as Boost unit test fixture.
Definition at line 210 of file geometry_unit_test_base.h.
|
inline |
Setup from a configuration.
configurer | an instance of ConfigurationClass |
The configuration is from the specified configurer class.
This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.
In the r-value-reference constructor, the configurer is moved.
Definition at line 228 of file geometry_unit_test_base.h.
|
inline |
Definition at line 231 of file geometry_unit_test_base.h.
|
virtual |
Destructor: closing remarks.
|
protectedvirtual |
Creates a new geometry.
Sets the geometry of the standard detector up.
This function sets up the geometry according to the provided information:
Definition at line 308 of file geometry_unit_test_base.h.
|
protectedvirtual |
Creates a new geometry.
|
inline |
Returns a pointer to the geometry.
Definition at line 242 of file geometry_unit_test_base.h.
|
inline |
Returns a pointer to the geometry.
Definition at line 242 of file geometry_unit_test_base.h.
|
inlinestatic |
Returns the current global geometry instance
std::out_of_range | if not present |
Definition at line 249 of file geometry_unit_test_base.h.
|
inlinestatic |
Returns the current global geometry instance
std::out_of_range | if not present |
Definition at line 249 of file geometry_unit_test_base.h.
|
protectedvirtual |
Get ownership of the specified geometry and registers it as global.
|
protectedvirtual |
Get ownership of the specified geometry and registers it as global.
Definition at line 365 of file geometry_unit_test_base.h.
|
inlineprotectedvirtual |
Definition at line 270 of file geometry_unit_test_base.h.
|
inlineprotectedvirtual |
Definition at line 270 of file geometry_unit_test_base.h.
|
protectedvirtual |
The complete initialization, ran at construction by default.
Reimplemented from testing::BasicTesterEnvironment< ConfigurationClass >.
Definition at line 395 of file geometry_unit_test_base.h.
|
protectedvirtual |
The complete initialization, ran at construction by default.
Reimplemented from testing::BasicTesterEnvironment< ConfigurationClass >.
|
protectedvirtual |
Sets up the geometry (creates and registers it)
Definition at line 380 of file geometry_unit_test_base.h.
|
protectedvirtual |
Sets up the geometry (creates and registers it)
|
inline |
Definition at line 243 of file geometry_unit_test_base.h.
|
inline |
Definition at line 243 of file geometry_unit_test_base.h.
|
inlinestatic |
Returns the current global geometry instance (may be nullptr if none)
Definition at line 253 of file geometry_unit_test_base.h.
|
inlinestatic |
Returns the current global geometry instance (may be nullptr if none)
Definition at line 253 of file geometry_unit_test_base.h.
|
private |
instance of the configurer
Definition at line 279 of file geometry_unit_test_base.h.
|
private |
pointer to the geometry
Definition at line 281 of file geometry_unit_test_base.h.