Geant4-11
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4PhysicsConstructorRegistry Class Reference

#include <G4PhysicsConstructorRegistry.hh>

Public Member Functions

void AddFactory (G4String, G4VBasePhysConstrFactory *)
 
std::vector< G4StringAvailablePhysicsConstructors () const
 
void Clean ()
 
void DeRegister (G4VPhysicsConstructor *)
 
G4VPhysicsConstructorGetPhysicsConstructor (const G4String &name)
 
G4bool IsKnownPhysicsConstructor (const G4String &name)
 
void PrintAvailablePhysicsConstructors () const
 
void Register (G4VPhysicsConstructor *)
 
 ~G4PhysicsConstructorRegistry ()
 

Static Public Member Functions

static G4PhysicsConstructorRegistryInstance ()
 

Private Member Functions

 G4PhysicsConstructorRegistry ()
 

Private Attributes

std::map< G4String, G4VBasePhysConstrFactory * > factories
 
std::vector< G4VPhysicsConstructor * > physConstr
 

Static Private Attributes

static G4ThreadLocal G4PhysicsConstructorRegistrytheInstance = 0
 

Detailed Description

Definition at line 56 of file G4PhysicsConstructorRegistry.hh.

Constructor & Destructor Documentation

◆ ~G4PhysicsConstructorRegistry()

G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry ( )

Definition at line 65 of file G4PhysicsConstructorRegistry.cc.

References Clean().

◆ G4PhysicsConstructorRegistry()

G4PhysicsConstructorRegistry::G4PhysicsConstructorRegistry ( )
private

Definition at line 62 of file G4PhysicsConstructorRegistry.cc.

63{}

Referenced by Instance().

Member Function Documentation

◆ AddFactory()

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

Definition at line 111 of file G4PhysicsConstructorRegistry.cc.

112{
114}
std::map< G4String, G4VBasePhysConstrFactory * > factories
const char * name(G4int ptype)
factory
Definition: test.py:55

References factories, test::factory, and G4InuclParticleNames::name().

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}

References factories.

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]) {
77 physConstr[i] = 0;
78 delete p;
79 }
80 }
81 physConstr.clear();
82 }
83}
std::vector< G4VPhysicsConstructor * > physConstr

References CLHEP::detail::n, and physConstr.

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}

References CLHEP::detail::n, and physConstr.

◆ 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)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57

References factories, FatalException, G4endl, G4Exception(), and G4InuclParticleNames::name().

Referenced by G4PhysListRegistry::GetModularPhysicsList().

◆ Instance()

G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::Instance ( )
static

◆ IsKnownPhysicsConstructor()

G4bool G4PhysicsConstructorRegistry::IsKnownPhysicsConstructor ( const G4String name)

◆ 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

References AvailablePhysicsConstructors(), G4cout, G4endl, and CLHEP::detail::n.

◆ 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}

References CLHEP::detail::n, and physConstr.

Field Documentation

◆ factories

std::map<G4String, G4VBasePhysConstrFactory*> G4PhysicsConstructorRegistry::factories
private

◆ physConstr

std::vector<G4VPhysicsConstructor*> G4PhysicsConstructorRegistry::physConstr
private

Definition at line 90 of file G4PhysicsConstructorRegistry.hh.

Referenced by Clean(), DeRegister(), and Register().

◆ theInstance

G4ThreadLocal G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::theInstance = 0
staticprivate

Definition at line 88 of file G4PhysicsConstructorRegistry.hh.

Referenced by Instance().


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