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

#include <G4LogicalVolumeStore.hh>

+ Inheritance diagram for G4LogicalVolumeStore:

Public Member Functions

G4LogicalVolumeGetVolume (const G4String &name, G4bool verbose=true) const
 
virtual ~G4LogicalVolumeStore ()
 

Static Public Member Functions

static void Register (G4LogicalVolume *pVolume)
 
static void DeRegister (G4LogicalVolume *pVolume)
 
static G4LogicalVolumeStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4LogicalVolumeStore ()
 

Detailed Description

Definition at line 62 of file G4LogicalVolumeStore.hh.

Constructor & Destructor Documentation

◆ ~G4LogicalVolumeStore()

G4LogicalVolumeStore::~G4LogicalVolumeStore ( )
virtual

Definition at line 64 of file G4LogicalVolumeStore.cc.

65{
66 Clean();
67}

◆ G4LogicalVolumeStore()

G4LogicalVolumeStore::G4LogicalVolumeStore ( )
protected

Definition at line 54 of file G4LogicalVolumeStore.cc.

55 : std::vector<G4LogicalVolume*>()
56{
57 reserve(100);
58}

Member Function Documentation

◆ Clean()

void G4LogicalVolumeStore::Clean ( )
static

Definition at line 73 of file G4LogicalVolumeStore.cc.

74{
75 // Do nothing if geometry is closed
76 //
77 if (G4GeometryManager::GetInstance()->IsGeometryClosed())
78 {
79 G4cout << "WARNING - Attempt to delete the logical volume store"
80 << " while geometry closed !" << G4endl;
81 return;
82 }
83
84 // Locks store for deletion of volumes. De-registration will be
85 // performed at this stage. G4LogicalVolumes will not de-register themselves.
86 //
87 locked = true;
88
89 size_t i=0;
91
92#ifdef G4GEOMETRY_VOXELDEBUG
93 G4cout << "Deleting Logical Volumes ... ";
94#endif
95
96 for(iterator pos=store->begin(); pos!=store->end(); pos++)
97 {
98 if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
99 if (*pos) { (*pos)->Lock(); delete *pos; }
100 i++;
101 }
102
103#ifdef G4GEOMETRY_VOXELDEBUG
104 if (store->size() < i-1)
105 { G4cout << "No volumes deleted. Already deleted by user ?" << G4endl; }
106 else
107 { G4cout << i-1 << " volumes deleted !" << G4endl; }
108#endif
109
110 locked = false;
111 store->clear();
112}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static G4GeometryManager * GetInstance()
static G4LogicalVolumeStore * GetInstance()
virtual void NotifyDeRegistration()=0

Referenced by G4GDMLMessenger::SetNewValue(), and ~G4LogicalVolumeStore().

◆ DeRegister()

void G4LogicalVolumeStore::DeRegister ( G4LogicalVolume pVolume)
static

Definition at line 138 of file G4LogicalVolumeStore.cc.

139{
140 if (!locked) // Do not de-register if locked !
141 {
142 if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
143 for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
144 {
145 if (**i==*pVolume)
146 {
147 GetInstance()->erase(i);
148 break;
149 }
150 }
151 }
152}

Referenced by G4LogicalVolume::~G4LogicalVolume().

◆ GetInstance()

◆ GetVolume()

G4LogicalVolume * G4LogicalVolumeStore::GetVolume ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 159 of file G4LogicalVolumeStore.cc.

160{
161 for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
162 {
163 if ((*i)->GetName() == name) { return *i; }
164 }
165 if (verbose)
166 {
167 std::ostringstream message;
168 message << "Volume NOT found in store !" << G4endl
169 << " Volume " << name << " NOT found in store !" << G4endl
170 << " Returning NULL pointer.";
171 G4Exception("G4LogicalVolumeStore::GetVolume()",
172 "GeomMgt1001", JustWarning, message);
173 }
174 return 0;
175}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4GDMLReadStructure::GetVolume(), and G4GDMLMessenger::SetNewValue().

◆ Register()

void G4LogicalVolumeStore::Register ( G4LogicalVolume pVolume)
static

Definition at line 128 of file G4LogicalVolumeStore.cc.

129{
130 GetInstance()->push_back(pVolume);
131 if (fgNotifier) { fgNotifier->NotifyRegistration(); }
132}
virtual void NotifyRegistration()=0

Referenced by G4LogicalVolume::G4LogicalVolume().

◆ SetNotifier()

void G4LogicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 118 of file G4LogicalVolumeStore.cc.

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

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