|
|
|||
Warning, file /include/Geant4/G4SolidStore.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 // G4SolidStore 0027 // 0028 // Class description: 0029 // 0030 // Container for all solids, 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 method 0033 // G4SolidStore::GetInstance(). 0034 // 0035 // All solids should be registered with G4SolidStore, and removed on their 0036 // destruction. The underlying container initially has a capacity of 100. 0037 // A map indexed by solid names is also recorded for fast search; 0038 // pointers to solids with same name are stored in buckets. 0039 // 0040 // If much additional functionality is added, should consider containment 0041 // instead of inheritance for std::vector<T>. 0042 0043 // Authors: Gabriele Cosmo & Paul Kent (CERN), 10.07.1995 - Initial version 0044 // -------------------------------------------------------------------- 0045 #ifndef G4VSOLIDSTORE_HH 0046 #define G4VSOLIDSTORE_HH 0047 0048 #include <vector> 0049 #include <map> 0050 0051 #include "G4VSolid.hh" 0052 #include "G4VStoreNotifier.hh" 0053 0054 /** 0055 * @brief G4LogicalVolumeStore is a singleton class, acting as container 0056 * for all solids primitives, with functionality derived from std::vector<T>. 0057 * All solids should be registered with G4SolidStore, and removed on their 0058 * destruction. The underlying container initially has a capacity of 100. 0059 * A map indexed by solid names is also recorded for fast search; pointers 0060 * to solids with same name are stored in buckets. 0061 */ 0062 0063 class G4SolidStore : public std::vector<G4VSolid*> 0064 { 0065 public: 0066 0067 /** 0068 * Destructor: takes care to delete allocated solids. 0069 */ 0070 virtual ~G4SolidStore(); 0071 0072 /** 0073 * Copy constructor and assignment operator not allowed. 0074 */ 0075 G4SolidStore(const G4SolidStore&) = delete; 0076 G4SolidStore& operator=(const G4SolidStore&) = delete; 0077 0078 /** 0079 * Adds the solid 'pSolid' to the collection. 0080 */ 0081 static void Register(G4VSolid* pSolid); 0082 0083 /** 0084 * Removes the solid 'pSolid' from the collection. 0085 */ 0086 static void DeRegister(G4VSolid* pSolid); 0087 0088 /** 0089 * Returns a pointer to the unique instance of G4SolidStore, 0090 * creating it if necessary. 0091 */ 0092 static G4SolidStore* GetInstance(); 0093 0094 /** 0095 * Assigns a notifier for allocation/deallocation of the solids. 0096 */ 0097 static void SetNotifier(G4VStoreNotifier* pNotifier); 0098 0099 /** 0100 * Deletes all solids from the store. 0101 */ 0102 static void Clean(); 0103 0104 /** 0105 * Returns a pointer to the first or last solid in the collection having 0106 * that name. Uses the internal map for fast search and warns if a solid 0107 * in the collection is not unique or not found. 0108 * @param[in] name The name of the solid to search. 0109 * @param[in] verbose Flag for enabling verbosity (default true). 0110 * @param[in] reverseSearch Flag to enable inverse search (default false). 0111 */ 0112 G4VSolid* GetSolid(const G4String& name, G4bool verbose = true, 0113 G4bool reverseSearch = false) const; 0114 0115 /** 0116 * Accessor and modifier to assess validity of the internal map. 0117 */ 0118 inline G4bool IsMapValid() const { return mvalid; } 0119 inline void SetMapValid(G4bool val) { mvalid = val; } 0120 0121 /** 0122 * Returns the internal map. 0123 */ 0124 inline const std::map<G4String, 0125 std::vector<G4VSolid*> >& GetMap() const { return bmap; } 0126 0127 /** 0128 * Brings contents of the internal map up to date and resets validity flag. 0129 */ 0130 void UpdateMap(); 0131 0132 protected: 0133 0134 /** 0135 * Protected singleton constructor. 0136 */ 0137 G4SolidStore(); 0138 0139 private: 0140 0141 static G4SolidStore* fgInstance; 0142 static G4ThreadLocal G4VStoreNotifier* fgNotifier; 0143 static G4ThreadLocal G4bool locked; 0144 0145 std::map<G4String, std::vector<G4VSolid*> > bmap; 0146 G4bool mvalid = false; // Flag to indicate if map is up to date or not 0147 }; 0148 0149 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|