Geant4 11.4.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

 ~G4CrossSectionFactoryRegistry ()=default
G4VBaseXSFactoryGetFactory (const G4String &name, G4bool abortIfNotFound=true) const
void Register (const G4String &name, G4VBaseXSFactory *factory)
void DeRegister (G4VBaseXSFactory *factory)
 G4CrossSectionFactoryRegistry (const G4CrossSectionFactoryRegistry &)=delete
G4CrossSectionFactoryRegistryoperator= (const G4CrossSectionFactoryRegistry &)=delete

Static Public Member Functions

static G4CrossSectionFactoryRegistryInstance ()

Friends

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

Detailed Description

Definition at line 48 of file G4CrossSectionFactoryRegistry.hh.

Constructor & Destructor Documentation

◆ ~G4CrossSectionFactoryRegistry()

G4CrossSectionFactoryRegistry::~G4CrossSectionFactoryRegistry ( )
default

◆ G4CrossSectionFactoryRegistry()

G4CrossSectionFactoryRegistry::G4CrossSectionFactoryRegistry ( const G4CrossSectionFactoryRegistry & )
delete

Member Function Documentation

◆ DeRegister()

void G4CrossSectionFactoryRegistry::DeRegister ( G4VBaseXSFactory * factory)

Definition at line 60 of file G4CrossSectionFactoryRegistry.cc.

61{
62 if ( nullptr == factory || factories.empty() ) { return; }
63 G4AutoLock l(regMutex);
64 for ( auto const & f : factories ) {
65 if ( factory == f.second ) {
66 factories[f.first] = nullptr;
67 }
68 }
69 l.unlock();
70}
G4TemplateAutoLock< G4Mutex > G4AutoLock

◆ GetFactory()

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

Definition at line 73 of file G4CrossSectionFactoryRegistry.cc.

74{
75 G4VBaseXSFactory* ptr = nullptr;
76 auto it = factories.find(name);
77 if ( it != factories.end() ) {
78 ptr = it->second;
79 } else if ( abortIfNotFound ) {
81 msg << "Cross section factory with name: " << name << " not found.";
82 G4Exception("G4CrossSectionFactoryRegistry::GetFactory(...)",
83 "CrossSection003", FatalException, msg);
84 }
85 return ptr;
86}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const char * name(G4int ptype)

Referenced by G4CrossSectionDataSetRegistry::GetCrossSectionDataSet().

◆ Instance()

G4CrossSectionFactoryRegistry * G4CrossSectionFactoryRegistry::Instance ( )
static

Definition at line 40 of file G4CrossSectionFactoryRegistry.cc.

41{
43 return &reg;
44}
G4CrossSectionFactoryRegistry(const G4CrossSectionFactoryRegistry &)=delete

Referenced by G4VBaseXSFactory::G4VBaseXSFactory(), and G4CrossSectionDataSetRegistry::GetCrossSectionDataSet().

◆ operator=()

G4CrossSectionFactoryRegistry & G4CrossSectionFactoryRegistry::operator= ( const G4CrossSectionFactoryRegistry & )
delete

◆ Register()

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

Definition at line 49 of file G4CrossSectionFactoryRegistry.cc.

50{
51 if ( factories.find(name) == factories.end() ) {
52 G4AutoLock l(regMutex);
53 if ( factories.find(name) == factories.end() ) {
54 factories[name] = factory;
55 }
56 l.unlock();
57 }
58}

◆ operator<<

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

Definition at line 88 of file G4CrossSectionFactoryRegistry.cc.

88 {
89 msg<<"Factory Registry "<<&rhs<<" has factories: [";
90 for ( std::map<G4String,G4VBaseXSFactory*>::const_iterator it =rhs.factories.begin();
91 it != rhs.factories.end() ; ++it )
92 {
93 msg<<(*it).first<<":"<<(*it).second<<",";
94 }
95 msg<<"]";
96 return msg;
97}

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