MarlinMT  0.1.0
GearGeometry.cc
Go to the documentation of this file.
1 
2 // -- marlinmt headers
5 
6 // -- gear headers
7 #include "gear/GearMgr.h"
8 #include "gearimpl/Util.h"
9 #include "gearxml/GearXML.h"
10 
11 namespace marlinmt {
12 
17  class GearGeometry : public GeometryPlugin {
18  public:
19  GearGeometry(const GearGeometry &) = delete ;
20  GearGeometry& operator=(const GearGeometry &) = delete ;
21 
22  public:
23  GearGeometry() ;
24 
25  protected:
26  void loadGeometry() ;
27  const void *handle() const ;
28  void destroy() ;
29  std::type_index typeIndex() const ;
30  void dumpGeometry() const ;
31 
32  private:
33  StringParameter _gearFile {*this, "GearFile",
34  "The GEAR geometry XML file" } ;
36  std::unique_ptr<gear::GearMgr> _gearMgr {nullptr} ;
37  };
38 
39  //--------------------------------------------------------------------------
40  //--------------------------------------------------------------------------
41 
43  GeometryPlugin("Gear") {
44  setDescription( "Gear geometry plugin. Use geoMgr->geometry<gear::GearMgr>() to access the geometry" ) ;
45  }
46 
47  //--------------------------------------------------------------------------
48 
50  gear::GearXML gearXML( _gearFile ) ;
51  _gearMgr.reset( gearXML.createGearMgr() ) ;
52  }
53 
54  //--------------------------------------------------------------------------
55 
56  const void *GearGeometry::handle() const {
57  return _gearMgr.get() ;
58  }
59 
60  //--------------------------------------------------------------------------
61 
63  _gearMgr = nullptr ;
64  }
65 
66  //--------------------------------------------------------------------------
67 
68  std::type_index GearGeometry::typeIndex() const {
69  return std::type_index( typeid( gear::GearMgr ) ) ;
70  }
71 
72  //--------------------------------------------------------------------------
73 
75  _logger->log<MESSAGE>() << *_gearMgr << std::endl ;
76  }
77 
79 
80 } // namespace marlinmt
81 
#define MARLINMT_DECLARE_GEOMETRY(Class)
Definition: PluginManager.h:40
GearGeometry class Responsible for loading Gear geometry in MarlinMT.
Definition: GearGeometry.cc:17
LoggerPtr _logger
The logger instance.
Definition: Component.h:173
std::type_index typeIndex() const
Get a type index object from the geometry handle.
Definition: GearGeometry.cc:68
void setDescription(const std::string &desc)
Set the component description.
Definition: Component.cc:41
GearGeometry & operator=(const GearGeometry &)=delete
const void * handle() const
Get a handle on the geometry instance.
Definition: GearGeometry.cc:56
void loadGeometry()
Load the geometry.
Definition: GearGeometry.cc:49
StringParameter _gearFile
Definition: GearGeometry.cc:33
void dumpGeometry() const
Dump the geometry in the console.
Definition: GearGeometry.cc:74
GeometryPlugin class Responsible for loading geometry in Marlin and providing access to it through th...
void destroy()
Cleanup geometry.
Definition: GearGeometry.cc:62
std::unique_ptr< gear::GearMgr > _gearMgr
The Gear manager handling geometry.
Definition: GearGeometry.cc:36