Geant4 10.7.0
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
88 size_t i=0;
90
91#ifdef G4DEBUG_NAVIGATION
92 G4cout << "Deleting Assemblies ... ";
93#endif
94
95 for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
96 {
97 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
98 if (*pos) { delete *pos; }
99 ++i;
100 }
101
102#ifdef G4DEBUG_NAVIGATION
103 if (store->size() < i-1)
104 { G4cout << "No assembly deleted. Already deleted by user ?" << G4endl; }
105 else
106 { G4cout << i-1 << " assemblies deleted !" << G4endl; }
107#endif
108
109 locked = false;
110 store->clear();
111}
#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 137 of file G4AssemblyStore.cc.

138{
139 if (!locked) // Do not de-register if locked !
140 {
141 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
142 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
143 {
144 if (*i==pAssembly)
145 {
146 GetInstance()->erase(i);
147 break;
148 }
149 }
150 }
151}

Referenced by G4AssemblyVolume::~G4AssemblyVolume().

◆ GetAssembly()

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

Definition at line 172 of file G4AssemblyStore.cc.

173{
174 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
175 {
176 if ((*i)->GetAssemblyID() == id) { return *i; }
177 }
178 if (verbose)
179 {
180 std::ostringstream message;
181 message << "Assembly NOT found in store !" << G4endl
182 << " Assembly " << id << " NOT found in store !" << G4endl
183 << " Returning NULL pointer.";
184 G4Exception("G4AssemblyStore::GetAssembly()",
185 "GeomVol1001", JustWarning, message);
186 }
187 return 0;
188}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35

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

◆ GetInstance()

G4AssemblyStore * G4AssemblyStore::GetInstance ( )
static

◆ Register()

void G4AssemblyStore::Register ( G4AssemblyVolume pAssembly)
static

Definition at line 127 of file G4AssemblyStore.cc.

128{
129 GetInstance()->push_back(pAssembly);
130 if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
131}
virtual void NotifyRegistration()=0

Referenced by G4AssemblyVolume::G4AssemblyVolume().

◆ SetNotifier()

void G4AssemblyStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 117 of file G4AssemblyStore.cc.

118{
119 GetInstance();
120 fgNotifier = pNotifier;
121}

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