82 G4cout <<
"WARNING - Attempt to delete the physical volume store"
83 <<
" while geometry closed !" <<
G4endl;
95 for(
const auto & pos : *store)
97 if (fgNotifier !=
nullptr) { fgNotifier->NotifyDeRegistration(); }
101 store->bmap.clear(); store->mvalid =
false;
113 fgNotifier = pNotifier;
123 if (mvalid) {
return; }
127 const G4String& vol_name = pos->GetName();
128 auto it = bmap.find(vol_name);
129 if (it != bmap.cend())
131 it->second.push_back(pos);
135 std::vector<G4VPhysicalVolume*> vol_vec { pos };
136 bmap.insert(std::make_pair(vol_name, vol_vec));
150 store->push_back(pVolume);
152 auto it = store->bmap.find(vol_name);
153 if (it != store->bmap.cend())
155 it->second.push_back(pVolume);
159 std::vector<G4VPhysicalVolume*> vol_vec { pVolume };
160 store->bmap.insert(std::make_pair(vol_name, vol_vec));
162 if (fgNotifier !=
nullptr) { fgNotifier->NotifyRegistration(); }
163 store->mvalid =
true;
176 if (fgNotifier !=
nullptr) { fgNotifier->NotifyDeRegistration(); }
178 if (motherLogical !=
nullptr) { motherLogical->
RemoveDaughter(pVolume); }
179 for (
auto i=store->cbegin(); i!=store->cend(); ++i)
188 auto it = store->bmap.find(vol_name);
189 if (it != store->bmap.cend())
191 if (it->second.size() > 1)
193 for (
auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
204 store->bmap.erase(it);
216 G4bool reverseSearch)
const
219 if (!store->mvalid) { store->
UpdateMap(); }
220 auto pos = store->bmap.find(name);
221 if(pos != store->bmap.cend())
223 if ((verbose) && (pos->second.size()>1))
225 std::ostringstream message;
226 message <<
"There exists more than ONE physical volume in store named: "
228 <<
"Returning the first found.";
234 return pos->second[pos->second.size()-1];
236 return pos->second[0];
240 std::ostringstream message;
241 message <<
"Volume NOT found in store !" <<
G4endl
242 <<
" Volume " << name <<
" NOT found in store !" <<
G4endl
243 <<
" Returning NULL pointer.";
257 if (fgInstance ==
nullptr)
259 fgInstance = &worldStore;
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define G4MUTEX_INITIALIZER
G4VNotifier G4VStoreNotifier
G4VStoreNotifier is a simple abstract class allowing for the implementation of user notifiers to be a...
G4GLOB_DLL std::ostream G4cout
static G4GeometryManager * GetInstance()
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
void RemoveDaughter(const G4VPhysicalVolume *p)
G4PhysicalVolumeStore is a singleton class, acting as container for all physical volumes,...
static G4PhysicalVolumeStore * GetInstance()
static void Register(G4VPhysicalVolume *pVolume)
static void DeRegister(G4VPhysicalVolume *pVolume)
static void SetNotifier(G4VStoreNotifier *pNotifier)
virtual ~G4PhysicalVolumeStore()
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
G4PhysicalVolumeStore(const G4PhysicalVolumeStore &)=delete
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4LogicalVolume * GetMotherLogical() const
const G4String & GetName() const