Geant4 11.2.2
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)
 
G4bool IsKnownPhysicsConstructor (const G4String &name)
 
std::vector< G4StringAvailablePhysicsConstructors () const
 
void PrintAvailablePhysicsConstructors () const
 

Static Public Member Functions

static G4PhysicsConstructorRegistryInstance ()
 

Detailed Description

Definition at line 56 of file G4PhysicsConstructorRegistry.hh.

Constructor & Destructor Documentation

◆ ~G4PhysicsConstructorRegistry()

G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry ( )

Member Function Documentation

◆ AddFactory()

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

Definition at line 111 of file G4PhysicsConstructorRegistry.cc.

112{
113 factories[name] = factory;
114}
const char * name(G4int ptype)

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

◆ AvailablePhysicsConstructors()

std::vector< G4String > G4PhysicsConstructorRegistry::AvailablePhysicsConstructors ( ) const

Definition at line 143 of file G4PhysicsConstructorRegistry.cc.

144{
145 std::vector<G4String> avail;
146 std::map<G4String,G4VBasePhysConstrFactory*>::const_iterator itr;
147 for ( itr = factories.begin(); itr != factories.end(); ++itr ) {
148 avail.push_back(itr->first);
149 }
150
151 return avail;
152}

Referenced by G4PhysListRegistry::DeconstructPhysListName(), and PrintAvailablePhysicsConstructors().

◆ Clean()

void G4PhysicsConstructorRegistry::Clean ( )

Definition at line 70 of file G4PhysicsConstructorRegistry.cc.

71{
72 size_t n = physConstr.size();
73 if(n > 0) {
74 for (size_t i=0; i<n; ++i) {
75 if(physConstr[i]) {
76 G4VPhysicsConstructor* p = physConstr[i];
77 physConstr[i] = 0;
78 delete p;
79 }
80 }
81 physConstr.clear();
82 }
83}

Referenced by ~G4PhysicsConstructorRegistry().

◆ DeRegister()

void G4PhysicsConstructorRegistry::DeRegister ( G4VPhysicsConstructor * p)

Definition at line 97 of file G4PhysicsConstructorRegistry.cc.

98{
99 if ( !p ) return;
100 size_t n = physConstr.size();
101 if ( n > 0 ) {
102 for (size_t i=0; i<n; ++i) {
103 if ( physConstr[i] == p ) {
104 physConstr[i] = 0;
105 return;
106 }
107 }
108 }
109}

◆ GetPhysicsConstructor()

G4VPhysicsConstructor * G4PhysicsConstructorRegistry::GetPhysicsConstructor ( const G4String & name)

Definition at line 116 of file G4PhysicsConstructorRegistry.cc.

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

Referenced by G4PhysListRegistry::GetModularPhysicsList().

◆ Instance()

G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::Instance ( )
static

Definition at line 53 of file G4PhysicsConstructorRegistry.cc.

54{
55 if(0 == theInstance) {
56 static G4ThreadLocal G4PhysicsConstructorRegistry *manager_G4MT_TLS_ = 0 ; if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4PhysicsConstructorRegistry ; G4PhysicsConstructorRegistry &manager = *manager_G4MT_TLS_;
57 theInstance = &manager;
58 }
59 return theInstance;
60}
#define G4ThreadLocal
Definition tls.hh:77

Referenced by G4PhysListRegistry::DeconstructPhysListName(), G4PhysicsConstructorFactory< T >::G4PhysicsConstructorFactory(), G4PhysListRegistry::GetModularPhysicsList(), and G4PhysListRegistry::PrintAvailablePhysLists().

◆ IsKnownPhysicsConstructor()

G4bool G4PhysicsConstructorRegistry::IsKnownPhysicsConstructor ( const G4String & name)

Definition at line 137 of file G4PhysicsConstructorRegistry.cc.

138{
139 return ( factories.find(name) != factories.end() );
140}

Referenced by G4PhysListRegistry::DeconstructPhysListName(), and G4PhysListRegistry::PrintAvailablePhysLists().

◆ PrintAvailablePhysicsConstructors()

void G4PhysicsConstructorRegistry::PrintAvailablePhysicsConstructors ( ) const

Definition at line 154 of file G4PhysicsConstructorRegistry.cc.

155{
156 std::vector<G4String> avail = AvailablePhysicsConstructors();
157 G4cout << "G4VPhysicsConstructors in G4PhysicsConstructorRegistry are:"
158 << G4endl;
159 if ( avail.empty() ) G4cout << "... no registered processes" << G4endl;
160 else {
161 size_t n = avail.size();
162 for (size_t i=0; i<n; ++i ) {
163 G4cout << " [" << std::setw(3) << i << "] "
164 << " \"" << avail[i] << "\"" << G4endl;
165 }
166 }
167}
G4GLOB_DLL std::ostream G4cout
std::vector< G4String > AvailablePhysicsConstructors() const

◆ Register()

void G4PhysicsConstructorRegistry::Register ( G4VPhysicsConstructor * p)

Definition at line 85 of file G4PhysicsConstructorRegistry.cc.

86{
87 if(!p) return;
88 size_t n = physConstr.size();
89 if(n > 0) {
90 for (size_t i=0; i<n; ++i) {
91 if(physConstr[i] == p) { return; }
92 }
93 }
94 physConstr.push_back(p);
95}

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