|
BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
A registry of constructed BDSAcceleratorComponent instances that can be searched. More...
#include <BDSAcceleratorComponentRegistry.hh>

Public Member Functions | |
| ~BDSAcceleratorComponentRegistry () | |
| void | RegisterComponent (BDSAcceleratorComponent *component, G4double rigidtyAtConstructionTime, bool isModified=false) |
| G4bool | IsRegistered (BDSAcceleratorComponent *component, G4double rigidtyAtConstructionTime) |
| Check whether an accelerator component is already registered. | |
| G4bool | IsRegistered (const G4String &componentName, G4double rigidtyAtConstructionTime) |
| Check whether an accelerator component is already registered by name. | |
| G4bool | IsRegisteredAllocated (const BDSAcceleratorComponent *componentName) const |
| Check if a unique component is registered in the allocatedComponents. | |
| BDSAcceleratorComponent * | GetComponent (const G4String &name, G4double rigidtyAtConstructionTime) |
| void | RegisterCurvilinearComponent (BDSAcceleratorComponent *component) |
| void | RegisterTunnelComponent (BDSAcceleratorComponent *component) |
| std::unordered_map< ACRegistryKey, BDSAcceleratorComponent * > | AllComponentsIncludingUnique () const |
| G4int | AlreadyRegisteredNameCount (const G4String &name) const |
| size_t | size () const |
| Size of registry. | |
| void | PrintNumberOfEachType () const |
| Print out the number of each type of component registered. | |
Static Public Member Functions | |
| static BDSAcceleratorComponentRegistry * | Instance () |
| Singleton accessor. | |
Private Types | |
| typedef std::unordered_map< ACRegistryKey, BDSAcceleratorComponent * > | RegistryMap |
Private Member Functions | |
| BDSAcceleratorComponentRegistry () | |
| Default constructor is private as singleton. | |
| BDSAcceleratorComponentRegistry & | operator= (const BDSAcceleratorComponentRegistry &) |
| assignment and copy constructor not implemented nor used | |
| BDSAcceleratorComponentRegistry (BDSAcceleratorComponentRegistry &) | |
Private Attributes | |
| RegistryMap | registry |
| Registry is a map - note 'register' is a protected keyword. | |
| RegistryMap | registryForAllocated |
| A map for absolutely everything including components that are unique. | |
| std::set< BDSAcceleratorComponent * > | allocatedComponents |
| Set of created components not in registry, for memory management. | |
| std::set< BDSAcceleratorComponent * > | curvilinearComponents |
| Set of curvilinear components - purely for memory management. | |
| std::set< BDSAcceleratorComponent * > | tunnelComponents |
| std::unordered_map< std::string, int > | typeCounter |
| std::unordered_map< std::string, int > | nameCounter |
Static Private Attributes | |
| static BDSAcceleratorComponentRegistry * | instance = nullptr |
| The singleton instance. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, BDSAcceleratorComponentRegistry const &r) |
| Output stream. | |
| typedef RegistryMap::iterator | iterator |
| typedef RegistryMap::const_iterator | const_iterator |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| G4bool | empty () const |
A registry of constructed BDSAcceleratorComponent instances that can be searched.
Uses an std::map rather than unordered map as although slower to access (less often and only at construction), a map is faster for iterating than an unordered map, which will be required to apply wrapper physics processes - relatively common.
NOTE, the iterations of the registry applies only to components that can be reused. The AllAllocatedComponents function should be used to access all components held in memory in the registry.
Definition at line 92 of file BDSAcceleratorComponentRegistry.hh.
| typedef RegistryMap::const_iterator BDSAcceleratorComponentRegistry::const_iterator |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 158 of file BDSAcceleratorComponentRegistry.hh.
| typedef RegistryMap::iterator BDSAcceleratorComponentRegistry::iterator |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 157 of file BDSAcceleratorComponentRegistry.hh.
|
private |
Use a typedef for this specific map implementation so we can easily define iterators and internal member variables without risking getting the exact map declaration wrong.
Definition at line 99 of file BDSAcceleratorComponentRegistry.hh.
| BDSAcceleratorComponentRegistry::~BDSAcceleratorComponentRegistry | ( | ) |
Destructor resets instance to 0 so that the class can be reinstantiated if necessary.
Definition at line 68 of file BDSAcceleratorComponentRegistry.cc.
References allocatedComponents, curvilinearComponents, instance, and registry.
|
private |
Default constructor is private as singleton.
Definition at line 65 of file BDSAcceleratorComponentRegistry.cc.
Referenced by Instance().

| std::unordered_map< ACRegistryKey, BDSAcceleratorComponent * > BDSAcceleratorComponentRegistry::AllComponentsIncludingUnique | ( | ) | const |
Access a map of all accelerator components by name, including ones that are uniquely built and stored only for memory management.
Definition at line 167 of file BDSAcceleratorComponentRegistry.cc.
References registry, and registryForAllocated.
Referenced by BDSDetectorConstruction::BuildPhysicsBias().

| G4int BDSAcceleratorComponentRegistry::AlreadyRegisteredNameCount | ( | const G4String & | name | ) | const |
Definition at line 175 of file BDSAcceleratorComponentRegistry.cc.
|
inline |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 159 of file BDSAcceleratorComponentRegistry.hh.
References registry.
|
inline |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 161 of file BDSAcceleratorComponentRegistry.hh.
References registry.
|
inline |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 163 of file BDSAcceleratorComponentRegistry.hh.
References registry.
|
inline |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 160 of file BDSAcceleratorComponentRegistry.hh.
References registry.
|
inline |
NOTE the iterator works only over components that can be reused and not allocated components. Iterator mechanics
Definition at line 162 of file BDSAcceleratorComponentRegistry.hh.
References registry.
| BDSAcceleratorComponent * BDSAcceleratorComponentRegistry::GetComponent | ( | const G4String & | name, |
| G4double | rigidtyAtConstructionTime | ||
| ) |
Access an already constructed component - will return null if no such component found. This is safe as this registry is primarily used by BDSComponentFactory which can return nullptr to BDSDetectorConstruction safely if an invalid component is requested.
Definition at line 145 of file BDSAcceleratorComponentRegistry.cc.
References registry.
Referenced by BDSComponentFactory::CreateComponent().

|
static |
Singleton accessor.
Definition at line 33 of file BDSAcceleratorComponentRegistry.cc.
References BDSAcceleratorComponentRegistry(), and instance.
Referenced by BDSAcceleratorModel::BDSAcceleratorModel(), BDSDetectorConstruction::BuildBeamlines(), BDSDetectorConstruction::BuildPhysicsBias(), BDSCurvilinearBuilder::CreateAngledBridgeComponent(), BDSCurvilinearBuilder::CreateBonusSectionEnd(), BDSCurvilinearBuilder::CreateBonusSectionStart(), BDSComponentFactory::CreateComponent(), BDSCurvilinearBuilder::CreateCurvilinearElement(), BDSCurvilinearBuilder::CreateDefaultBridgeComponent(), BDSCurvilinearBuilder::CreateStraightBridgeComponent(), and BDSTunnelFactoryBase::PrepareTunnelSection().


| G4bool BDSAcceleratorComponentRegistry::IsRegistered | ( | BDSAcceleratorComponent * | component, |
| G4double | rigidtyAtConstructionTime | ||
| ) |
Check whether an accelerator component is already registered.
Definition at line 127 of file BDSAcceleratorComponentRegistry.cc.
References BDSAcceleratorComponent::GetName(), and IsRegistered().
Referenced by IsRegistered(), and RegisterComponent().


| G4bool BDSAcceleratorComponentRegistry::IsRegistered | ( | const G4String & | componentName, |
| G4double | rigidtyAtConstructionTime | ||
| ) |
Check whether an accelerator component is already registered by name.
Definition at line 138 of file BDSAcceleratorComponentRegistry.cc.
References registry.
| G4bool BDSAcceleratorComponentRegistry::IsRegisteredAllocated | ( | const BDSAcceleratorComponent * | componentName | ) | const |
Check if a unique component is registered in the allocatedComponents.
Definition at line 133 of file BDSAcceleratorComponentRegistry.cc.
References allocatedComponents.
Referenced by RegisterComponent().

| void BDSAcceleratorComponentRegistry::PrintNumberOfEachType | ( | ) | const |
Print out the number of each type of component registered.
Definition at line 192 of file BDSAcceleratorComponentRegistry.cc.
References typeCounter.
Referenced by BDSDetectorConstruction::BuildBeamlines().

