Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 G4CrossSectionFactoryRegistryInstance ()
 

Friends

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

Detailed Description

Definition at line 48 of file G4CrossSectionFactoryRegistry.hh.

Member Function Documentation

◆ GetFactory()

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

Definition at line 78 of file G4CrossSectionFactoryRegistry.cc.

79{
80 G4AutoLock l(G4TypeMutex<G4CrossSectionFactoryRegistry>());
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}
@ 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
const char * name(G4int ptype)

Referenced by G4CrossSectionDataSetRegistry::GetCrossSectionDataSet().

◆ Instance()

◆ Register()

void G4CrossSectionFactoryRegistry::Register ( const G4String name,
G4VBaseXSFactory factory 
)

Definition at line 64 of file G4CrossSectionFactoryRegistry.cc.

65{
66 G4AutoLock l(G4TypeMutex<G4CrossSectionFactoryRegistry>());
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}
@ JustWarning

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

Friends And Related Function Documentation

◆ operator<<

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: