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

The Stack class provides (and connects) the main particle data storage machinery. More...

#include <Stack.hpp>

Inheritance diagram for corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >:

Public Types

typedef TStackData stack_data_type
 this is the type of the user-provided data structure
 
typedef SecondaryView< TStackData, MParticleInterface, MSecondaryProducer > stack_view_type
 
template<typename TStackIterator >
using pi_type = MParticleInterface< TStackIterator >
 
typedef StackIteratorInterface< value_type, MParticleInterface, MSecondaryProducer, Stackstack_iterator_type
 Via the StackIteratorInterface and ConstStackIteratorInterface specialization, the type of the stack_iterator_type template class is declared for a particular stack data object. More...
 
typedef ConstStackIteratorInterface< value_type, MParticleInterface, MSecondaryProducer, Stackconst_stack_iterator_type
 
typedef stack_iterator_type::particle_interface_type particle_interface_type
 this is the full type of the user-declared MParticleInterface
 
typedef stack_iterator_type particle_type
 In all programming context, the object to access, copy, and transport particle data is via the stack_iterator_type.
 

Public Member Functions

 Stack ()
 create a new Stack, if there is already data associated prepare needed initialization.
 
 Stack (Stack &)=delete
 since Stack can be very big, we don't want to copy it
 
Stackoperator= (Stack &)=delete
 since Stack can be very big, we don't want to copy it
 
template<typename UType = TStackData, typename = typename std::enable_if<std::is_reference<UType>::value>::type>
 Stack (TStackData vD)
 if TStackData is a reference member we HAVE to initialize it in the constructor, this is typically needed for SecondaryView
 
template<typename... TArgs, typename UType = TStackData, typename = typename std::enable_if<std::is_reference<UType>::value>::type>
 Stack (TArgs... args)
 This constructor takes any argument and passes it on to the TStackData user class. More...
 
Most generic proxy methods for TStackData data_
unsigned int getCapacity () const
 
unsigned int getErased () const
 
unsigned int getEntries () const
 
template<typename... TArgs>
void clear (TArgs... args)
 

These are functions required by std containers and std loops

stack_iterator_type begin ()
 
stack_iterator_type end ()
 
stack_iterator_type last ()
 
const_stack_iterator_type begin () const
 
const_stack_iterator_type end () const
 
const_stack_iterator_type last () const
 
const_stack_iterator_type cbegin () const
 
const_stack_iterator_type cend () const
 
const_stack_iterator_type clast () const
 
stack_iterator_type at (unsigned int i)
 
const_stack_iterator_type at (unsigned int i) const
 
stack_iterator_type first ()
 
const_stack_iterator_type cfirst () const
 
stack_iterator_type getNextParticle ()
 
template<typename... TArgs>
stack_iterator_type addParticle (const TArgs... v)
 increase stack size, create new particle at end of stack
 
void swap (stack_iterator_type a, stack_iterator_type b)
 
void copy (stack_iterator_type a, stack_iterator_type b)
 
void copy (const_stack_iterator_type a, stack_iterator_type b)
 
void erase (stack_iterator_type p)
 
void erase (particle_interface_type p)
 delete this particle
 
bool isEmpty ()
 check if there are no further non-deleted particles on stack
 
bool isErased (const stack_iterator_type &p) const
 check if this particle was already deleted
 
bool isErased (const const_stack_iterator_type &p) const
 
bool isErased (const particle_interface_type &p) const
 
bool purgeLastIfDeleted ()
 Function to ultimatively remove the last entry from the stack, if it was marked as deleted before. More...
 
void purge ()
 Function to ultimatively remove all entries from the stack marked as deleted. More...
 
unsigned int getSize () const
 
std::string asString () const
 
template<typename... TArgs>
stack_iterator_type addSecondary (stack_iterator_type &parent, const TArgs... v)
 increase stack size, create new particle at end of stack, related to parent particle/projectile More...
 
void swap (unsigned int const a, unsigned int const b)
 
void copy (unsigned int const a, unsigned int const b)
 
bool isErased (unsigned int const i) const
 
void erase (unsigned int const i)
 
