|
||||
Warning, file /include/Geant4/G4LogicalVolumeStore.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4LogicalVolumeStore 0027 // 0028 // Class description: 0029 // 0030 // Container for all logical volumes, with functionality derived from 0031 // std::vector<T>. The class is a 'singleton', in that only 0032 // one can exist, and access is provided via the static function 0033 // G4LogicalVolumeStore::GetInstance() 0034 // 0035 // All logical volumes should be registered with G4LogicalVolumeStore, 0036 // and removed on their destruction. 0037 // The underlying container initially has a capacity of 100. 0038 // A map indexed by volume names is also recorded for fast search; 0039 // pointers to volumes with same name are stored in buckets. 0040 // 0041 // If much additional functionality is added, should consider containment 0042 // instead of inheritance for std::vector<T>. 0043 0044 // 10.07.95, P.Kent, G.Cosmo - Initial version 0045 // -------------------------------------------------------------------- 0046 #ifndef G4LOGICALVOLUMESTORE_HH 0047 #define G4LOGICALVOLUMESTORE_HH 1 0048 0049 #include <vector> 0050 #include <map> 0051 0052 #include "G4LogicalVolume.hh" 0053 #include "G4VStoreNotifier.hh" 0054 0055 class G4LogicalVolumeStore : public std::vector<G4LogicalVolume*> 0056 { 0057 public: 0058 0059 static void Register(G4LogicalVolume* pVolume); 0060 // Add the logical volume to the collection. 0061 static void DeRegister(G4LogicalVolume* pVolume); 0062 // Remove the logical volume from the collection. 0063 static G4LogicalVolumeStore* GetInstance(); 0064 // Get a ptr to the unique G4LogicalVolumeStore, creating it if necessary. 0065 static void SetNotifier(G4VStoreNotifier* pNotifier); 0066 // Assign a notifier for allocation/deallocation of the logical volumes. 0067 static void Clean(); 0068 // Delete all volumes from the store. 0069 0070 G4LogicalVolume* GetVolume(const G4String& name, G4bool verbose=true, 0071 G4bool reverseSearch=false) const; 0072 // Return the pointer of the first or last volume in the collection having 0073 // that name. Uses the internal map for fast search and warns if 0074 // a volume in the collection is not unique or not found. 0075 0076 inline G4bool IsMapValid() const { return mvalid; } 0077 inline void SetMapValid(G4bool val) { mvalid = val; } 0078 // Accessor to assess validity of the internal map. 0079 inline const std::map<G4String, 0080 std::vector<G4LogicalVolume*> >& GetMap() const { return bmap; } 0081 // Return the internal map. 0082 void UpdateMap(); 0083 // Bring contents of internal map up to date and resets validity flag. 0084 0085 virtual ~G4LogicalVolumeStore(); 0086 // Destructor: takes care to delete allocated logical volumes. 0087 0088 G4LogicalVolumeStore(const G4LogicalVolumeStore&) = delete; 0089 G4LogicalVolumeStore& operator=(const G4LogicalVolumeStore&) = delete; 0090 // Forbidden copy constructor and assignment operator 0091 0092 protected: 0093 0094 G4LogicalVolumeStore(); 0095 0096 private: 0097 0098 static G4LogicalVolumeStore* fgInstance; 0099 static G4ThreadLocal G4VStoreNotifier* fgNotifier; 0100 static G4ThreadLocal G4bool locked; 0101 0102 std::map<G4String, std::vector<G4LogicalVolume*> > bmap; 0103 G4bool mvalid = false; // Flag to indicate if map is up to date or not 0104 }; 0105 0106 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |