Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 G4PhysicsConstructorRegistryInstance ()
 

Detailed Description

Definition at line 57 of file G4PhysicsConstructorRegistry.hh.

Constructor & Destructor Documentation

◆ ~G4PhysicsConstructorRegistry()

G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry ( )

Member Function Documentation

◆ AddFactory()

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

Definition at line 107 of file G4PhysicsConstructorRegistry.cc.

108{
109 factories[name] = factory;
110}

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

◆ Clean()

void G4PhysicsConstructorRegistry::Clean ( )

Definition at line 66 of file G4PhysicsConstructorRegistry.cc.

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}

Referenced by ~G4PhysicsConstructorRegistry().

◆ DeRegister()

void G4PhysicsConstructorRegistry::DeRegister ( G4VPhysicsConstructor p)

Definition at line 93 of file G4PhysicsConstructorRegistry.cc.

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}

◆ GetPhysicsConstructor()

G4VPhysicsConstructor * G4PhysicsConstructorRegistry::GetPhysicsConstructor ( const G4String name)

Definition at line 112 of file G4PhysicsConstructorRegistry.cc.

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}
@ FatalException
#define G4endl
Definition: G4ios.hh:52
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

◆ Instance()

G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::Instance ( )
static

Definition at line 49 of file G4PhysicsConstructorRegistry.cc.

50{
51 if(0 == theInstance) {
52 static G4PhysicsConstructorRegistry manager;
53 theInstance = &manager;
54 }
55 return theInstance;
56}

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

◆ Register()

void G4PhysicsConstructorRegistry::Register ( G4VPhysicsConstructor p)

Definition at line 81 of file G4PhysicsConstructorRegistry.cc.

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}

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