void purge (unsigned int i)
 will remove from storage the element i. More...
 
unsigned int getIndexFromIterator (const unsigned int vI) const
 Function to perform eventual transformation from StackIterator::getIndex() to index in data stored in TStackData data_. More...
 

Return reference to TStackData object data_ for data access

class StackIteratorInterface< value_type, MParticleInterface, MSecondaryProducer, Stack >
 
class ConstStackIteratorInterface< value_type, MParticleInterface, MSecondaryProducer, Stack >
 
template<typename T1 , template< typename > typename M1, template< class T2, template< class > class T3 > class M2>
class SecondaryView
 
class ParticleBase< stack_iterator_type >
 
unsigned int nDeleted_ = 0
 
value_type & getStackData ()
 
const value_type & getStackData () const
 

Detailed Description

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
class corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >

The Stack class provides (and connects) the main particle data storage machinery.

The StackDataType type is the user-provided bare data storage object. This can be of any complexity, from a simple struct (fortran common block), to a combination of different and distributed data sources.

The user-provided ParticleInterface template type is the base class type of the StackIteratorInterface class (CRTP) and must provide all functions to read single particle data from the StackDataType, given an 'unsigned int' index.

Important: ParticleInterface must inherit from ParticleBase.

The Stack implements the std-type begin/end function to allow integration in normal for loops, ranges, etc.

The template argument MSecondaryProducer is only needed because of gitlab Issue 161

Due to a limitation of clang the corsika::MakeView does not work. Thus, MSecondaryProducer is needed here to fully define a SecondaryView class.

Definition at line 77 of file Stack.hpp.

Member Typedef Documentation

◆ stack_iterator_type

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
typedef StackIteratorInterface<value_type, MParticleInterface, MSecondaryProducer, Stack> corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::stack_iterator_type

Via the StackIteratorInterface and ConstStackIteratorInterface specialization, the type of the stack_iterator_type template class is declared for a particular stack data object.

Using CRTP, this also determines the type of MParticleInterface template class simultaneously.

Definition at line 100 of file Stack.hpp.

Constructor & Destructor Documentation

◆ Stack()

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
template<typename... TArgs, typename UType = TStackData, typename = typename std::enable_if<std::is_reference<UType>::value>::type>
corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::Stack ( TArgs...  args)
inline

This constructor takes any argument and passes it on to the TStackData user class.

If the user did not provide a suited constructor this will fail with an error message.

Furthermore, this is disabled with enable_if for SecondaryView stacks, where the inner data container is always a reference and cannot be initialized here.

Definition at line 152 of file Stack.hpp.

Member Function Documentation

◆ addSecondary()

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
template<typename... TArgs>
stack_iterator_type corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::addSecondary ( stack_iterator_type parent,
const TArgs...  v 
)
protected

increase stack size, create new particle at end of stack, related to parent particle/projectile

This should only get internally called from a StackIterator::addSecondary via ParticleBase

◆ getIndexFromIterator()

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
unsigned int corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::getIndexFromIterator ( const unsigned int  vI) const
protected

Function to perform eventual transformation from StackIterator::getIndex() to index in data stored in TStackData data_.

By default (and in almost all cases) this should just be identiy. See class SecondaryView for an alternative implementation.

◆ purge() [1/2]

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
void corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::purge ( )

Function to ultimatively remove all entries from the stack marked as deleted.

Careful: this will re-order the entries on the stack, since "gaps" in the stack are filled with entries from the back (copied).

◆ purge() [2/2]

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
void corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::purge ( unsigned int  i)
protected

will remove from storage the element i.

This is a helper function for SecondaryView.

◆ purgeLastIfDeleted()

template<typename TStackData, template< typename > typename MParticleInterface, template< typename T1, template< class > class T2 > class MSecondaryProducer = DefaultSecondaryProducer>
bool corsika::Stack< TStackData, MParticleInterface, MSecondaryProducer >::purgeLastIfDeleted ( )

Function to ultimatively remove the last entry from the stack, if it was marked as deleted before.

If this is not the case, the function will just return false and do nothing.


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