G4PhysicsTable.hh

Go to the documentation of this file.
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 // 
00030 // ------------------------------------------------------------
00031 //      GEANT 4 class header file
00032 //
00033 // Class description:
00034 //
00035 // G4PhysicsTable is an utility class for storage of pointers
00036 // to G4PhysicsVector containers. It derives all functionalities
00037 // of STL vector containers with the addition of few methods for
00038 // compatibility with previous implementation based on Rogue-Wave
00039 // pointer collections.
00040 // The constructor given the 'capacity' of the table, pre-allocates
00041 // memory for the specified value by invoking the STL's reserve()
00042 // function, in order to avoid reallocation during insertions.
00043 // G4PhysicsTable has a vector of boolean which are used 
00044 // as 'recalc-needed' flags when processes calculate physics tables. 
00045 // ------------------------------------------------------------
00046 //
00047 // History:
00048 // -------
00049 // - First implementation, based on object model of
00050 //   2nd December 1995. G.Cosmo
00051 // - 1st March 1996, modified. K.Amako
00052 // - 24th February 2001, migration to STL vectors. H.Kurashige
00053 // - 9th March 2001, added Store/RetrievePhysicsTable. H.Kurashige
00054 // - 20th August 2004, added FlagArray and related methods   H.Kurashige
00055 //-------------------------------------
00056 
00057 #ifndef G4PhysicsTable_h
00058 #define G4PhysicsTable_h 1
00059 
00060 #include <vector>
00061 #include "globals.hh"
00062 #include "G4ios.hh"
00063 
00064 class G4PhysicsVector;
00065 
00066 class G4PhysicsTable : public std::vector<G4PhysicsVector*> 
00067 {
00068 
00069   typedef std::vector<G4PhysicsVector*> G4PhysCollection;
00070   typedef std::vector<G4bool> G4FlagCollection;
00071  
00072  public: // with description
00073 
00074   G4PhysicsTable();
00075     // Default constructor.
00076 
00077   explicit G4PhysicsTable(size_t cap);
00078     // Constructor with capacity. Reserves memory for the
00079     // specified capacity.
00080 
00081   virtual ~G4PhysicsTable();
00082     // Destructor.
00083     // Does not invoke deletion of contained pointed collections.
00084 
00085   G4PhysicsVector*& operator()(size_t);
00086   G4PhysicsVector* const& operator()(size_t) const;
00087     // Access operators.
00088 
00089   void clearAndDestroy();
00090     // Removes all items and deletes them at the same time.
00091 
00092   void   push_back( G4PhysicsVector* );
00093   void   insert (G4PhysicsVector*);
00094     // Pushes new element to collection.
00095 
00096   void   insertAt (size_t, G4PhysicsVector*); 
00097     // insert element at the specified position in the collection.
00098   
00099   void   resize(size_t, G4PhysicsVector* vec = (G4PhysicsVector*)(0));
00100   // resize collection
00101  
00102   size_t entries() const;
00103   size_t length() const;
00104     // Return collection's size.
00105 
00106   G4bool isEmpty() const;
00107     // Flags if collection is empty or not.
00108 
00109   G4bool ExistPhysicsTable(const G4String& fileName) const;
00110     // Check if the specified file exists or not
00111 
00112   G4bool StorePhysicsTable(const G4String& filename, G4bool ascii=false);
00113     // Stores PhysicsTable in a file (returns false in case of failure).
00114   
00115   G4bool RetrievePhysicsTable(const G4String& filename, G4bool ascii=false);
00116     // Retrieves Physics from a file (returns false in case of failure).
00117 
00118   void ResetFlagArray();
00119     // Reset the array of flags and all flags are set "true" 
00120     // This flag is supposed to be used as "recalc-needed" flag
00121     //   associated with each physics vector  
00122 
00123   G4bool GetFlag(size_t i) const;
00124   void   ClearFlag(size_t i);
00125     // Get/Clear the flag for the 'i-th' physics vector    
00126    
00127   friend std::ostream& operator<<(std::ostream& out, G4PhysicsTable& table);
00128 
00129  protected:
00130 
00131   G4PhysicsVector* CreatePhysicsVector(G4int type);  
00132   G4FlagCollection vecFlag; 
00133 
00134  private:
00135 
00136   G4PhysicsTable(const G4PhysicsTable&);
00137   G4PhysicsTable& operator=(const G4PhysicsTable&);
00138     // Private copy constructor and assignment operator.
00139 
00140 };
00141 
00142 typedef G4PhysicsTable::iterator G4PhysicsTableIterator;
00143 
00144 #include "G4PhysicsVector.hh"
00145 #include "G4PhysicsTable.icc"
00146 
00147 #endif

Generated on Mon May 27 17:49:19 2013 for Geant4 by  doxygen 1.4.7