19#include "BDSAcceleratorComponentRegistry.hh"
43 G4cout << __METHOD_NAME__ <<
"size of registry " <<
registry.size() << G4endl;
51 for (
auto ac : tunnelComponents)
73 for (
const auto element : *line)
88 for (
const auto element : *line)
92 G4cout << __METHOD_NAME__ <<
"size of registry " <<
registry.size() << G4endl;
116 catch (
const std::out_of_range& )
118 G4cerr << __METHOD_NAME__ <<
"unknown component named: \"" << name <<
"\"" << G4endl;
130 tunnelComponents.insert(component);
135 std::map<G4String, BDSAcceleratorComponent*> result;
144 std::ios_base::fmtflags ff = out.flags();
145 out <<
"Accelerator Component Registry:" << G4endl;
147 {out << std::left << std::setw(15) << it.second->GetType() <<
" \"" << it.first <<
"\"" << G4endl;}
154 G4cout << __METHOD_NAME__ << G4endl;
156 {G4cout << std::setw(20) << kv.first <<
" : " << kv.second << G4endl;}
A registry of constructed BDSAcceleratorComponent instances that can be searched.
void RegisterCurvilinearComponent(BDSAcceleratorComponent *component)
static BDSAcceleratorComponentRegistry * Instance()
Singleton accessor.
std::map< G4String, BDSAcceleratorComponent * > AllComponentsIncludingUnique() const
void RegisterTunnelComponent(BDSAcceleratorComponent *component)
void RegisterComponent(BDSAcceleratorComponent *component, bool isModified=false)
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.
static BDSAcceleratorComponentRegistry * instance
The singleton instance.
G4bool IsRegisteredAllocated(const BDSAcceleratorComponent *componentName) const
Check if a unique component is registered in the allocatedComponents.
void PrintNumberOfEachType() const
Print out the number of each type of component registered.
BDSAcceleratorComponent * GetComponent(const G4String &name)
std::unordered_map< std::string, int > typeCounter
G4bool IsRegistered(BDSAcceleratorComponent *component)
Check whether an accelerator component is already registered.
BDSAcceleratorComponentRegistry()
Default constructor is private as singleton.
~BDSAcceleratorComponentRegistry()
RegistryMap registry
Registry is a map - note 'register' is a protected keyword.
RegistryMap registryForAllocated
A map for absolutely everything including components that are unique.
Abstract class that represents a component of an accelerator.
virtual G4String GetName() const
The name of the component without modification.
G4String GetType() const
Get a string describing the type of the component.
A class that hold multiple accelerator components.