CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType > Class Template Reference

The StackIteratorInterface is the main interface to iterator over particles on a stack. More...

#include <StackIteratorInterface.hpp>

Inheritance diagram for corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >:

Public Types

typedef TParticleInterface< corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType > > particle_interface_type
 
typedef TStackType stack_type
 
typedef TStackData stack_data_type
 

Public Member Functions

 StackIteratorInterface (StackIteratorInterface &&rhs)
 
 StackIteratorInterface (StackIteratorInterface const &vR)
 
StackIteratorInterfaceoperator= (StackIteratorInterface const &vR)
 
 StackIteratorInterface (stack_type &data, unsigned int const index)
 Iterator must always point to data, with an index. More...
 
template<typename... TArgs>
 StackIteratorInterface (stack_type &data, unsigned int const index, const TArgs... args)
 Constructor that also sets new values on particle data object. More...
 
template<typename... TArgs>
 StackIteratorInterface (stack_type &data, unsigned int const index, StackIteratorInterface &parent, const TArgs... args)
 Constructor that also sets new values on particle data object, including reference to parent particle. More...
 
bool isErased () const
 
Iterator interface
StackIteratorInterfaceoperator++ ()
 
StackIteratorInterface operator++ (int)
 
StackIteratorInterface operator+ (int delta) const
 
bool operator== (StackIteratorInterface const &rhs) const
 
bool operator!= (StackIteratorInterface const &rhs) const
 
bool operator== (const ConstStackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, stack_type > &rhs) const
 
bool operator!= (const ConstStackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, stack_type > &rhs) const
 
particle_interface_type & operator* ()
 Convert iterator to value type, where value type is the user-provided particle readout class.
 
particle_interface_type const & operator* () const
 Convert iterator to const value type, where value type is the user-provided particle readout class.
 

Protected Member Functions

Stack data access
unsigned int getIndex () const
 Get current particle index.
 
stack_type & getStack ()
 Get current particle Stack object.
 
stack_type const & getStack () const
 Get current particle const Stack object.
 
TStackData & getStackData ()
 Get current user particle TStackData object.
 
TStackData const & getStackData () const
 Get current const user particle TStackData object.
 
unsigned int getIndexFromIterator () const
 Get data index as mapped in Stack class.
 

Protected Attributes

unsigned int index_ = 0
 

Friends

class Stack< TStackData, TParticleInterface, MSecondaryProducer >
 
class Stack< TStackData &, TParticleInterface, MSecondaryProducer >
 
class ParticleBase< StackIteratorInterface >
 
template<typename T1 , template< typename > typename M1, template< typename T, template< typename > typename T3 > typename M2>
class SecondaryView
 
template<typename T , template< typename > typename TParticleInterface_>
class corsika::history::HistorySecondaryProducer
 
class ConstStackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, stack_type >
 

Detailed Description

template<typename TStackData, template< typename > typename TParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer, typename TStackType = Stack<TStackData, TParticleInterface, MSecondaryProducer>>
class corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >

The StackIteratorInterface is the main interface to iterator over particles on a stack.

At the same time StackIteratorInterface is a Particle object by itself, thus there is no difference between type and ref_type for convenience of the physicist.

This allows to write code like:

for (auto& p : theStack) {
p.setEnergy(newEnergy);
}

The template argument Stack determines the type of Stack object the data is stored in. A pointer to the Stack object is part of the StackIteratorInterface. In addition to Stack the iterator only knows the index index_ in the Stack data.

The template argument TParticleInterface acts as a policy to provide readout function of Particle data from the stack. The TParticleInterface class must know how to retrieve information from the Stack data for a particle entry at any index index_.

The TParticleInterface class must be written and provided by the user, it contains methods like auto getData() const { return getStackData().getData(getIndex()); }, where StackIteratorInterface::getStackData() return a reference to the object storing the particle data of type TStackData. And StackIteratorInterface::getIndex() provides the iterator index to be readout. The TStackData is another user-provided class to store data and must implement functions compatible with TParticleInterface, in this example TStackData::getData(const unsigned int vIndex).

For two examples see stack_example.cc, or the corsika::sibyll::SibStack class.

Definition at line 79 of file StackIteratorInterface.hpp.

Constructor & Destructor Documentation

◆ StackIteratorInterface() [1/4]

template<typename TStackData , template< typename > typename TParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer, typename TStackType = Stack<TStackData, TParticleInterface, MSecondaryProducer>>
corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >::StackIteratorInterface ( StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType > &&  rhs)
inline
Todo:
check rule of five

Definition at line 94 of file StackIteratorInterface.hpp.

◆ StackIteratorInterface() [2/4]

template<typename TStackData , template< typename > typename TParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer, typename TStackType = Stack<TStackData, TParticleInterface, MSecondaryProducer>>
corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >::StackIteratorInterface ( stack_type &  data,
unsigned int const  index 
)
inline

Iterator must always point to data, with an index.

Parameters
datareference to the stack [rw]
indexindex on stack

Definition at line 116 of file StackIteratorInterface.hpp.

◆ StackIteratorInterface() [3/4]

template<typename TStackData , template< typename > typename TParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer, typename TStackType = Stack<TStackData, TParticleInterface, MSecondaryProducer>>
template<typename... TArgs>
corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >::StackIteratorInterface ( stack_type &  data,
unsigned int const  index,
const TArgs...  args 
)
inline

Constructor that also sets new values on particle data object.

Parameters
datareference to the stack [rw].
indexindex on stack.
argsvariadic list of data to initialize stack entry, this must be consistent with the definition of the user-provided particle_interface_type::setParticleData(...) function.

Definition at line 130 of file StackIteratorInterface.hpp.

◆ StackIteratorInterface() [4/4]

template<typename TStackData , template< typename > typename TParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer, typename TStackType = Stack<TStackData, TParticleInterface, MSecondaryProducer>>
template<typename... TArgs>
corsika::StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType >::StackIteratorInterface ( stack_type &  data,
unsigned int const  index,
StackIteratorInterface< TStackData, TParticleInterface, MSecondaryProducer, TStackType > &  parent,
const TArgs...  args 
)
inline

Constructor that also sets new values on particle data object, including reference to parent particle.

Parameters
datareference to the stack [rw]
indexindex on stack
parentto parent particle [rw]. This can be used for thinning, particle counting, history, etc.
argsvariadic list of data to initialize stack entry, this must be consistent with the definition of the user-provided particle_interface_type::setParticleData(...) function.

Definition at line 151 of file StackIteratorInterface.hpp.


The documentation for this class was generated from the following file: