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

#include <G4PhysicalVolumeStore.hh>

+ Inheritance diagram for G4PhysicalVolumeStore:

Public Member Functions

G4VPhysicalVolumeGetVolume (const G4String &name, G4bool verbose=true) const
 
virtual ~G4PhysicalVolumeStore ()
 

Static Public Member Functions

static void Register (G4VPhysicalVolume *pSolid)
 
static void DeRegister (G4VPhysicalVolume *pSolid)
 
static G4PhysicalVolumeStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4PhysicalVolumeStore ()
 

Detailed Description

Definition at line 62 of file G4PhysicalVolumeStore.hh.

Constructor & Destructor Documentation

◆ ~G4PhysicalVolumeStore()

G4PhysicalVolumeStore::~G4PhysicalVolumeStore ( )
virtual

Definition at line 65 of file G4PhysicalVolumeStore.cc.

66{
67 Clean();
68}

◆ G4PhysicalVolumeStore()

G4PhysicalVolumeStore::G4PhysicalVolumeStore ( )
protected

Definition at line 55 of file G4PhysicalVolumeStore.cc.

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

Member Function Documentation

◆ Clean()

void G4PhysicalVolumeStore::Clean ( )
static

Definition at line 74 of file G4PhysicalVolumeStore.cc.

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

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

◆ DeRegister()

void G4PhysicalVolumeStore::DeRegister ( G4VPhysicalVolume pSolid)
static

Definition at line 142 of file G4PhysicalVolumeStore.cc.

143{
144 if (!locked) // Do not de-register if locked !
145 {
146 if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
147 G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
148 if (motherLogical) { motherLogical->RemoveDaughter(pVolume); }
149 for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
150 {
151 if (**i==*pVolume)
152 {
153 GetInstance()->erase(i);
154 break;
155 }
156 }
157 }
158}
void RemoveDaughter(const G4VPhysicalVolume *p)

Referenced by G4VPhysicalVolume::~G4VPhysicalVolume().

◆ GetInstance()

◆ GetVolume()

G4VPhysicalVolume * G4PhysicalVolumeStore::GetVolume ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 165 of file G4PhysicalVolumeStore.cc.

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

Referenced by G4GDMLReadStructure::GetPhysvol().

◆ Register()

void G4PhysicalVolumeStore::Register ( G4VPhysicalVolume pSolid)
static

Definition at line 131 of file G4PhysicalVolumeStore.cc.

132{
133 GetInstance()->push_back(pVolume);
134 if (fgNotifier) { fgNotifier->NotifyRegistration(); }
135}
virtual void NotifyRegistration()=0

Referenced by G4VPhysicalVolume::G4VPhysicalVolume().

◆ SetNotifier()

void G4PhysicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 121 of file G4PhysicalVolumeStore.cc.

122{
123 GetInstance();
124 fgNotifier = pNotifier;
125}

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