Geant4 11.2.2
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 53 of file G4AssemblyStore.hh.

Constructor & Destructor Documentation

◆ G4AssemblyStore()

G4AssemblyStore::G4AssemblyStore ( )
protected

Definition at line 51 of file G4AssemblyStore.cc.

52{
53 reserve(20);
54}

◆ ~G4AssemblyStore()

G4AssemblyStore::~G4AssemblyStore ( )
protectedvirtual

Definition at line 60 of file G4AssemblyStore.cc.

61{
62 Clean(); // Delete all assemblies in the store
63}
static void Clean()

Member Function Documentation

◆ Clean()

void G4AssemblyStore::Clean ( )
static

Definition at line 69 of file G4AssemblyStore.cc.

70{
71 // Do nothing if geometry is closed
72 //
74 {
75 G4cout << "WARNING - Attempt to delete the assembly store"
76 << " while geometry closed !" << G4endl;
77 return;
78 }
79
80 // Locks store for deletion of assemblies. De-registration will be
81 // performed at this stage. Assemblies will not de-register themselves.
82 //
83 locked = true;
84
86
87 for(const auto & pos : *store)
88 {
89 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
90 if (pos != nullptr) { delete pos; }
91 }
92
93 locked = false;
94 store->clear();
95}
#define G4endl
Definition G4ios.hh:67
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 121 of file G4AssemblyStore.cc.

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

Referenced by G4AssemblyVolume::~G4AssemblyVolume().

◆ GetAssembly()

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

Definition at line 156 of file G4AssemblyStore.cc.

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

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

◆ GetInstance()

G4AssemblyStore * G4AssemblyStore::GetInstance ( )
static

◆ Register()

void G4AssemblyStore::Register ( G4AssemblyVolume * pAssembly)
static

Definition at line 111 of file G4AssemblyStore.cc.

112{
113 GetInstance()->push_back(pAssembly);
114 if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
115}
virtual void NotifyRegistration()=0

Referenced by G4AssemblyVolume::G4AssemblyVolume(), and G4AssemblyVolume::G4AssemblyVolume().

◆ SetNotifier()

void G4AssemblyStore::SetNotifier ( G4VStoreNotifier * pNotifier)
static

Definition at line 101 of file G4AssemblyStore.cc.

102{
103 GetInstance();
104 fgNotifier = pNotifier;
105}

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