Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // 26 // G4PhysicsTable << 8 // $Id: G4PhysicsTable.hh,v 1.10 2001/04/03 07:26:38 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ >> 10 // >> 11 // >> 12 // ------------------------------------------------------------ >> 13 // GEANT 4 class header file 27 // 14 // 28 // Class description: 15 // Class description: 29 // 16 // 30 // G4PhysicsTable is an utility class for stor 17 // G4PhysicsTable is an utility class for storage of pointers 31 // to G4PhysicsVector containers. It derives a 18 // to G4PhysicsVector containers. It derives all functionalities 32 // of STL vector containers with the addition 19 // of STL vector containers with the addition of few methods for 33 // compatibility with previous implementation 20 // compatibility with previous implementation based on Rogue-Wave 34 // pointer collections. 21 // pointer collections. 35 // The constructor given the 'capacity' of the 22 // The constructor given the 'capacity' of the table, pre-allocates 36 // memory for the specified value by invoking 23 // memory for the specified value by invoking the STL's reserve() 37 // function, in order to avoid reallocation du 24 // function, in order to avoid reallocation during insertions. 38 // G4PhysicsTable has a vector of Boolean whic << 25 // ------------------------------------------------------------ 39 // as 'recalc-needed' flags when processes cal << 26 // >> 27 // History: >> 28 // ------- >> 29 // - First implementation, based on object model of >> 30 // 2nd December 1995. G.Cosmo >> 31 // - 1st March 1996, modified. K.Amako >> 32 // - 24th February 2001, migration to STL vectors. H.Kurashige >> 33 // - 9th March 2001, added Store/RetrievePhysicsTable. H.Kurashige >> 34 //------------------------------------- 40 35 41 // Author: G.Cosmo, 2 December 1995 << 36 #ifndef G4PhysicsTable_h 42 // First implementation based on objec << 37 #define G4PhysicsTable_h 1 43 // Revisions: << 44 // - 1st March 1996, K.Amako: modified << 45 // - 24th February 2001, H.Kurashige: migratio << 46 // ------------------------------------------- << 47 #ifndef G4PhysicsTable_hh << 48 #define G4PhysicsTable_hh 1 << 49 38 50 #include "G4PhysicsVector.hh" << 39 #include "g4std/vector" 51 #include "G4ios.hh" << 52 #include "globals.hh" 40 #include "globals.hh" 53 #include <vector> << 41 #include "G4ios.hh" >> 42 >> 43 class G4PhysicsVector; 54 44 55 class G4PhysicsTable : public std::vector<G4Ph << 45 class G4PhysicsTable : public G4std::vector<G4PhysicsVector*> 56 { 46 { 57 using G4PhysCollection = std::vector<G4Physi << 58 using G4FlagCollection = std::vector<G4bool> << 59 47 60 public: << 48 typedef G4std::vector<G4PhysicsVector*> G4PhysCollection; 61 G4PhysicsTable() = default; << 62 // Default constructor << 63 49 64 explicit G4PhysicsTable(size_t cap); << 50 public: // with description 65 // Constructor with capacity. Reserves memor << 66 51 67 virtual ~G4PhysicsTable(); << 52 G4PhysicsTable(); 68 // Destructor. Does not invoke deletion of c << 53 // Default constructor. 69 54 70 G4PhysicsTable(const G4PhysicsTable&) = dele << 55 G4PhysicsTable(size_t capacity); 71 G4PhysicsTable& operator=(const G4PhysicsTab << 56 // Constructor with capacity. Reserves memory for the >> 57 // specified capacity. 72 58 73 G4PhysicsVector*& operator()(std::size_t); << 59 virtual ~G4PhysicsTable(); 74 G4PhysicsVector* const& operator()(std::size << 60 // Destructor. 75 // Access operators << 61 // Does not invoke deletion of contained pointed collections. 76 62 77 void clearAndDestroy(); << 63 G4PhysicsVector*& operator()(size_t); 78 // Removes all items and deletes them at the << 64 G4PhysicsVector* const& operator()(size_t) const; >> 65 // Access operators. 79 66 80 void push_back(G4PhysicsVector*); << 67 void clearAndDestroy(); 81 void insert(G4PhysicsVector*); << 68 // Removes all items and deletes them at the same time. 82 // Pushes new element to collection << 83 69 84 void insertAt(std::size_t, G4PhysicsVector*) << 70 void insert (G4PhysicsVector*); 85 // Insert element at the specified position << 71 // Pushes new element to collection. 86 72 87 void resize(std::size_t, G4PhysicsVector* ve << 73 void insertAt (size_t, G4PhysicsVector*); 88 // Resize collection << 74 // Inserts element at the specified position in the collection. 89 75 90 std::size_t entries() const; << 76 size_t entries() const; 91 std::size_t length() const; << 77 size_t length() const; 92 // Return collection's size << 78 // Return collection's size. 93 79 94 G4bool isEmpty() const; 80 G4bool isEmpty() const; 95 // Flags if collection is empty or not << 81 // Flags if collection is empty or not. 96 82 97 G4bool ExistPhysicsTable(const G4String& fil << 83 G4bool StorePhysicsTable(const G4String& filename, G4bool ascii=false); 98 // Check if the specified file exists or not << 84 // Stores PhysicsTable in a file (returns false in case of failure). >> 85 >> 86 G4bool RetrievePhysicsTable(const G4String& filename, G4bool ascii=false); >> 87 // Retrieves Physics from a file (returns false in case of failure). 99 88 100 G4bool StorePhysicsTable(const G4String& fil << 89 friend G4std::ostream& operator<<(G4std::ostream& out, G4PhysicsTable& table); 101 // Stores PhysicsTable in a file (returns fa << 102 90 103 G4bool RetrievePhysicsTable(const G4String& << 91 protected: 104 // Retrieves Physics from a file (returns fa << 105 92 106 void ResetFlagArray(); << 93 G4PhysicsVector* CreatePhysicsVector(G4int type); 107 // Reset the array of flags and all flags ar << 108 // This flag is supposed to be used as "reca << 109 // associated with each physics vector << 110 94 111 G4bool GetFlag(std::size_t i) const; << 95 private: 112 void ClearFlag(std::size_t i); << 113 // Get/Clear the flag for the 'i-th' physics << 114 96 115 friend std::ostream& operator<<(std::ostream << 97 G4PhysicsTable(const G4PhysicsTable&); >> 98 G4PhysicsTable& operator=(const G4PhysicsTable&); >> 99 // Private copy constructor and assignment operator. 116 100 117 protected: << 118 G4PhysicsVector* CreatePhysicsVector(G4int t << 119 G4FlagCollection vecFlag; << 120 }; 101 }; 121 102 >> 103 typedef G4PhysicsTable::iterator G4PhysicsTableIterator; >> 104 >> 105 #include "G4PhysicsVector.hh" 122 #include "G4PhysicsTable.icc" 106 #include "G4PhysicsTable.icc" 123 107 124 #endif 108 #endif 125 109