Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
G4PhysicsProcessFactorySingleton Class Reference

#include <G4PhysicsProcessFactorySingleton.hh>

Classes

struct  Cleaner
 

Public Member Functions

G4VPhysicsConstructor * GetPhysicsProcess (const G4String &)
 
G4bool IsKnownPhysicsProcess (const G4String &)
 
const std::vector< G4String > & AvailablePhysicsProcesses () const
 
void PrintAvailablePhysicsProcesses () const
 
G4bool RegisterCreator (G4String name, PhysProcCtorFuncPtr_t ctorptr, G4bool *ptr)
 

Static Public Member Functions

static G4PhysicsProcessFactorySingletonInstance ()
 

Private Member Functions

 G4PhysicsProcessFactorySingleton ()
 
virtual ~G4PhysicsProcessFactorySingleton ()
 
 G4PhysicsProcessFactorySingleton (const G4PhysicsProcessFactorySingleton &)
 
void operator= (const G4PhysicsProcessFactorySingleton &)
 

Private Attributes

std::map< G4String, PhysProcCtorFuncPtr_tfFunctionMap
 
std::map< G4String, G4bool * > fBoolPtrMap
 
std::vector< G4String > listnames
 

Static Private Attributes

static G4PhysicsProcessFactorySingletonfgTheInstance
 

Friends

struct Cleaner
 

Detailed Description

Definition at line 57 of file G4PhysicsProcessFactorySingleton.hh.

Constructor & Destructor Documentation

G4PhysicsProcessFactorySingleton::G4PhysicsProcessFactorySingleton ( )
private

Definition at line 47 of file G4PhysicsProcessFactorySingleton.cc.

48 {
49  fgTheInstance = this; // record created self in static pointer
50 }
static G4PhysicsProcessFactorySingleton * fgTheInstance
G4PhysicsProcessFactorySingleton::~G4PhysicsProcessFactorySingleton ( )
privatevirtual

Definition at line 52 of file G4PhysicsProcessFactorySingleton.cc.

53 {
54  fgTheInstance = 0;
55 }
static G4PhysicsProcessFactorySingleton * fgTheInstance
G4PhysicsProcessFactorySingleton::G4PhysicsProcessFactorySingleton ( const G4PhysicsProcessFactorySingleton )
private

Member Function Documentation

const std::vector< G4String > & G4PhysicsProcessFactorySingleton::AvailablePhysicsProcesses ( ) const

Definition at line 104 of file G4PhysicsProcessFactorySingleton.cc.

105 {
106  // list of names might be out of date due to new registrations
107  // rescan the std::map on each call (which won't be frequent)
108  listnames.clear();
109 
110  // scan map for registered names
112  for ( itr = fFunctionMap.begin(); itr != fFunctionMap.end(); ++itr )
113  listnames.push_back(itr->first);
114 
115  return listnames;
116 }
intermediate_table::const_iterator const_iterator
std::map< G4String, PhysProcCtorFuncPtr_t > fFunctionMap
G4VPhysicsConstructor * G4PhysicsProcessFactorySingleton::GetPhysicsProcess ( const G4String &  name)

Definition at line 72 of file G4PhysicsProcessFactorySingleton.cc.

73 {
74  G4VPhysicsConstructor* p = 0;
75 
76  // we don't want map creating an entry if it doesn't exist
77  // so use map::find() not map::operator[]
79  = fFunctionMap.find(name);
80  if ( fFunctionMap.end() != itr ) {
81  // found an appropriate entry in the list
82  PhysProcCtorFuncPtr_t foo = itr->second; // this is the function
83  p = (*foo)(); // use function to create the physics process
84  }
85  if ( ! p ) {
86  G4cout << "### G4PhysicsProcessFactorySingleton WARNING: "
87  << "PhysicsProcess " << name << " is not known"
88  << G4endl;
89  }
90  return p;
91 }
static QCString name
Definition: declinfo.cpp:673
intermediate_table::iterator iterator
std::map< G4String, PhysProcCtorFuncPtr_t > fFunctionMap
p
Definition: test.py:223
G4VPhysicsConstructor *(* PhysProcCtorFuncPtr_t)()
G4PhysicsProcessFactorySingleton & G4PhysicsProcessFactorySingleton::Instance ( void  )
static

Definition at line 57 of file G4PhysicsProcessFactorySingleton.cc.

58 {
59  // Cleaner dtor calls G4PhysicsProcessFactorySingleton dtor at job end
60  static Cleaner cleaner;
61 
62  if ( ! fgTheInstance ) {
63  // need to create one
64  cleaner.UseMe(); // dummy call to quiet compiler warnings
66  }
67 
68  return *fgTheInstance;
69 }
static G4PhysicsProcessFactorySingleton * fgTheInstance
G4bool G4PhysicsProcessFactorySingleton::IsKnownPhysicsProcess ( const G4String &  name)

Definition at line 93 of file G4PhysicsProcessFactorySingleton.cc.

94 {
95  // check if we know the name
96  G4bool res = false;
98  = fFunctionMap.find(name);
99  if ( fFunctionMap.end() != itr ) res = true;
100  return res;
101 }
static QCString name
Definition: declinfo.cpp:673
intermediate_table::iterator iterator
std::map< G4String, PhysProcCtorFuncPtr_t > fFunctionMap
void G4PhysicsProcessFactorySingleton::operator= ( const G4PhysicsProcessFactorySingleton )
private
void G4PhysicsProcessFactorySingleton::PrintAvailablePhysicsProcesses ( ) const

Definition at line 118 of file G4PhysicsProcessFactorySingleton.cc.

119 {
120  std::vector<G4String> list = AvailablePhysicsProcesses();
121  G4cout << "G4VPhysicsConstructors in "
122  << "G4PhysicsProcessFactorySingleton are: "
123  << G4endl;
124  if ( list.empty() ) G4cout << " ... no registered processes" << G4endl;
125  else {
126  for (size_t indx=0; indx < list.size(); ++indx ) {
127  G4cout << " [" << std::setw(2) << indx << "] "
128  << "\"" << list[indx] << "\"" << G4endl;
129  }
130  }
131 
132 }
const std::vector< G4String > & AvailablePhysicsProcesses() const
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
G4bool G4PhysicsProcessFactorySingleton::RegisterCreator ( G4String  name,
PhysProcCtorFuncPtr_t  ctorptr,
G4bool *  ptr 
)

Definition at line 134 of file G4PhysicsProcessFactorySingleton.cc.

137 {
138  // record new functions for creating processes
139  fFunctionMap[name] = foo;
140  fBoolPtrMap[name] = boolptr;
141  return true;
142 }
static QCString name
Definition: declinfo.cpp:673
std::map< G4String, PhysProcCtorFuncPtr_t > fFunctionMap

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 113 of file G4PhysicsProcessFactorySingleton.hh.

Member Data Documentation

std::map<G4String, G4bool*> G4PhysicsProcessFactorySingleton::fBoolPtrMap
private

Definition at line 85 of file G4PhysicsProcessFactorySingleton.hh.

std::map<G4String, PhysProcCtorFuncPtr_t> G4PhysicsProcessFactorySingleton::fFunctionMap
private

Definition at line 82 of file G4PhysicsProcessFactorySingleton.hh.

G4PhysicsProcessFactorySingleton * G4PhysicsProcessFactorySingleton::fgTheInstance
staticprivate

Definition at line 79 of file G4PhysicsProcessFactorySingleton.hh.

std::vector<G4String> G4PhysicsProcessFactorySingleton::listnames
mutableprivate

Definition at line 87 of file G4PhysicsProcessFactorySingleton.hh.


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