Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Friends
G4CrossSectionFactoryRegistry Class Reference

#include <G4CrossSectionFactoryRegistry.hh>

Public Member Functions

G4VBaseXSFactoryGetFactory (const G4String &name, G4bool abortIfNotFound=true) const
 
void Register (const G4String &name, G4VBaseXSFactory *factory)
 

Static Public Member Functions

static
G4CrossSectionFactoryRegistry
Instance ()
 

Friends

std::ostream & operator<< (std::ostream &, const G4CrossSectionFactoryRegistry &)
 

Detailed Description

Definition at line 48 of file G4CrossSectionFactoryRegistry.hh.

Member Function Documentation

G4VBaseXSFactory * G4CrossSectionFactoryRegistry::GetFactory ( const G4String name,
G4bool  abortIfNotFound = true 
) const

Definition at line 78 of file G4CrossSectionFactoryRegistry.cc.

References FatalException, and G4Exception().

Referenced by G4CrossSectionDataSetRegistry::GetCrossSectionDataSet().

79 {
80  G4AutoLock l(&xsFactoryRegisterMutex);
81  std::map<G4String,G4VBaseXSFactory*>::const_iterator it = factories.find(name);
82  if ( it != factories.end() ) return it->second;
83  else
84  {
85  if ( abortIfNotFound )
86  {
88  msg <<"Cross section factory with name: "<<name
89  <<" not found.";
90  G4Exception("G4CrossSectionFactoryRegistry::Register(...)",
91  "CrossSection003",FatalException,msg);
92  }
93  }
94  return static_cast<G4VBaseXSFactory*>(0);
95 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4CrossSectionFactoryRegistry * G4CrossSectionFactoryRegistry::Instance ( void  )
static
void G4CrossSectionFactoryRegistry::Register ( const G4String name,
G4VBaseXSFactory factory 
)

Definition at line 64 of file G4CrossSectionFactoryRegistry.cc.

References G4Exception(), and JustWarning.

Referenced by G4CrossSectionFactory< T, mode >::G4CrossSectionFactory(), G4CrossSectionFactory< T, 0 >::G4CrossSectionFactory(), and G4CrossSectionFactory< T, 1 >::G4CrossSectionFactory().

65 {
66  G4AutoLock l(&xsFactoryRegisterMutex);
67  if ( factories.find(name) != factories.end() )
68  {
70  msg <<"Cross section factory with name: "<<name
71  <<" already existing, old factory has been replaced";
72  G4Exception("G4CrossSectionFactoryRegistry::Register(...)",
73  "CrossSection002",JustWarning,msg);
74  }
75  factories[name] = factory;
76 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const XML_Char * name
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  msg,
const G4CrossSectionFactoryRegistry rhs 
)
friend

Definition at line 98 of file G4CrossSectionFactoryRegistry.cc.

98  {
99  msg<<"Factory Registry "<<&rhs<<" has factories: [";
100  for ( std::map<G4String,G4VBaseXSFactory*>::const_iterator it =rhs.factories.begin() ;
101  it != rhs.factories.end() ; ++it )
102  {
103  msg<<(*it).first<<":"<<(*it).second<<",";
104  }
105  msg<<"]";
106  return msg;
107 }

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