Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
g4nu::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 59 of file G4PhysicsProcessFactorySingleton.hh.

Constructor & Destructor Documentation

G4PhysicsProcessFactorySingleton::G4PhysicsProcessFactorySingleton ( )
private

Definition at line 49 of file G4PhysicsProcessFactorySingleton.cc.

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

Definition at line 54 of file G4PhysicsProcessFactorySingleton.cc.

55 {
56  fgTheInstance = 0;
57 }
static G4PhysicsProcessFactorySingleton * fgTheInstance
g4nu::G4PhysicsProcessFactorySingleton::G4PhysicsProcessFactorySingleton ( const G4PhysicsProcessFactorySingleton )
private

Member Function Documentation

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

Definition at line 106 of file G4PhysicsProcessFactorySingleton.cc.

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

Definition at line 74 of file G4PhysicsProcessFactorySingleton.cc.

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

Definition at line 59 of file G4PhysicsProcessFactorySingleton.cc.

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

Definition at line 95 of file G4PhysicsProcessFactorySingleton.cc.

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

Definition at line 120 of file G4PhysicsProcessFactorySingleton.cc.

121 {
122  std::vector<G4String> list = AvailablePhysicsProcesses();
123  G4cout << "G4VPhysicsConstructors in "
124  << "G4PhysicsProcessFactorySingleton are: "
125  << G4endl;
126  if ( list.empty() ) G4cout << " ... no registered processes" << G4endl;
127  else {
128  for (size_t indx=0; indx < list.size(); ++indx ) {
129  G4cout << " [" << std::setw(2) << indx << "] "
130  << "\"" << list[indx] << "\"" << G4endl;
131  }
132  }
133 
134 }
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 136 of file G4PhysicsProcessFactorySingleton.cc.

139 {
140  // record new functions for creating processes
141  fFunctionMap[name] = foo;
142  fBoolPtrMap[name] = boolptr;
143  return true;
144 }
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 115 of file G4PhysicsProcessFactorySingleton.hh.

Member Data Documentation

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

Definition at line 87 of file G4PhysicsProcessFactorySingleton.hh.

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

Definition at line 84 of file G4PhysicsProcessFactorySingleton.hh.

G4PhysicsProcessFactorySingleton * G4PhysicsProcessFactorySingleton::fgTheInstance
staticprivate

Definition at line 81 of file G4PhysicsProcessFactorySingleton.hh.

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

Definition at line 89 of file G4PhysicsProcessFactorySingleton.hh.


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