Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AssemblyStore Class Reference

#include <G4AssemblyStore.hh>

+ Inheritance diagram for G4AssemblyStore:

Public Member Functions

G4AssemblyVolumeGetAssembly (unsigned int id, G4bool verbose=true) const
 

Static Public Member Functions

static void Register (G4AssemblyVolume *pAssembly)
 
static void DeRegister (G4AssemblyVolume *pAssembly)
 
static G4AssemblyStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4AssemblyStore ()
 
virtual ~G4AssemblyStore ()
 

Detailed Description

Definition at line 59 of file G4AssemblyStore.hh.

Constructor & Destructor Documentation

◆ G4AssemblyStore()

G4AssemblyStore::G4AssemblyStore ( )
protected

Definition at line 53 of file G4AssemblyStore.cc.

54 : std::vector<G4AssemblyVolume*>()
55{
56 reserve(20);
57}

◆ ~G4AssemblyStore()

G4AssemblyStore::~G4AssemblyStore ( )
protectedvirtual

Definition at line 63 of file G4AssemblyStore.cc.

64{
65 Clean(); // Delete all assemblies in the store
66}
static void Clean()

Member Function Documentation

◆ Clean()

void G4AssemblyStore::Clean ( )
static

Definition at line 72 of file G4AssemblyStore.cc.

73{
74 // Do nothing if geometry is closed
75 //
77 {
78 G4cout << "WARNING - Attempt to delete the assembly store"
79 << " while geometry closed !" << G4endl;
80 return;
81 }
82
83 // Locks store for deletion of assemblies. De-registration will be
84 // performed at this stage. Assemblies will not de-register themselves.
85 //
86 locked = true;
87
89
90 for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
91 {
92 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
93 if (*pos) { delete *pos; }
94 }
95
96 locked = false;
97 store->clear();
98}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4AssemblyStore * GetInstance()
static G4bool IsGeometryClosed()
virtual void NotifyDeRegistration()=0

Referenced by G4RunManager::ReinitializeGeometry(), and ~G4AssemblyStore().

◆ DeRegister()

void G4AssemblyStore::DeRegister ( G4AssemblyVolume pAssembly)
static

Definition at line 124 of file G4AssemblyStore.cc.

125{
126 if (!locked) // Do not de-register if locked !
127 {
128 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
129 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
130 {
131 if (*i==pAssembly)
132 {
133 GetInstance()->erase(i);
134 break;
135 }
136 }
137 }
138}

Referenced by G4AssemblyVolume::~G4AssemblyVolume().

◆ GetAssembly()

G4AssemblyVolume * G4AssemblyStore::GetAssembly ( unsigned int  id,
G4bool  verbose = true 
) const

Definition at line 159 of file G4AssemblyStore.cc.

160{
161 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
162 {
163 if ((*i)->GetAssemblyID() == id) { return *i; }
164 }
165 if (verbose)
166 {
167 std::ostringstream message;
168 message << "Assembly NOT found in store !" << G4endl
169 << " Assembly " << id << " NOT found in store !" << G4endl
170 << " Returning NULL pointer.";
171 G4Exception("G4AssemblyStore::GetAssembly()",
172 "GeomVol1001", JustWarning, message);
173 }
174 return 0;
175}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59

Referenced by G4GDMLWriteStructure::AssemblyWrite(), G4AssemblyVolume::G4AssemblyVolume(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ GetInstance()

G4AssemblyStore * G4AssemblyStore::GetInstance ( )
static

◆ Register()

void G4AssemblyStore::Register ( G4AssemblyVolume pAssembly)
static

Definition at line 114 of file G4AssemblyStore.cc.

115{
116 GetInstance()->push_back(pAssembly);
117 if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
118}
virtual void NotifyRegistration()=0

Referenced by G4AssemblyVolume::G4AssemblyVolume().

◆ SetNotifier()

void G4AssemblyStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 104 of file G4AssemblyStore.cc.

105{
106 GetInstance();
107 fgNotifier = pNotifier;
108}

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