Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4RegionStore << 23 // >> 24 // $Id: G4RegionStore.hh,v 1.3 2003/02/07 11:32:20 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-01 $ >> 26 // >> 27 // class G4RegionStore 27 // 28 // 28 // Class description: 29 // Class description: 29 // 30 // 30 // Container for all regions, with functionali << 31 // Container for all regiong, with functionality derived from 31 // std::vector<T>. The class is a 'singleton', << 32 // std::vector<T>. The class is a `singleton', in that only 32 // one can exist, and access is provided via t 33 // one can exist, and access is provided via the static method 33 // G4RegionStore::GetInstance(). 34 // G4RegionStore::GetInstance(). 34 // 35 // 35 // All regions should be registered with G4Reg 36 // All regions should be registered with G4RegionStore, and removed on their 36 // destruction. The underlying container initi 37 // destruction. The underlying container initially has a capacity of 20. 37 // A map indexed by volume names is also recor << 38 // pointers to regions with same name are stor << 39 // 38 // 40 // If much additional functionality is added, 39 // If much additional functionality is added, should consider containment 41 // instead of inheritance for std::vector<T>. << 40 // instead of inheritance for std::vector<T> 42 << 41 // 43 // 18.09.02, G.Cosmo - Initial version << 42 // Member data: 44 // ------------------------------------------- << 43 // 45 #ifndef G4REGIONSTORE_HH << 44 // static G4RegionStore* 46 #define G4REGIONSTORE_HH 1 << 45 // - Pointer to the single G4RegionStore 47 46 48 #include <vector> << 47 // History: 49 #include <map> << 48 // 18.09.02 G.Cosmo Initial version >> 49 // ******************************************************************** 50 50 51 #include "G4Types.hh" << 51 #ifndef G4REGIONSTORE_HH 52 #include "G4String.hh" << 52 #define G4REGIONSTORE_HH 53 #include "G4VStoreNotifier.hh" << 54 53 55 class G4Region; 54 class G4Region; 56 class G4VPhysicalVolume; << 57 55 58 class G4RegionStore : public std::vector<G4Reg << 56 #include "g4std/vector" >> 57 #include "globals.hh" >> 58 >> 59 class G4RegionStore : public G4std::vector<G4Region*> 59 { 60 { 60 public: << 61 public: // with description 61 62 62 static void Register(G4Region* pRegion); << 63 static void Register(G4Region* pSolid); 63 // Add the region to the collection. 64 // Add the region to the collection. 64 static void DeRegister(G4Region* pRegion); << 65 static void DeRegister(G4Region* pSolid); 65 // Remove the region from the collection 66 // Remove the region from the collection. 66 static G4RegionStore* GetInstance(); 67 static G4RegionStore* GetInstance(); 67 // Get a ptr to the unique G4RegionStore 68 // Get a ptr to the unique G4RegionStore, creating it if necessary. 68 static void SetNotifier(G4VStoreNotifier* << 69 // Assign a notifier for allocation/deal << 70 static void Clean(); 69 static void Clean(); 71 // Delete all regions from the store exc << 70 // Delete all regions from the store. 72 71 73 G4bool IsModified() const; 72 G4bool IsModified() const; 74 // Loops through all regions to verify i 73 // Loops through all regions to verify if a region has been 75 // modified. It returns TRUE if just one 74 // modified. It returns TRUE if just one region is modified. 76 void ResetRegionModified(); 75 void ResetRegionModified(); 77 // Loops through all regions to reset fl 76 // Loops through all regions to reset flag for modification 78 // to FALSE. Used by the run manager to 77 // to FALSE. Used by the run manager to notify that the 79 // physics table has been updated. 78 // physics table has been updated. 80 79 81 void UpdateMaterialList(G4VPhysicalVolume* << 80 void UpdateMaterialList(); 82 // Forces recomputation of material list 81 // Forces recomputation of material lists in all regions 83 // in the store. 82 // in the store. 84 83 85 G4Region* GetRegion(const G4String& name, << 84 G4Region* GetRegion(const G4String& name, G4bool verbose=true) const; 86 // Returns a region through its name spe << 85 // Returns a region through its name specification. 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 86 99 G4Region* FindOrCreateRegion(const G4Strin 87 G4Region* FindOrCreateRegion(const G4String& name); 100 // Returns a region through its name spe 88 // Returns a region through its name specification, if it exists. 101 // If it does not exist it will allocate 89 // If it does not exist it will allocate one delegating ownership 102 // to the client. 90 // to the client. 103 91 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(); 92 virtual ~G4RegionStore(); 110 // Destructor: takes care to delete allo 93 // Destructor: takes care to delete allocated regions. 111 94 112 G4RegionStore(const G4RegionStore&) = dele << 113 G4RegionStore& operator=(const G4RegionSto << 114 // Forbidden copy constructor and assign << 115 << 116 protected: 95 protected: 117 96 118 G4RegionStore(); 97 G4RegionStore(); 119 // Protected singleton constructor. << 120 98 121 private: 99 private: 122 100 123 static G4RegionStore* fgInstance; 101 static G4RegionStore* fgInstance; 124 static G4ThreadLocal G4VStoreNotifier* fgN << 102 static G4bool locked; 125 static G4ThreadLocal G4bool locked; << 126 << 127 std::map<G4String, std::vector<G4Region*> << 128 G4bool mvalid = false; // Flag to indicat << 129 }; 103 }; 130 104 131 #endif 105 #endif 132 106