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 G4LogicalVolumeStore 00030 // 00031 // Class description: 00032 // 00033 // Container for all LogicalVolumes, 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 function 00036 // G4LogicalVolumeStore::GetInstance() 00037 // 00038 // All LogicalVolumes should be registered with G4LogicalVolumeStore, 00039 // and removed on their destruction. Intended principally for UI browser. 00040 // The underlying container initially has a capacity of 100. 00041 // 00042 // If much additional functionality is added, should consider containment 00043 // instead of inheritance for std::vector<T>. 00044 // 00045 // Member data: 00046 // 00047 // static G4LogicalVolumeStore* fgInstance 00048 // - Ptr to the single G4LogicalVolumeStore. 00049 00050 // History: 00051 // 18.04.01 G.Cosmo Migrated to STL vector 00052 // 10.07.95 P.Kent Initial version 00053 // -------------------------------------------------------------------- 00054 #ifndef G4LOGICALVOLUMESTORE_HH 00055 #define G4LOGICALVOLUMESTORE_HH 00056 00057 #include <vector> 00058 00059 #include "G4LogicalVolume.hh" 00060 #include "G4VStoreNotifier.hh" 00061 00062 class G4LogicalVolumeStore : public std::vector<G4LogicalVolume*> 00063 { 00064 public: // with description 00065 00066 static void Register(G4LogicalVolume* pVolume); 00067 // Add the logical volume to the collection. 00068 static void DeRegister(G4LogicalVolume* pVolume); 00069 // Remove the logical volume from the collection. 00070 static G4LogicalVolumeStore* GetInstance(); 00071 // Get a ptr to the unique G4LogicalVolumeStore, creating it if necessary. 00072 static void SetNotifier(G4VStoreNotifier* pNotifier); 00073 // Assign a notifier for allocation/deallocation of the logical volumes. 00074 static void Clean(); 00075 // Delete all volumes from the store. 00076 00077 G4LogicalVolume* GetVolume(const G4String& name, G4bool verbose=true) const; 00078 // Return the pointer of the first volume in the collection having 00079 // that name. 00080 00081 virtual ~G4LogicalVolumeStore(); 00082 // Destructor: takes care to delete allocated logical volumes. 00083 00084 protected: 00085 00086 G4LogicalVolumeStore(); 00087 00088 private: 00089 00090 static G4LogicalVolumeStore* fgInstance; 00091 static G4VStoreNotifier* fgNotifier; 00092 static G4bool locked; 00093 }; 00094 00095 #endif