Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4RegionStore 27 // 28 // Class description: 29 // 30 // Container for all regions, with functionali 31 // std::vector<T>. The class is a 'singleton', 32 // one can exist, and access is provided via t 33 // G4RegionStore::GetInstance(). 34 // 35 // All regions should be registered with G4Reg 36 // destruction. The underlying container initi 37 // A map indexed by volume names is also recor 38 // pointers to regions with same name are stor 39 // 40 // If much additional functionality is added, 41 // instead of inheritance for std::vector<T>. 42 43 // 18.09.02, G.Cosmo - Initial version 44 // ------------------------------------------- 45 #ifndef G4REGIONSTORE_HH 46 #define G4REGIONSTORE_HH 1 47 48 #include <vector> 49 #include <map> 50 51 #include "G4Types.hh" 52 #include "G4String.hh" 53 #include "G4VStoreNotifier.hh" 54 55 class G4Region; 56 class G4VPhysicalVolume; 57 58 class G4RegionStore : public std::vector<G4Reg 59 { 60 public: 61 62 static void Register(G4Region* pRegion); 63 // Add the region to the collection. 64 static void DeRegister(G4Region* pRegion); 65 // Remove the region from the collection 66 static G4RegionStore* GetInstance(); 67 // Get a ptr to the unique G4RegionStore 68 static void SetNotifier(G4VStoreNotifier* 69 // Assign a notifier for allocation/deal 70 static void Clean(); 71 // Delete all regions from the store exc 72 73 G4bool IsModified() const; 74 // Loops through all regions to verify i 75 // modified. It returns TRUE if just one 76 void ResetRegionModified(); 77 // Loops through all regions to reset fl 78 // to FALSE. Used by the run manager to 79 // physics table has been updated. 80 81 void UpdateMaterialList(G4VPhysicalVolume* 82 // Forces recomputation of material list 83 // in the store. 84 85 G4Region* GetRegion(const G4String& name, 86 // Returns a region through its name spe 87 // map for fast search and warns if a re 88 // unique or not found. 89 90 inline G4bool IsMapValid() const { return 91 inline void SetMapValid(G4bool val) { mva 92 // Accessor to assess validity of the in 93 inline const std::map<G4String, 94 std::vector<G4Region*> >& GetMap() 95 // Return the internal map. 96 void UpdateMap(); 97 // Bring contents of internal map up to 98 99 G4Region* FindOrCreateRegion(const G4Strin 100 // Returns a region through its name spe 101 // If it does not exist it will allocate 102 // to the client. 103 104 void SetWorldVolume(); 105 // Set a world volume pointer to a regio 106 // Scan over all world volumes. 107 // This method should be exclusively use 108 109 virtual ~G4RegionStore(); 110 // Destructor: takes care to delete allo 111 112 G4RegionStore(const G4RegionStore&) = dele 113 G4RegionStore& operator=(const G4RegionSto 114 // Forbidden copy constructor and assign 115 116 protected: 117 118 G4RegionStore(); 119 // Protected singleton constructor. 120 121 private: 122 123 static G4RegionStore* fgInstance; 124 static G4ThreadLocal G4VStoreNotifier* fgN 125 static G4ThreadLocal G4bool locked; 126 127 std::map<G4String, std::vector<G4Region*> 128 G4bool mvalid = false; // Flag to indicat 129 }; 130 131 #endif 132