Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions
G4PhysicsConstructorRegistry Class Reference

#include <G4PhysicsConstructorRegistry.hh>

Public Member Functions

 ~G4PhysicsConstructorRegistry ()
 
void Register (G4VPhysicsConstructor *)
 
void DeRegister (G4VPhysicsConstructor *)
 
void Clean ()
 
void AddFactory (G4String, G4VBasePhysConstrFactory *)
 
G4VPhysicsConstructorGetPhysicsConstructor (const G4String &name)
 

Static Public Member Functions

static
G4PhysicsConstructorRegistry
Instance ()
 

Detailed Description

Definition at line 57 of file G4PhysicsConstructorRegistry.hh.

Constructor & Destructor Documentation

G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry ( )

Definition at line 61 of file G4PhysicsConstructorRegistry.cc.

References Clean().

Member Function Documentation

void G4PhysicsConstructorRegistry::AddFactory ( G4String  name,
G4VBasePhysConstrFactory factory 
)

Definition at line 107 of file G4PhysicsConstructorRegistry.cc.

Referenced by G4PhysicsConstructorFactory< T >::G4PhysicsConstructorFactory().

108 {
109  factories[name] = factory;
110 }
const XML_Char * name
void G4PhysicsConstructorRegistry::Clean ( )

Definition at line 66 of file G4PhysicsConstructorRegistry.cc.

References n.

Referenced by ~G4PhysicsConstructorRegistry().

67 {
68  size_t n = physConstr.size();
69  if(n > 0) {
70  for (size_t i=0; i<n; ++i) {
71  if(physConstr[i]) {
72  G4VPhysicsConstructor* p = physConstr[i];
73  physConstr[i] = 0;
74  delete p;
75  }
76  }
77  physConstr.clear();
78  }
79 }
const char * p
Definition: xmltok.h:285
const G4int n
void G4PhysicsConstructorRegistry::DeRegister ( G4VPhysicsConstructor p)

Definition at line 93 of file G4PhysicsConstructorRegistry.cc.

References n.

94 {
95  if(!p) return;
96  size_t n = physConstr.size();
97  if(n > 0) {
98  for (size_t i=0; i<n; ++i) {
99  if(physConstr[i] == p) {
100  physConstr[i] = 0;
101  return;
102  }
103  }
104  }
105 }
const G4int n
G4VPhysicsConstructor * G4PhysicsConstructorRegistry::GetPhysicsConstructor ( const G4String name)

Definition at line 112 of file G4PhysicsConstructorRegistry.cc.

References FatalException, G4endl, and G4Exception().

113 {
114  // check if factory exists...
115  //
116  if (factories.find(name)!=factories.end())
117  {
118  // we could store the list of called factories in some vector and
119  // before returning we can could first check if this physics constructor was already instantiated
120  // if yes, we can throw an exception saying that this physics can been already registered
121 
122  return factories[name]->Instantiate();
123  }
124  else
125  {
127  ED << "The factory for the physics constructor ["<< name << "] does not exist!" << G4endl;
128  G4Exception("G4PhysicsConstructorRegistry::GetPhysicsConstructor", "PhysicsList001", FatalException, ED);
129  return 0;
130  }
131 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const XML_Char * name
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::Instance ( void  )
static

Definition at line 49 of file G4PhysicsConstructorRegistry.cc.

References G4ThreadLocal.

Referenced by G4PhysicsConstructorFactory< T >::G4PhysicsConstructorFactory().

50 {
51  if(0 == theInstance) {
52  static G4ThreadLocal G4PhysicsConstructorRegistry *manager_G4MT_TLS_ = 0 ; if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4PhysicsConstructorRegistry ; G4PhysicsConstructorRegistry &manager = *manager_G4MT_TLS_;
53  theInstance = &manager;
54  }
55  return theInstance;
56 }
#define G4ThreadLocal
Definition: tls.hh:52
void G4PhysicsConstructorRegistry::Register ( G4VPhysicsConstructor p)

Definition at line 81 of file G4PhysicsConstructorRegistry.cc.

References n.

82 {
83  if(!p) return;
84  size_t n = physConstr.size();
85  if(n > 0) {
86  for (size_t i=0; i<n; ++i) {
87  if(physConstr[i] == p) { return; }
88  }
89  }
90  physConstr.push_back(p);
91 }
const G4int n

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