00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // class G4RegionStore 00030 // 00031 // Class description: 00032 // 00033 // Container for all regiong, with functionality derived from 00034 // std::vector<T>. The class is a `singleton', in that only 00035 // one can exist, and access is provided via the static method 00036 // G4RegionStore::GetInstance(). 00037 // 00038 // All regions should be registered with G4RegionStore, and removed on their 00039 // destruction. The underlying container initially has a capacity of 20. 00040 // 00041 // If much additional functionality is added, should consider containment 00042 // instead of inheritance for std::vector<T> 00043 // 00044 // Member data: 00045 // 00046 // static G4RegionStore* 00047 // - Pointer to the single G4RegionStore 00048 00049 // History: 00050 // 18.09.02 G.Cosmo Initial version 00051 // -------------------------------------------------------------------- 00052 #ifndef G4REGIONSTORE_HH 00053 #define G4REGIONSTORE_HH 00054 00055 #include <vector> 00056 #include "G4Types.hh" 00057 #include "G4String.hh" 00058 #include "G4VStoreNotifier.hh" 00059 00060 class G4Region; 00061 class G4VPhysicalVolume; 00062 00063 class G4RegionStore : public std::vector<G4Region*> 00064 { 00065 public: // with description 00066 00067 static void Register(G4Region* pSolid); 00068 // Add the region to the collection. 00069 static void DeRegister(G4Region* pSolid); 00070 // Remove the region from the collection. 00071 static G4RegionStore* GetInstance(); 00072 // Get a ptr to the unique G4RegionStore, creating it if necessary. 00073 static void SetNotifier(G4VStoreNotifier* pNotifier); 00074 // Assign a notifier for allocation/deallocation of regions. 00075 static void Clean(); 00076 // Delete all regions from the store except for the world region. 00077 00078 G4bool IsModified() const; 00079 // Loops through all regions to verify if a region has been 00080 // modified. It returns TRUE if just one region is modified. 00081 void ResetRegionModified(); 00082 // Loops through all regions to reset flag for modification 00083 // to FALSE. Used by the run manager to notify that the 00084 // physics table has been updated. 00085 00086 void UpdateMaterialList(G4VPhysicalVolume* currentWorld=0); 00087 // Forces recomputation of material lists in all regions 00088 // in the store. 00089 00090 G4Region* GetRegion(const G4String& name, G4bool verbose=true) const; 00091 // Returns a region through its name specification. 00092 00093 G4Region* FindOrCreateRegion(const G4String& name); 00094 // Returns a region through its name specification, if it exists. 00095 // If it does not exist it will allocate one delegating ownership 00096 // to the client. 00097 00098 public: // without description 00099 00100 void SetWorldVolume(); 00101 // Set a world volume pointer to a region that belongs to it. 00102 // Scan over all world volumes. 00103 // This method should be exclusively used by G4RunManagerKernel. 00104 00105 protected: 00106 00107 G4RegionStore(); 00108 // Protected singleton constructor. 00109 virtual ~G4RegionStore(); 00110 // Destructor: takes care to delete allocated regions. 00111 00112 private: 00113 00114 static G4RegionStore* fgInstance; 00115 static G4VStoreNotifier* fgNotifier; 00116 static G4bool locked; 00117 }; 00118 00119 #endif