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
G4LogicalVolumeStore Class Reference

#include <G4LogicalVolumeStore.hh>

Inheritance diagram for G4LogicalVolumeStore:

Public Member Functions

G4LogicalVolumeGetVolume (const G4String &name, G4bool verbose=true) const
 
virtual ~G4LogicalVolumeStore ()
 

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

Constructor & Destructor Documentation

G4LogicalVolumeStore::~G4LogicalVolumeStore ( )
virtual

Definition at line 64 of file G4LogicalVolumeStore.cc.

References Clean().

65 {
66  Clean();
67 }
G4LogicalVolumeStore::G4LogicalVolumeStore ( )
protected

Definition at line 54 of file G4LogicalVolumeStore.cc.

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

Member Function Documentation

void G4LogicalVolumeStore::Clean ( )
static

Definition at line 73 of file G4LogicalVolumeStore.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 ~G4LogicalVolumeStore().

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

Definition at line 138 of file G4LogicalVolumeStore.cc.

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

Referenced by G4LogicalVolume::~G4LogicalVolume().

139 {
140  if (!locked) // Do not de-register if locked !
141  {
142  if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
143  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
144  {
145  if (**i==*pVolume)
146  {
147  GetInstance()->erase(i);
148  break;
149  }
150  }
151  }
152 }
virtual void NotifyDeRegistration()=0
static G4LogicalVolumeStore * GetInstance()
G4LogicalVolumeStore * G4LogicalVolumeStore::GetInstance ( void  )
static
G4LogicalVolume * G4LogicalVolumeStore::GetVolume ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 159 of file G4LogicalVolumeStore.cc.

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

Referenced by GB02DetectorConstruction::ConstructSDandField(), B4PrimaryGeneratorAction::GeneratePrimaries(), B2PrimaryGeneratorAction::GeneratePrimaries(), B1PrimaryGeneratorAction::GeneratePrimaries(), G4GDMLReadStructure::GetVolume(), G4GDMLMessenger::SetNewValue(), and F04SteppingAction::UserSteppingAction().

160 {
161  for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
162  {
163  if ((*i)->GetName() == name) { return *i; }
164  }
165  if (verbose)
166  {
167  std::ostringstream message;
168  message << "Volume NOT found in store !" << G4endl
169  << " Volume " << name << " NOT found in store !" << G4endl
170  << " Returning NULL pointer.";
171  G4Exception("G4LogicalVolumeStore::GetVolume()",
172  "GeomMgt1001", JustWarning, message);
173  }
174  return 0;
175 }
const XML_Char * name
static G4LogicalVolumeStore * 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 G4LogicalVolumeStore::Register ( G4LogicalVolume pVolume)
static

Definition at line 128 of file G4LogicalVolumeStore.cc.

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

Referenced by G4LogicalVolume::G4LogicalVolume().

129 {
130  GetInstance()->push_back(pVolume);
131  if (fgNotifier) { fgNotifier->NotifyRegistration(); }
132 }
static G4LogicalVolumeStore * GetInstance()
virtual void NotifyRegistration()=0
void G4LogicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 118 of file G4LogicalVolumeStore.cc.

References GetInstance().

119 {
120  GetInstance();
121  fgNotifier = pNotifier;
122 }
static G4LogicalVolumeStore * GetInstance()

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