20 template <
class T1,
template <
class>
class T2>
21 class DefaultSecondaryProducer;
61 template <
typename TStackDataType,
template <
typename>
typename TParticleInterface,
62 template <
typename T1,
template <
class>
class T2>
class MSecondaryProducer =
63 DefaultSecondaryProducer>
65 :
public Stack<TStackDataType&, TParticleInterface, MSecondaryProducer>,
66 public MSecondaryProducer<TStackDataType, TParticleInterface> {
87 TParticleInterface, MSecondaryProducer,
88 inner_stack_value_type>
92 typename std::remove_reference<TStackDataType>::type, TParticleInterface,
93 MSecondaryProducer, inner_stack_value_type>
97 typedef StackIteratorInterface<typename std::remove_reference<TStackDataType>::type,
98 TParticleInterface, MSecondaryProducer, view_type>
102 typename std::remove_reference<TStackDataType>::type, TParticleInterface,
103 MSecondaryProducer, view_type>
110 using ParticleInterfaceType =
typename stack_view_iterator::particle_interface_type;
116 template <
typename... TArgs>
125 :
Stack<TStackDataType&, TParticleInterface, MSecondaryProducer>(
126 particle.getStackData())
127 , MSecondaryProducer<TStackDataType, TParticleInterface>{particle}
128 , inner_stack_(particle.getStack())
129 , projectile_index_(particle.getIndex()) {
130 CORSIKA_LOG_TRACE(
"SecondaryView::SecondaryView(particle&)");
137 :
Stack<TStackDataType&, TParticleInterface, MSecondaryProducer>(
138 particle.getStackData())
139 , MSecondaryProducer<TStackDataType, TParticleInterface>{particle}
140 , inner_stack_(particle.getStack())
141 , projectile_index_(particle.getIndex()) {
142 CORSIKA_LOG_TRACE(
"SecondaryView::SecondaryView(particle&&)");
151 :
Stack<TStackDataType&, TParticleInterface,
152 MSecondaryProducer>{view.getStackData()}
153 , MSecondaryProducer<TStackDataType, TParticleInterface>{stack_value_iterator{
154 view.inner_stack_, view.getIndexFromIterator(projectile.getIndex())}}
155 , inner_stack_{view.inner_stack_}
156 , projectile_index_{view.getIndexFromIterator(projectile.getIndex())} {
157 CORSIKA_LOG_TRACE(
"SecondaryView::SecondaryView(view, projectile)");
165 stack_value_iterator parent()
167 return stack_value_iterator(inner_stack_, projectile_index_);
175 stack_value_iterator asNewParent()
const {
176 return stack_value_iterator(inner_stack_, projectile_index_);
183 stack_view_iterator getProjectile() {
185 return stack_view_iterator(*
this, 0);
192 const_stack_view_iterator getProjectile()
const {
194 return const_stack_view_iterator(*
this, 0);
200 template <
typename... Args>
206 unsigned int getSize()
const {
return indices_.size(); }
208 unsigned int getEntries()
const {
209 return getSize() - inner_stack_reference_type::getErased();
212 bool isEmpty()
const {
return getEntries() == 0; }
222 stack_view_iterator begin();
224 stack_view_iterator end() {
return stack_view_iterator(*
this,
getSize() + 1); }
226 stack_view_iterator last();
228 const_stack_view_iterator begin()
const;
230 const_stack_view_iterator end()
const {
231 return const_stack_view_iterator(*
this,
getSize() + 1);
234 const_stack_view_iterator last()
const;
236 const_stack_view_iterator cbegin()
const;
238 const_stack_view_iterator cend()
const {
239 return const_stack_view_iterator(*
this,
getSize());
242 const_stack_view_iterator clast()
const;
244 stack_view_iterator at(
unsigned int i) {
return stack_view_iterator(*
this, i); }
246 const_stack_view_iterator at(
unsigned int i)
const {
247 return const_stack_view_iterator(*
this, i);
250 stack_view_iterator first() {
return stack_view_iterator{*
this, 0}; }
252 const_stack_view_iterator cfirst()
const {
253 return const_stack_view_iterator{*
this, 0};
257 void swap(stack_view_iterator a, stack_view_iterator b);
259 void copy(stack_view_iterator a, stack_view_iterator b);
261 void copy(const_stack_view_iterator a, stack_view_iterator b);
275 void erase(stack_view_iterator p);
292 bool isErased(
const stack_view_iterator& p)
const {
296 bool isErased(
const const_stack_view_iterator& p)
const {
302 bool isErased(
const ParticleInterfaceType& p)
const {
306 bool isDeleted(
const const_stack_view_iterator& p)
const {
307 return isDeleted(p.getIndex() - 1);
326 std::string asString()
const;
330 typename std::remove_reference<TStackDataType>::type, TParticleInterface,
331 MSecondaryProducer, view_type>;
334 typename std::remove_reference<TStackDataType>::type, TParticleInterface,
335 MSecondaryProducer, view_type>;
348 template <typename... Args>
349 stack_view_iterator addSecondary(stack_view_iterator& proj, const Args... v);
353 bool
isErased(unsigned int i) const {
354 if (i >= indices_.size())
return false;
366 if (vI == 0)
return projectile_index_;
367 return indices_[vI - 1];
371 inner_stack_value_type& inner_stack_;
372 unsigned int projectile_index_;
373 std::vector<unsigned int> indices_;
384 #if not defined(__clang__) && defined(__GNUC__) || defined(__GNUG__) 385 template <
typename TStack,
386 template <
class TStack_,
template <
class>
class pi_type_>
388 template <
typename>
typename pi_type_ = TStack::template pi_type>
397 #include <corsika/detail/framework/stack/SecondaryView.inl> void erase(stack_view_iterator p)
need overwrite Stack::Delete, since we want to call SecondaryView::DeleteLast
SecondaryView(stack_value_iterator &&particle)
SecondaryView can only be constructed passing it a valid stack_view_iterator to another Stack object ...
The Stack class provides (and connects) the main particle data storage machinery. ...
CORSIKA8 logging utilities.
SecondaryView(view_type &view, stack_view_iterator &projectile)
Also allow to create a new View from a Projectile (stack_view_iterator on View)
Description of particle stacks.
stack_view_iterator getNextParticle()
return next particle from stack, need to overwrtie Stack::getNextParticle to get right reference ...
bool purgeLastIfDeleted()
Function to ultimatively remove the last entry from the stack, if it was marked as deleted before...
bool isErased(const stack_view_iterator &p) const
check if this particle was already deleted
unsigned int getIndex() const
Get current particle index.
SecondaryView(stack_value_iterator &particle)
SecondaryView can only be constructed passing it a valid stack_view_iterator to another Stack object ...
void purge()
Function to ultimatively remove all entries from the stack marked as deleted.
`, since they are used everywhere as integral part of the framework.
unsigned int getSize() const
overwrite Stack::getSize to return actual number of secondaries
unsigned int getIndexFromIterator(const unsigned int vI) const
We only want to 'see' secondaries indexed in indices_.
stack_view_iterator addSecondary(stack_view_iterator &proj, const Args... v)
Overwrite of Stack::stack_view_iterator.
SecondaryView can only be constructed by giving a valid Projectile particle, following calls to addSe...
Class to handle the generation of new secondaries.
bool isErased(const ParticleInterfaceType &p) const
delete this particle
The base class to define the readout of particle properties from a particle stack.
Stack< TStackDataType &, TParticleInterface, MSecondaryProducer > inner_stack_reference_type
Helper type for inside this class.
This is the iterator class for const-access to stack data.
The StackIteratorInterface is the main interface to iterator over particles on a stack.