Geant4-11
pyG4ParticleList.cc
Go to the documentation of this file.
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// pyG4ParticleList.cc
28//
29// 2005 Q
30// ====================================================================
31#include <boost/python.hpp>
32#include "G4ParticleTable.hh"
33
34using namespace boost::python;
35
36// ====================================================================
37// internal class
38// ====================================================================
39
41public:
42 typedef std::vector<G4ParticleDefinition*> ParticleList;
43 typedef ParticleList::iterator p_iterator;
44
46
49 if(particleTableCache.size() != static_cast<size_t>(particleTable-> size()) ) {
50 particleTableCache.clear();
51 G4ParticleTable::G4PTblDicIterator* theParticleIterator= particleTable-> GetIterator();
52 theParticleIterator-> reset();
53 while( (*theParticleIterator)() ){
54 G4ParticleDefinition* particle= theParticleIterator-> value();
55 particleTableCache.push_back(particle);
56 }
57 }
58 return particleTableCache.begin();
59 }
60
63 if(particleTableCache.size() != static_cast<size_t>(particleTable-> size()) ) {
64 particleTableCache.clear();
65 G4ParticleTable::G4PTblDicIterator* theParticleIterator= particleTable-> GetIterator();
66 theParticleIterator-> reset();
67 while( (*theParticleIterator)() ){
68 G4ParticleDefinition* particle= theParticleIterator-> value();
69 particleTableCache.push_back(particle);
70 }
71 }
72 return particleTableCache.end();
73 }
74};
75
77
78
79// ====================================================================
80// module definition
81// ====================================================================
83{
84 class_<PyG4ParticleList>("PyG4ParticleList", "particle list")
85 .def("__iter__", iterator<PyG4ParticleList::ParticleList>())
86 .add_property("particles", range(&PyG4ParticleList::p_begin,
88 ;
89}
90
#define theParticleIterator
static G4ParticleTable * GetParticleTable()
ParticleList::iterator p_iterator
p_iterator p_begin()
static ParticleList particleTableCache
std::vector< G4ParticleDefinition * > ParticleList
p_iterator p_end()
void export_PyG4ParticleList()