G4ShortLivedTable.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 //      History: first implementation, 
00034 //      based on object model of June 27, 98 H.Kurashige
00035 // ------------------------------------------------------------
00036 //      added clear()                   20 Mar.,08 H.Kurashige
00037 //      added Remove()                  06 Nov.,98 H.Kurashige
00038 
00039 #ifndef G4ShortLivedTable_h
00040 #define G4ShortLivedTable_h 1
00041 
00042 #include "G4ios.hh"
00043 #include "globals.hh"
00044 #include "G4ParticleDefinition.hh"
00045 
00046 #include <vector>
00047 
00048 class G4ParticleTable;
00049 
00050 class G4ShortLivedTable
00051 {
00052  // Class Description
00053  //   G4ShortLivedTable is the table of pointer to G4ParticleDefinition
00054  //   In G4ShortLivedTable, each G4ParticleDefinition pointer is stored
00055  //
00056 
00057  public:
00058    // Use STL Vector as list of shortlives
00059    typedef std::vector<const G4ParticleDefinition*>  G4ShortLivedList;
00060 
00061  public:
00062    G4ShortLivedTable();
00063 
00064  protected:
00065    // Copy constructor and assignment operator
00066     G4ShortLivedTable(const  G4ShortLivedTable &right);
00067     G4ShortLivedTable & operator=(const G4ShortLivedTable &);
00068  
00069  public: // With Description
00070    virtual ~G4ShortLivedTable();
00071 
00072    G4bool                IsShortLived(const G4ParticleDefinition*) const;
00073    // return true if the particle is shortlived particle
00074   
00075    void DumpTable(const G4String &particle_name = "ALL") const;
00076    // dump information of particles specified by name 
00077 
00078    G4int                 Entries() const;
00079    // return number of particles in the list
00080 
00081    G4bool                Contains(const G4ParticleDefinition *particle) const;
00082    // return true if the list contains the specified particle 
00083 
00084    void                  Insert(const G4ParticleDefinition* particle);
00085    // add the particle in the list
00086 
00087    void                  Remove(const G4ParticleDefinition* particle);
00088    // remove the particle (not delete) from the list 
00089 
00090    G4ParticleDefinition* GetParticle(G4int index) const;
00091    // return the i-th particle in the list
00092 
00093    G4int                 size() const;
00094    // return number of particles in the list
00095   
00096    void                  clear();
00097    // remove all particles (not delete) from the list
00098 
00099  protected://Without Description
00100    G4int                GetVerboseLevel() const;
00101 
00102  private:
00103    G4ShortLivedList*                  fShortLivedList;
00104 
00105 };
00106 
00107 inline G4bool  G4ShortLivedTable::Contains(const G4ParticleDefinition* particle) const
00108 {
00109   G4ShortLivedList::iterator i;
00110   for (i = fShortLivedList->begin(); i!= fShortLivedList->end(); ++i) {
00111     if (**i==*particle) return true;
00112   }
00113   return false;
00114 }
00115 
00116 inline G4int G4ShortLivedTable::Entries() const
00117 {
00118   return fShortLivedList->size();
00119 }
00120 
00121 inline G4int G4ShortLivedTable::size() const
00122 {
00123   return fShortLivedList->size();
00124 }
00125 
00126 
00127 inline 
00128  G4ParticleDefinition*  G4ShortLivedTable::GetParticle(G4int index) const
00129 {
00130   if ( (index >=0 ) && (index < Entries()) ) {
00131     return const_cast<G4ParticleDefinition*>( (*fShortLivedList)[index] );
00132   } else {
00133     return 0; 
00134   } 
00135 }
00136 
00137 
00138 
00139 #endif

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