testShowerFileParticleIterator.cc
Go to the documentation of this file.
1 
12 #include <utl/Particle.h>
13 #include <utl/AugerException.h>
14 
15 using namespace utl;
16 
17 
22 {
23  pParticleV::iterator cur = fParticles.begin();
24  pParticleV::iterator end = fParticles.end();
25  while (cur != end) {
26  delete *cur;
27  ++cur;
28  }
29 }
30 
31 
35 void
37 {
38  fParticles.push_back(new Particle(p));
39  fIteratorValid = false;
40 }
41 
42 
46 void
48 {
49  fCurrentParticle = fParticles.begin();
50  fSkipped = 0;
51  fIteratorValid = true;
52 }
53 
54 
58 Particle*
60 {
61  if (!fIteratorValid) {
62  throw IOFailureException("testShowerParticleFileIterator not valid");
63  }
64 
65  while (fSkipped < fSkipAtBeginning && fCurrentParticle != fParticles.end()) {
66  ++fCurrentParticle;
67  ++fSkipped;
68  }
69 
70  if (fCurrentParticle == fParticles.end()) {
71  fIteratorValid = false;
72  return 0;
73  } else {
74  return *fCurrentParticle++;
75  }
76 }
77 
78 // Configure (x)emacs for this file ...
79 // Local Variables:
80 // mode:c++
81 // compile-command: "make -C .. -k run-testParticleTests"
82 // End:
Describes a particle for Simulation.
Definition: Particle.h:26
Base class to report exceptions in IO.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
virtual void Rewind()
Rewind the particle list in the shower file to the beginning.
virtual utl::Particle * GetOneParticle(const utl::CoordinateSystemPtr &cs)
Member function to fetch the next particle.

, generated on Tue Sep 26 2023.