Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions
G4SolidStore Class Reference

#include <G4SolidStore.hh>

Inheritance diagram for G4SolidStore:

Public Member Functions

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

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 62 of file G4SolidStore.hh.

Constructor & Destructor Documentation

G4SolidStore::~G4SolidStore ( )
virtual

Definition at line 64 of file G4SolidStore.cc.

References Clean().

65 {
66  // In multi-threaded mode, since parameterised solids are replicated
67  // by threads, the master thread can not free them when thread private
68  // malloc library is used. May let the master thread to replicate.
69 
70 #ifndef G4MULTITHREADED
71  Clean();
72 #endif
73 }
static void Clean()
Definition: G4SolidStore.cc:79
G4SolidStore::G4SolidStore ( )
protected

Definition at line 54 of file G4SolidStore.cc.

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

Member Function Documentation

void G4SolidStore::Clean ( )
static

Definition at line 79 of file G4SolidStore.cc.

References G4cout, G4endl, GetInstance(), G4GeometryManager::GetInstance(), and G4VNotifier::NotifyDeRegistration().

Referenced by LXeDetectorConstruction::Construct(), F04DetectorConstruction::Construct(), WLSDetectorConstruction::Construct(), ElectronBenchmarkDetector::CreateGeometry(), G4RunManager::ReinitializeGeometry(), G4GDMLMessenger::SetNewValue(), and ~G4SolidStore().

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

Definition at line 144 of file G4SolidStore.cc.

References GetInstance(), and G4VNotifier::NotifyDeRegistration().

Referenced by G4SurfaceVoxelizer::G4SurfaceVoxelizer(), UVoxelizer::UVoxelizer(), and G4VSolid::~G4VSolid().

145 {
146  if (!locked) // Do not de-register if locked !
147  {
148  if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
149  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
150  {
151  if (**i==*pSolid)
152  {
153  GetInstance()->erase(i);
154  break;
155  }
156  }
157  }
158 }
virtual void NotifyDeRegistration()=0
static G4SolidStore * GetInstance()
G4SolidStore * G4SolidStore::GetInstance ( void  )
static
G4VSolid * G4SolidStore::GetSolid ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 164 of file G4SolidStore.cc.

References G4endl, G4Exception(), GetInstance(), and JustWarning.

Referenced by G4GDMLReadSolids::GetSolid().

165 {
166  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
167  {
168  if ((*i)->GetName() == name) { return *i; }
169  }
170  if (verbose)
171  {
172  std::ostringstream message;
173  message << "Solid " << name << " not found in store !" << G4endl
174  << "Returning NULL pointer.";
175  G4Exception("G4SolidStore::GetSolid()",
176  "GeomMgt1001", JustWarning, message);
177  }
178  return 0;
179 }
const XML_Char * name
static G4SolidStore * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void G4SolidStore::Register ( G4VSolid pSolid)
static

Definition at line 134 of file G4SolidStore.cc.

References GetInstance(), and G4VNotifier::NotifyRegistration().

Referenced by G4VSolid::G4VSolid().

135 {
136  GetInstance()->push_back(pSolid);
137  if (fgNotifier) { fgNotifier->NotifyRegistration(); }
138 }
static G4SolidStore * GetInstance()
virtual void NotifyRegistration()=0
void G4SolidStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 124 of file G4SolidStore.cc.

References GetInstance().

125 {
126  GetInstance();
127  fgNotifier = pNotifier;
128 }
static G4SolidStore * GetInstance()

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