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

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 58 of file G4LogicalVolumeStore.hh.

Constructor & Destructor Documentation

◆ ~G4LogicalVolumeStore()

G4LogicalVolumeStore::~G4LogicalVolumeStore ( )
virtual

Definition at line 58 of file G4LogicalVolumeStore.cc.

59{
60 Clean(); // Delete all volumes in the store
61 G4LogicalVolume::Clean(); // Delete allocated sub-instance data
62}
static void Clean()

◆ G4LogicalVolumeStore() [1/2]

G4LogicalVolumeStore::G4LogicalVolumeStore ( const G4LogicalVolumeStore )
delete

◆ G4LogicalVolumeStore() [2/2]

G4LogicalVolumeStore::G4LogicalVolumeStore ( )
protected

Definition at line 48 of file G4LogicalVolumeStore.cc.

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

Member Function Documentation

◆ Clean()

void G4LogicalVolumeStore::Clean ( )
static

Definition at line 68 of file G4LogicalVolumeStore.cc.

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

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

◆ DeRegister()

void G4LogicalVolumeStore::DeRegister ( G4LogicalVolume pVolume)
static

Definition at line 133 of file G4LogicalVolumeStore.cc.

134{
135 if (!locked) // Do not de-register if locked !
136 {
137 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
138 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
139 {
140 if (**i==*pVolume)
141 {
142 GetInstance()->erase(i);
143 break;
144 }
145 }
146 }
147}

Referenced by G4LogicalVolume::~G4LogicalVolume().

◆ GetInstance()

◆ GetVolume()

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

Definition at line 154 of file G4LogicalVolumeStore.cc.

155{
156 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
157 {
158 if ((*i)->GetName() == name) { return *i; }
159 }
160 if (verbose)
161 {
162 std::ostringstream message;
163 message << "Volume NOT found in store !" << G4endl
164 << " Volume " << name << " NOT found in store !" << G4endl
165 << " Returning NULL pointer.";
166 G4Exception("G4LogicalVolumeStore::GetVolume()",
167 "GeomMgt1001", JustWarning, message);
168 }
169 return 0;
170}
@ 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::GetVolume(), G4GDMLMessenger::SetNewValue(), and G4ScoringProbe::SetupGeometry().

◆ operator=()

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

◆ Register()

void G4LogicalVolumeStore::Register ( G4LogicalVolume pVolume)
static

Definition at line 123 of file G4LogicalVolumeStore.cc.

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

Referenced by G4LogicalVolume::G4LogicalVolume().

◆ SetNotifier()

void G4LogicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 113 of file G4LogicalVolumeStore.cc.

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

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