Geant4 10.7.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 ()
 
 G4PhysicalVolumeStore (const G4PhysicalVolumeStore &)=delete
 
G4PhysicalVolumeStoreoperator= (const G4PhysicalVolumeStore &)=delete
 

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 57 of file G4PhysicalVolumeStore.hh.

Constructor & Destructor Documentation

◆ ~G4PhysicalVolumeStore()

G4PhysicalVolumeStore::~G4PhysicalVolumeStore ( )
virtual

Definition at line 59 of file G4PhysicalVolumeStore.cc.

60{
61 Clean(); // Delete all volumes in the store
62 G4VPhysicalVolume::Clean(); // Delete allocated sub-instance data
63}

◆ G4PhysicalVolumeStore() [1/2]

G4PhysicalVolumeStore::G4PhysicalVolumeStore ( const G4PhysicalVolumeStore )
delete

◆ G4PhysicalVolumeStore() [2/2]

G4PhysicalVolumeStore::G4PhysicalVolumeStore ( )
protected

Definition at line 49 of file G4PhysicalVolumeStore.cc.

50 : std::vector<G4VPhysicalVolume*>()
51{
52 reserve(100);
53}

Member Function Documentation

◆ Clean()

void G4PhysicalVolumeStore::Clean ( )
static

Definition at line 69 of file G4PhysicalVolumeStore.cc.

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

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

◆ DeRegister()

void G4PhysicalVolumeStore::DeRegister ( G4VPhysicalVolume pSolid)
static

Definition at line 135 of file G4PhysicalVolumeStore.cc.

136{
137 if (!locked) // Do not de-register if locked !
138 {
139 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
140 G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
141 if (motherLogical != nullptr) { motherLogical->RemoveDaughter(pVolume); }
142 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
143 {
144 if (**i==*pVolume)
145 {
146 GetInstance()->erase(i);
147 break;
148 }
149 }
150 }
151}
void RemoveDaughter(const G4VPhysicalVolume *p)

Referenced by G4VPhysicalVolume::~G4VPhysicalVolume().

◆ GetInstance()

◆ GetVolume()

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

Definition at line 158 of file G4PhysicalVolumeStore.cc.

159{
160 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
161 {
162 if ((*i)->GetName() == name) { return *i; }
163 }
164 if (verbose)
165 {
166 std::ostringstream message;
167 message << "Volume NOT found in store !" << G4endl
168 << " Volume " << name << " NOT found in store !" << G4endl
169 << " Returning NULL pointer.";
170 G4Exception("G4PhysicalVolumeStore::GetVolume()",
171 "GeomMgt1001", JustWarning, message);
172 }
173 return nullptr;
174}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
const char * name(G4int ptype)

Referenced by G4GDMLReadStructure::GetPhysvol().

◆ operator=()

G4PhysicalVolumeStore & G4PhysicalVolumeStore::operator= ( const G4PhysicalVolumeStore )
delete

◆ Register()

void G4PhysicalVolumeStore::Register ( G4VPhysicalVolume pSolid)
static

Definition at line 124 of file G4PhysicalVolumeStore.cc.

125{
126 GetInstance()->push_back(pVolume);
127 if (fgNotifier) { fgNotifier->NotifyRegistration(); }
128}
virtual void NotifyRegistration()=0

Referenced by G4VPhysicalVolume::G4VPhysicalVolume().

◆ SetNotifier()

void G4PhysicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 114 of file G4PhysicalVolumeStore.cc.

115{
116 GetInstance();
117 fgNotifier = pNotifier;
118}

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