| void BDSAcceleratorComponentRegistry::RegisterComponent | ( | BDSAcceleratorComponent * | component, |
| G4double | rigidtyAtConstructionTime, | ||
| bool | isModified = false |
||
| ) |
Register a BDSAcceleratorComponent. Once in the registry, can be reused through GetComponent function. Optional flag isModified indicates that the component was modified beyond its original parser definition (ie likely to match the face of another component) and should not be reused even if it appears later in the lattice. In this case, it is stored here, purely for memory management. Note, the registry of allocated components relies on unique naming for unique components. ie sb1_mod_0 and sb1_mod_1.
Definition at line 85 of file BDSAcceleratorComponentRegistry.cc.
References allocatedComponents, BDSAcceleratorComponent::GetName(), BDSAcceleratorComponent::GetType(), IsRegistered(), IsRegisteredAllocated(), nameCounter, RegisterComponent(), registry, registryForAllocated, and typeCounter.
Referenced by BDSComponentFactory::CreateComponent(), and RegisterComponent().


| void BDSAcceleratorComponentRegistry::RegisterCurvilinearComponent | ( | BDSAcceleratorComponent * | component | ) |
Register a curvilinear component - purely to keep track of and delete at the end of the program.
Definition at line 157 of file BDSAcceleratorComponentRegistry.cc.
References curvilinearComponents.
Referenced by BDSCurvilinearBuilder::CreateAngledBridgeComponent(), BDSCurvilinearBuilder::CreateBonusSectionEnd(), BDSCurvilinearBuilder::CreateBonusSectionStart(), BDSCurvilinearBuilder::CreateCurvilinearElement(), BDSCurvilinearBuilder::CreateDefaultBridgeComponent(), and BDSCurvilinearBuilder::CreateStraightBridgeComponent().

| void BDSAcceleratorComponentRegistry::RegisterTunnelComponent | ( | BDSAcceleratorComponent * | component | ) |
Register a tunnel component - purely to keep track of and delete at the end of the program.
Definition at line 162 of file BDSAcceleratorComponentRegistry.cc.
Referenced by BDSTunnelFactoryBase::PrepareTunnelSection().

|
inline |
Size of registry.
Definition at line 167 of file BDSAcceleratorComponentRegistry.hh.
References registry.
Referenced by BDSDetectorConstruction::BuildBeamlines().

|
friend |
Output stream.
Definition at line 181 of file BDSAcceleratorComponentRegistry.cc.
|
private |
Set of created components not in registry, for memory management.
Definition at line 187 of file BDSAcceleratorComponentRegistry.hh.
Referenced by IsRegisteredAllocated(), RegisterComponent(), and ~BDSAcceleratorComponentRegistry().
|
private |
Set of curvilinear components - purely for memory management.
Definition at line 190 of file BDSAcceleratorComponentRegistry.hh.
Referenced by RegisterCurvilinearComponent(), and ~BDSAcceleratorComponentRegistry().
|
staticprivate |
The singleton instance.
Definition at line 180 of file BDSAcceleratorComponentRegistry.hh.
Referenced by Instance(), and ~BDSAcceleratorComponentRegistry().
|
private |
Counter for each component name. Used in case a component is registered but with a different rigidity. We'll have to name it differently with a numbered suffix.
Definition at line 202 of file BDSAcceleratorComponentRegistry.hh.
Referenced by RegisterComponent().
|
private |
Registry is a map - note 'register' is a protected keyword.
Definition at line 102 of file BDSAcceleratorComponentRegistry.hh.
Referenced by AllComponentsIncludingUnique(), begin(), begin(), empty(), end(), end(), GetComponent(), IsRegistered(), RegisterComponent(), size(), and ~BDSAcceleratorComponentRegistry().
|
private |
A map for absolutely everything including components that are unique.
Definition at line 105 of file BDSAcceleratorComponentRegistry.hh.
Referenced by AllComponentsIncludingUnique(), and RegisterComponent().
|
private |
Definition at line 192 of file BDSAcceleratorComponentRegistry.hh.
|
private |
Map to count the number of each type registered. We have to use std::string as G4String doesn't provide a hash for the unordered map. We use unordered map because it's faster for insertions and retrievals but slow for range iteration which we only do for debug print out or once.
Definition at line 198 of file BDSAcceleratorComponentRegistry.hh.
Referenced by PrintNumberOfEachType(), and RegisterComponent().