Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RegionStore.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4RegionStore
27//
28// Class description:
29//
30// Container for all regions, with functionality derived from
31// std::vector<T>. The class is a 'singleton', in that only
32// one can exist, and access is provided via the static method
33// G4RegionStore::GetInstance().
34//
35// All regions should be registered with G4RegionStore, and removed on their
36// destruction. The underlying container initially has a capacity of 20.
37//
38// If much additional functionality is added, should consider containment
39// instead of inheritance for std::vector<T>
40//
41// Member data:
42//
43// static G4RegionStore*
44// - Pointer to the single G4RegionStore
45
46// 18.09.02, G.Cosmo - Initial version
47// --------------------------------------------------------------------
48#ifndef G4REGIONSTORE_HH
49#define G4REGIONSTORE_HH
50
51#include <vector>
52#include "G4Types.hh"
53#include "G4String.hh"
54#include "G4VStoreNotifier.hh"
55
56class G4Region;
58
59class G4RegionStore : public std::vector<G4Region*>
60{
61 public:
62
63 static void Register(G4Region* pRegion);
64 // Add the region to the collection.
65 static void DeRegister(G4Region* pRegion);
66 // Remove the region from the collection.
67 static G4RegionStore* GetInstance();
68 // Get a ptr to the unique G4RegionStore, creating it if necessary.
69 static void SetNotifier(G4VStoreNotifier* pNotifier);
70 // Assign a notifier for allocation/deallocation of regions.
71 static void Clean();
72 // Delete all regions from the store except for the world region.
73
74 G4bool IsModified() const;
75 // Loops through all regions to verify if a region has been
76 // modified. It returns TRUE if just one region is modified.
78 // Loops through all regions to reset flag for modification
79 // to FALSE. Used by the run manager to notify that the
80 // physics table has been updated.
81
82 void UpdateMaterialList(G4VPhysicalVolume* currentWorld=0);
83 // Forces recomputation of material lists in all regions
84 // in the store.
85
86 G4Region* GetRegion(const G4String& name, G4bool verbose = true) const;
87 // Returns a region through its name specification.
88
90 // Returns a region through its name specification, if it exists.
91 // If it does not exist it will allocate one delegating ownership
92 // to the client.
93
94 void SetWorldVolume();
95 // Set a world volume pointer to a region that belongs to it.
96 // Scan over all world volumes.
97 // This method should be exclusively used by G4RunManagerKernel.
98
99 virtual ~G4RegionStore();
100 // Destructor: takes care to delete allocated regions.
101
102 G4RegionStore(const G4RegionStore&) = delete;
104 // Forbidden copy constructor and assignment operator
105
106 protected:
107
109 // Protected singleton constructor.
110
111 private:
112
113 static G4RegionStore* fgInstance;
114 static G4ThreadLocal G4VStoreNotifier* fgNotifier;
115 static G4ThreadLocal G4bool locked;
116};
117
118#endif
bool G4bool
Definition: G4Types.hh:86
static void DeRegister(G4Region *pRegion)
static void Register(G4Region *pRegion)
static G4RegionStore * GetInstance()
static void SetNotifier(G4VStoreNotifier *pNotifier)
virtual ~G4RegionStore()
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=0)
static void Clean()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4Region * FindOrCreateRegion(const G4String &name)
void ResetRegionModified()
G4RegionStore & operator=(const G4RegionStore &)=delete
G4RegionStore(const G4RegionStore &)=delete
G4bool IsModified() const
void SetWorldVolume()
#define G4ThreadLocal
Definition: tls.hh:77