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

Manager for MC plugins. More...

#include <GGSMCPluginManager.h>

Public Member Functions

 ~GGSMCPluginManager ()
 Destructor.
 
bool LoadPlugin (const std::string &libName)
 Loads a plugin library. More...
 
G4VUserPhysicsList * LoadPhysicsListPlugin (const std::string &libName)
 Loads a physics list plugin library. More...
 

Static Public Member Functions

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

Detailed Description

Manager for MC plugins.

This singleton dynamically loads MC plugin libraries.

Definition at line 24 of file GGSMCPluginManager.h.

Member Function Documentation

GGSMCPluginManager & GGSMCPluginManager::GetInstance ( )
static

Get the singleton instance.

Returns
Rference to the plugin manager.

Definition at line 22 of file GGSMCPluginManager.cpp.

22  {
23  static GGSMCPluginManager instance;
24  return instance;
25 }
Manager for MC plugins.
G4VUserPhysicsList * GGSMCPluginManager::LoadPhysicsListPlugin ( const std::string &  libName)

Loads a physics list plugin library.

This method opens the library and creates the physics list it contains.

Parameters
libNameFull path to the library file.
Returns
a pointer to the physics list object; false if no plugin physics list is found in the file.

Definition at line 57 of file GGSMCPluginManager.cpp.

57  {
58  static const std::string routineName("GGSMCPluginManager::LoadPhysicsListPlugin");
59 
60  void *library = dlopen(libName.data(), RTLD_LAZY);
61 
62  if (!library) {
63  COUT(ERROR) << "Cannot load library: " << dlerror() << ENDL;
64  return NULL;
65  }
66 
67  _files.push_back(library);
68 
69  // Reset errors
70  dlerror();
71  // Load the symbols
72  G4VUserPhysicsList *(*PLBuilder)() =
73  reinterpret_cast<G4VUserPhysicsList *(*)()>(dlsym(library, "PhysicsListBuilder"));
74 
75  const char *dlsym_error = dlerror();
76  if (dlsym_error) {
77  COUT(ERROR) << "Cannot load symbol PhysicsListBuilder: " << dlsym_error << ENDL;
78  return NULL;
79  }
80 
81  return PLBuilder();
82 }
#define ENDL
Definition: GGSSmartLog.h:105
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Definition: GGSSmartLog.h:76
bool GGSMCPluginManager::LoadPlugin ( const std::string &  libName)

Loads a plugin library.

This method opens the library and gives access to the plugin objects (user actions and sensitive detectors) inside it.

Parameters
libNameFull path to the library file.
Returns
true if library has been successfully opened.

Definition at line 37 of file GGSMCPluginManager.cpp.

37  {
38  static const std::string routineName("GGSMCPluginManager::LoadPlugin");
39 
40  void *library = dlopen(libName.data(), RTLD_NOW);
41 
42  if (!library) {
43  COUT(ERROR) << "Cannot load library: " << dlerror() << ENDL;
44  return false;
45  }
46 
47  _files.push_back(library);
48 
49  // Reset errors
50  dlerror();
51 
52  return true;
53 }
#define ENDL
Definition: GGSSmartLog.h:105
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Definition: GGSSmartLog.h:76

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