Import Geant4 11.4.0 source tree
This commit is contained in:
@@ -40,10 +40,10 @@
|
||||
// If much additional functionality is added, should consider containment
|
||||
// instead of inheritance for std::vector<T>.
|
||||
|
||||
// 18.09.02, G.Cosmo - Initial version
|
||||
// Author: Gabriele Cosmo (CERN), 18.09.2002
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4REGIONSTORE_HH
|
||||
#define G4REGIONSTORE_HH 1
|
||||
#define G4REGIONSTORE_HH
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -55,68 +55,117 @@
|
||||
class G4Region;
|
||||
class G4VPhysicalVolume;
|
||||
|
||||
/**
|
||||
* @brief G4RegionStore is a singleton class, acting as container
|
||||
* for all geometrical regions, with functionality derived from std::vector<T>.
|
||||
* All regions should be registered with G4RegionStore, and removed on their
|
||||
* destruction. The underlying container initially has a capacity of 20.
|
||||
* A map indexed by volume names is also recorded for fast search; pointers
|
||||
* to regions with same name are stored in buckets.
|
||||
*/
|
||||
|
||||
class G4RegionStore : public std::vector<G4Region*>
|
||||
{
|
||||
public:
|
||||
|
||||
static void Register(G4Region* pRegion);
|
||||
// Add the region to the collection.
|
||||
static void DeRegister(G4Region* pRegion);
|
||||
// Remove the region from the collection.
|
||||
static G4RegionStore* GetInstance();
|
||||
// Get a ptr to the unique G4RegionStore, creating it if necessary.
|
||||
static void SetNotifier(G4VStoreNotifier* pNotifier);
|
||||
// Assign a notifier for allocation/deallocation of regions.
|
||||
static void Clean();
|
||||
// Delete all regions from the store except for the world region.
|
||||
|
||||
G4bool IsModified() const;
|
||||
// Loops through all regions to verify if a region has been
|
||||
// modified. It returns TRUE if just one region is modified.
|
||||
void ResetRegionModified();
|
||||
// Loops through all regions to reset flag for modification
|
||||
// to FALSE. Used by the run manager to notify that the
|
||||
// physics table has been updated.
|
||||
|
||||
void UpdateMaterialList(G4VPhysicalVolume* currentWorld=nullptr);
|
||||
// Forces recomputation of material lists in all regions
|
||||
// in the store.
|
||||
|
||||
G4Region* GetRegion(const G4String& name, G4bool verbose = true) const;
|
||||
// Returns a region through its name specification. Uses the internal
|
||||
// map for fast search and warns if a region in the collection is not
|
||||
// unique or not found.
|
||||
|
||||
inline G4bool IsMapValid() const { return mvalid; }
|
||||
inline void SetMapValid(G4bool val) { mvalid = val; }
|
||||
// Accessor to assess validity of the internal map.
|
||||
inline const std::map<G4String,
|
||||
std::vector<G4Region*> >& GetMap() const { return bmap; }
|
||||
// Return the internal map.
|
||||
void UpdateMap();
|
||||
// Bring contents of internal map up to date and resets validity flag.
|
||||
|
||||
G4Region* FindOrCreateRegion(const G4String& name);
|
||||
// Returns a region through its name specification, if it exists.
|
||||
// If it does not exist it will allocate one delegating ownership
|
||||
// to the client.
|
||||
|
||||
void SetWorldVolume();
|
||||
// Set a world volume pointer to a region that belongs to it.
|
||||
// Scan over all world volumes.
|
||||
// This method should be exclusively used by G4RunManagerKernel.
|
||||
|
||||
/**
|
||||
* Destructor: takes care to delete allocated regions.
|
||||
*/
|
||||
virtual ~G4RegionStore();
|
||||
// Destructor: takes care to delete allocated regions.
|
||||
|
||||
/**
|
||||
* Copy constructor and assignment operator not allowed.
|
||||
*/
|
||||
G4RegionStore(const G4RegionStore&) = delete;
|
||||
G4RegionStore& operator=(const G4RegionStore&) = delete;
|
||||
// Forbidden copy constructor and assignment operator
|
||||
|
||||
/**
|
||||
* Adds the region 'pRegion' to the collection.
|
||||
*/
|
||||
static void Register(G4Region* pRegion);
|
||||
|
||||
/**
|
||||
* Removes the region 'pRegion' from the collection.
|
||||
*/
|
||||
static void DeRegister(G4Region* pRegion);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the unique instance of G4RegionStore,
|
||||
* creating it if necessary.
|
||||
*/
|
||||
static G4RegionStore* GetInstance();
|
||||
|
||||
/**
|
||||
* Assigns a notifier for allocation/deallocation of regions.
|
||||
*/
|
||||
static void SetNotifier(G4VStoreNotifier* pNotifier);
|
||||
|
||||
/**
|
||||
* Deletes all regions from the store, except for the world region.
|
||||
*/
|
||||
static void Clean();
|
||||
|
||||
/**
|
||||
* Loops through all regions to verify if a region has been modified.
|
||||
* @returns true if just one region is modified.
|
||||
*/
|
||||
G4bool IsModified() const;
|
||||
|
||||
/**
|
||||
* Loops through all regions to reset the flag for modification to false.
|
||||
* Used by the run manager to notify that the physics table has been updated.
|
||||
*/
|
||||
void ResetRegionModified();
|
||||
|
||||
/**
|
||||
* Forces recomputation of the material lists in all regions in the store.
|
||||
*/
|
||||
void UpdateMaterialList(G4VPhysicalVolume* currentWorld = nullptr);
|
||||
|
||||
/**
|
||||
* Returns a pointer to a region through its name specification.
|
||||
* It uses the internal map for fast search and warns if a region in the
|
||||
* collection is not unique or not found.
|
||||
*/
|
||||
G4Region* GetRegion(const G4String& name, G4bool verbose = true) const;
|
||||
|
||||
/**
|
||||
* Accessor and modifier to assess validity of the internal map.
|
||||
*/
|
||||
inline G4bool IsMapValid() const { return mvalid; }
|
||||
inline void SetMapValid(G4bool val) { mvalid = val; }
|
||||
|
||||
/**
|
||||
* Returns the internal map.
|
||||
*/
|
||||
inline const std::map<G4String,
|
||||
std::vector<G4Region*> >& GetMap() const { return bmap; }
|
||||
|
||||
/**
|
||||
* Brings contents of the internal map up to date and resets validity flag.
|
||||
*/
|
||||
void UpdateMap();
|
||||
|
||||
/**
|
||||
* Returns a pointer to a region through its name specification, if it
|
||||
* exists. If it does not exist, it will allocate one, delegating ownership
|
||||
* to the client.
|
||||
*/
|
||||
G4Region* FindOrCreateRegion(const G4String& name);
|
||||
|
||||
/**
|
||||
* Sets a world volume pointer to a region that belongs to it.
|
||||
* Scans over all world volumes. This method should be exclusively
|
||||
* used by G4RunManagerKernel.
|
||||
*/
|
||||
void SetWorldVolume();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Protected singleton constructor.
|
||||
*/
|
||||
G4RegionStore();
|
||||
// Protected singleton constructor.
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user