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

#include <G4SolidStore.hh>

+ Inheritance diagram for G4SolidStore:

Public Member Functions

G4VSolidGetSolid (const G4String &name, G4bool verbose=true) const
 
virtual ~G4SolidStore ()
 
 G4SolidStore (const G4SolidStore &)=delete
 
G4SolidStoreoperator= (const G4SolidStore &)=delete
 

Static Public Member Functions

static void Register (G4VSolid *pSolid)
 
static void DeRegister (G4VSolid *pSolid)
 
static G4SolidStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4SolidStore ()
 

Detailed Description

Definition at line 58 of file G4SolidStore.hh.

Constructor & Destructor Documentation

◆ ~G4SolidStore()

G4SolidStore::~G4SolidStore ( )
virtual

Definition at line 59 of file G4SolidStore.cc.

60{
61 Clean();
62}
static void Clean()
Definition: G4SolidStore.cc:68

◆ G4SolidStore() [1/2]

G4SolidStore::G4SolidStore ( const G4SolidStore )
delete

◆ G4SolidStore() [2/2]

G4SolidStore::G4SolidStore ( )
protected

Definition at line 49 of file G4SolidStore.cc.

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

Member Function Documentation

◆ Clean()

void G4SolidStore::Clean ( )
static

Definition at line 68 of file G4SolidStore.cc.

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

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

◆ DeRegister()

void G4SolidStore::DeRegister ( G4VSolid pSolid)
static

Definition at line 132 of file G4SolidStore.cc.

133{
134 if (!locked) // Do not de-register if locked !
135 {
136 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
137 for (auto i=GetInstance()->crbegin(); i!=GetInstance()->crend(); ++i)
138 {
139 if (**i==*pSolid)
140 {
141 GetInstance()->erase(std::next(i).base());
142 break;
143 }
144 }
145 }
146}

Referenced by G4Voxelizer::G4Voxelizer(), and G4VSolid::~G4VSolid().

◆ GetInstance()

G4SolidStore * G4SolidStore::GetInstance ( )
static

Definition at line 173 of file G4SolidStore.cc.

174{
175 static G4SolidStore worldStore;
176 if (fgInstance == nullptr)
177 {
178 fgInstance = &worldStore;
179 }
180 return fgInstance;
181}

Referenced by Clean(), DeRegister(), G4Voxelizer::G4Voxelizer(), G4VSolid::G4VSolid(), G4GDMLReadSolids::GetSolid(), GetSolid(), Register(), G4RunManager::ReinitializeGeometry(), SetNotifier(), G4GeometryManager::SetWorldMaximumExtent(), G4GDMLRead::StripNames(), and G4VSolid::~G4VSolid().

◆ GetSolid()

G4VSolid * G4SolidStore::GetSolid ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 152 of file G4SolidStore.cc.

153{
154 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
155 {
156 if ((*i)->GetName() == name) { return *i; }
157 }
158 if (verbose)
159 {
160 std::ostringstream message;
161 message << "Solid " << name << " not found in store !" << G4endl
162 << "Returning NULL pointer.";
163 G4Exception("G4SolidStore::GetSolid()",
164 "GeomMgt1001", JustWarning, message);
165 }
166 return nullptr;
167}
@ 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 G4GDMLReadSolids::GetSolid().

◆ operator=()

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

◆ Register()

void G4SolidStore::Register ( G4VSolid pSolid)
static

Definition at line 122 of file G4SolidStore.cc.

123{
124 GetInstance()->push_back(pSolid);
125 if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
126}
virtual void NotifyRegistration()=0

Referenced by G4VSolid::G4VSolid().

◆ SetNotifier()

void G4SolidStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 112 of file G4SolidStore.cc.

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

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