Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
G4PhysicsConstructorRegistry
Instance ()
 

Detailed Description

Definition at line 57 of file G4PhysicsConstructorRegistry.hh.

Constructor & Destructor Documentation

G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry ( )

Definition at line 62 of file G4PhysicsConstructorRegistry.cc.

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 108 of file G4PhysicsConstructorRegistry.cc.

109 {
110  factories[name] = factory;
111 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

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

Definition at line 140 of file G4PhysicsConstructorRegistry.cc.

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

Here is the caller graph for this function:

void G4PhysicsConstructorRegistry::Clean ( )

Definition at line 67 of file G4PhysicsConstructorRegistry.cc.

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

Here is the caller graph for this function:

void G4PhysicsConstructorRegistry::DeRegister ( G4VPhysicsConstructor p)

Definition at line 94 of file G4PhysicsConstructorRegistry.cc.

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

Definition at line 113 of file G4PhysicsConstructorRegistry.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4PhysicsConstructorRegistry * G4PhysicsConstructorRegistry::Instance ( void  )
static

Definition at line 50 of file G4PhysicsConstructorRegistry.cc.

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

Here is the caller graph for this function:

G4bool G4PhysicsConstructorRegistry::IsKnownPhysicsConstructor ( const G4String name)

Definition at line 134 of file G4PhysicsConstructorRegistry.cc.

135 {
136  return ( factories.find(name) != factories.end() );
137 }

Here is the caller graph for this function:

void G4PhysicsConstructorRegistry::PrintAvailablePhysicsConstructors ( ) const

Definition at line 151 of file G4PhysicsConstructorRegistry.cc.

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

Here is the call graph for this function:

void G4PhysicsConstructorRegistry::Register ( G4VPhysicsConstructor p)

Definition at line 82 of file G4PhysicsConstructorRegistry.cc.

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

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