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