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.11 2001/07/11 10:00:50 gunter Exp $ >> 25 // GEANT4 tag $Name: geant4-05-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 // ------------------------------------------------------------ 39 // as 'recalc-needed' flags when processes cal << 42 // >> 43 // History: >> 44 // ------- >> 45 // - First implementation, based on object model of >> 46 // 2nd December 1995. G.Cosmo >> 47 // - 1st March 1996, modified. K.Amako >> 48 // - 24th February 2001, migration to STL vectors. H.Kurashige >> 49 // - 9th March 2001, added Store/RetrievePhysicsTable. H.Kurashige >> 50 //------------------------------------- 40 51 41 // Author: G.Cosmo, 2 December 1995 << 52 #ifndef G4PhysicsTable_h 42 // First implementation based on objec << 53 #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 54 50 #include "G4PhysicsVector.hh" << 55 #include "g4std/vector" 51 #include "G4ios.hh" << 52 #include "globals.hh" 56 #include "globals.hh" 53 #include <vector> << 57 #include "G4ios.hh" 54 58 55 class G4PhysicsTable : public std::vector<G4Ph << 59 class G4PhysicsVector; >> 60 >> 61 class G4PhysicsTable : public G4std::vector<G4PhysicsVector*> 56 { 62 { 57 using G4PhysCollection = std::vector<G4Physi << 58 using G4FlagCollection = std::vector<G4bool> << 59 63 60 public: << 64 typedef G4std::vector<G4PhysicsVector*> G4PhysCollection; 61 G4PhysicsTable() = default; << 62 // Default constructor << 63 65 64 explicit G4PhysicsTable(size_t cap); << 66 public: // with description 65 // Constructor with capacity. Reserves memor << 66 67 67 virtual ~G4PhysicsTable(); << 68 G4PhysicsTable(); 68 // Destructor. Does not invoke deletion of c << 69 // Default constructor. 69 70 70 G4PhysicsTable(const G4PhysicsTable&) = dele << 71 G4PhysicsTable(size_t capacity); 71 G4PhysicsTable& operator=(const G4PhysicsTab << 72 // Constructor with capacity. Reserves memory for the >> 73 // specified capacity. 72 74 73 G4PhysicsVector*& operator()(std::size_t); << 75 virtual ~G4PhysicsTable(); 74 G4PhysicsVector* const& operator()(std::size << 76 // Destructor. 75 // Access operators << 77 // Does not invoke deletion of contained pointed collections. 76 78 77 void clearAndDestroy(); << 79 G4PhysicsVector*& operator()(size_t); 78 // Removes all items and deletes them at the << 80 G4PhysicsVector* const& operator()(size_t) const; >> 81 // Access operators. 79 82 80 void push_back(G4PhysicsVector*); << 83 void clearAndDestroy(); 81 void insert(G4PhysicsVector*); << 84 // Removes all items and deletes them at the same time. 82 // Pushes new element to collection << 83 85 84 void insertAt(std::size_t, G4PhysicsVector*) << 86 void insert (G4PhysicsVector*); 85 // Insert element at the specified position << 87 // Pushes new element to collection. 86 88 87 void resize(std::size_t, G4PhysicsVector* ve << 89 void insertAt (size_t, G4PhysicsVector*); 88 // Resize collection << 90 // Inserts element at the specified position in the collection. 89 91 90 std::size_t entries() const; << 92 size_t entries() const; 91 std::size_t length() const; << 93 size_t length() const; 92 // Return collection's size << 94 // Return collection's size. 93 95 94 G4bool isEmpty() const; 96 G4bool isEmpty() const; 95 // Flags if collection is empty or not << 97 // Flags if collection is empty or not. 96 98 97 G4bool ExistPhysicsTable(const G4String& fil << 99 G4bool StorePhysicsTable(const G4String& filename, G4bool ascii=false); 98 // Check if the specified file exists or not << 100 // Stores PhysicsTable in a file (returns false in case of failure). >> 101 >> 102 G4bool RetrievePhysicsTable(const G4String& filename, G4bool ascii=false); >> 103 // Retrieves Physics from a file (returns false in case of failure). 99 104 100 G4bool StorePhysicsTable(const G4String& fil << 105 friend G4std::ostream& operator<<(G4std::ostream& out, G4PhysicsTable& table); 101 // Stores PhysicsTable in a file (returns fa << 102 106 103 G4bool RetrievePhysicsTable(const G4String& << 107 protected: 104 // Retrieves Physics from a file (returns fa << 105 108 106 void ResetFlagArray(); << 109 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 110 111 G4bool GetFlag(std::size_t i) const; << 111 private: 112 void ClearFlag(std::size_t i); << 113 // Get/Clear the flag for the 'i-th' physics << 114 112 115 friend std::ostream& operator<<(std::ostream << 113 G4PhysicsTable(const G4PhysicsTable&); >> 114 G4PhysicsTable& operator=(const G4PhysicsTable&); >> 115 // Private copy constructor and assignment operator. 116 116 117 protected: << 118 G4PhysicsVector* CreatePhysicsVector(G4int t << 119 G4FlagCollection vecFlag; << 120 }; 117 }; 121 118 >> 119 typedef G4PhysicsTable::iterator G4PhysicsTableIterator; >> 120 >> 121 #include "G4PhysicsVector.hh" 122 #include "G4PhysicsTable.icc" 122 #include "G4PhysicsTable.icc" 123 123 124 #endif 124 #endif 125 125