GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions
GGSGeoPluginManager Class Reference

Manager for geometry plugin. More...

#include <GGSGeoPluginManager.h>

Public Member Functions

 ~GGSGeoPluginManager ()
 Destructor.
 
bool LoadGeoPlugin (const std::string &libName)
 Loads the geometry plugin library. More...
 
GGSVGeometryConstructionGetGeoConstruction ()
 Returns the geometry construction object. More...
 

Static Public Member Functions

static GGSGeoPluginManagerGetInstance ()
 Get the singleton instance. More...
 

Detailed Description

Manager for geometry plugin.

This singleton dynamically loads a GGS geometry contained in an in external dynamic library. Note that it will not build the geometry, but only create and return (via its GetGeoConstruction method) a GGSVGeometryConstruction object. To actually build the geometry, the user must call the Construct method of this object.

See Also
GGSVGeometryConstruction

Definition at line 30 of file GGSGeoPluginManager.h.

Member Function Documentation

GGSVGeometryConstruction* GGSGeoPluginManager::GetGeoConstruction ( )
inline

Returns the geometry construction object.

This method must be called ONLY AFTER a successful call to LoadGeoPlugin. To actually build the geometry, the user must call the Construct method of the returned object.

Returns
Pointer to the geometry construction object.
NULL if previous call to LoadGeoPlugin returned false or if LoadGeoPlugin has not been called at all.

Definition at line 63 of file GGSGeoPluginManager.h.

63  {
64  if (_geoConstruction)
65  return _geoConstruction;
66  else
67  return NULL;
68  }
GGSGeoPluginManager & GGSGeoPluginManager::GetInstance ( )
static

Get the singleton instance.

Returns
Reference to the geometry plugin manager.

Definition at line 30 of file GGSGeoPluginManager.cpp.

30  {
31  static GGSGeoPluginManager instance;
32  return instance;
33 }
Manager for geometry plugin.
bool GGSGeoPluginManager::LoadGeoPlugin ( const std::string &  libName)

Loads the geometry plugin library.

This method opens the library and creates the GGSVGeometryConstruction object. Note that at this stage the geometry has still not been built, but any messenger built in GGSVGeometryConstruction constructor will be available to set geometry parameters before geometry construction.

Parameters
libNameFull path to the library file.
Returns
true if library has been opened and geometry construction object has been created, false otherwise.

Definition at line 46 of file GGSGeoPluginManager.cpp.

46  {
47 
48  static const std::string routineName("GGSGeoPluginManager::LoadGeoPlugin");
49 
50  // Clean any previously loaded geometry
51  G4GeometryManager::GetInstance()->OpenGeometry();
52  G4PhysicalVolumeStore::GetInstance()->Clean();
53  G4LogicalVolumeStore::GetInstance()->Clean();
54  G4SolidStore::GetInstance()->Clean();
55 
56  // Load the GGSGeometryConstruction library
57  _ggsLibrary = dlopen(libName.c_str(), RTLD_LAZY);
58 
59  if (!_ggsLibrary) {
60  COUT(ERROR) << "Cannot load library; " << dlerror() << ENDL;
61  // Reset errors
62  dlerror();
63  return false;
64  }
65 
66  // Reset errors
67  dlerror();
68 
69  // Load the symbols
70  GGSVGeometryConstruction* (*create_GGSGeometryConstruction)() = reinterpret_cast<GGSVGeometryConstruction* (*)()>(dlsym(_ggsLibrary, "GeometryBuilder"));
71  const char* dlsym_error = dlerror();
72  if (dlsym_error) {
73  COUT(ERROR) << "Cannot load symbol create; " << dlsym_error << ENDL;
74  dlclose(_ggsLibrary);
75  _ggsLibrary = NULL;
76  // Reset errors
77  dlerror();
78  return false;
79  }
80 
81  _geoConstruction = create_GGSGeometryConstruction();
82 
83  if (_geoConstruction)
84  return true;
85  else
86  return false;
87 }
Abstract class needed to load GGS geometry.
#define ENDL
Definition: GGSSmartLog.h:93
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Definition: GGSSmartLog.h:66

The documentation for this class was generated from the following files: