source: trunk/source/particles/management/include/G4ShortLivedTable.hh @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 4.6 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4ShortLivedTable.hh,v 1.14 2010/08/10 15:47:42 kurasige Exp $
28// GEANT4 tag $Name: particles-V09-03-15 $
29//
30//
31// ------------------------------------------------------------
32//      GEANT 4 class header file
33//
34//      History: first implementation,
35//      based on object model of June 27, 98 H.Kurashige
36// ------------------------------------------------------------
37//      added clear()                   20 Mar.,08 H.Kurashige
38//      added Remove()                  06 Nov.,98 H.Kurashige
39
40#ifndef G4ShortLivedTable_h
41#define G4ShortLivedTable_h 1
42
43#include "G4ios.hh"
44#include "globals.hh"
45#include "G4ParticleDefinition.hh"
46
47#include <vector>
48
49class G4ParticleTable;
50
51class G4ShortLivedTable
52{
53 // Class Description
54 //   G4ShortLivedTable is the table of pointer to G4ParticleDefinition
55 //   In G4ShortLivedTable, each G4ParticleDefinition pointer is stored
56 //
57
58 public:
59   // Use STL Vector as list of shortlives
60   typedef std::vector<const G4ParticleDefinition*>  G4ShortLivedList;
61
62 public:
63   G4ShortLivedTable();
64
65 protected:
66   G4ShortLivedTable(const  G4ShortLivedTable &right);
67
68 public: // With Description
69   virtual ~G4ShortLivedTable();
70
71   G4bool                IsShortLived(const G4ParticleDefinition*) const;
72   // return true if the particle is shortlived particle
73 
74   void DumpTable(const G4String &particle_name = "ALL") const;
75   // dump information of particles specified by name
76
77   G4int                 Entries() const;
78   // return number of particles in the list
79
80   G4bool                Contains(const G4ParticleDefinition *particle) const;
81   // return true if the list contains the specified particle
82
83   void                  Insert(const G4ParticleDefinition* particle);
84   // add the particle in the list
85
86   void                  Remove(const G4ParticleDefinition* particle);
87   // remove the particle (not delete) from the list
88
89   G4ParticleDefinition* GetParticle(G4int index) const;
90   // return the i-th particle in the list
91
92   G4int                 size() const;
93   // return number of particles in the list
94 
95   void                  clear();
96   // remove all particles (not delete) from the list
97
98 protected://Without Description
99   G4int                GetVerboseLevel() const;
100
101 private:
102   G4ShortLivedList*                  fShortLivedList;
103
104};
105
106inline G4bool  G4ShortLivedTable::Contains(const G4ParticleDefinition* particle) const
107{
108  G4ShortLivedList::iterator i;
109  for (i = fShortLivedList->begin(); i!= fShortLivedList->end(); ++i) {
110    if (**i==*particle) return true;
111  }
112  return false;
113}
114
115inline G4int G4ShortLivedTable::Entries() const
116{
117  return fShortLivedList->size();
118}
119
120inline G4int G4ShortLivedTable::size() const
121{
122  return fShortLivedList->size();
123}
124
125inline void G4ShortLivedTable::clear()
126{
127  fShortLivedList->clear();
128}
129
130inline 
131 G4ParticleDefinition*  G4ShortLivedTable::GetParticle(G4int index) const
132{
133  if ( (index >=0 ) && (index < Entries()) ) {
134    return const_cast<G4ParticleDefinition*>( (*fShortLivedList)[index] );
135  } else {
136    return 0; 
137  } 
138}
139
140
141
142#endif
Note: See TracBrowser for help on using the repository browser.