12 #include <corsika/framework/stack/StackIteratorInterface.hpp> 13 #include <corsika/framework/stack/DefaultSecondaryProducer.hpp> 14 #include <corsika/framework/stack/SecondaryView.hpp> 20 #include <type_traits> 74 template <
typename TStackData,
template <
typename>
typename MParticleInterface,
75 template <
typename T1,
template <
class>
class T2>
class MSecondaryProducer =
76 DefaultSecondaryProducer>
79 typedef typename std::remove_reference<TStackData>::type value_type;
88 template <
typename TStackIterator>
89 using pi_type = MParticleInterface<TStackIterator>;
103 MSecondaryProducer,
Stack>
123 , deleted_(
std::vector<bool>(data_.getSize(), false)) {}
134 template <
typename UType = TStackData,
135 typename =
typename std::enable_if<std::is_reference<UType>::value>::type>
139 , deleted_(
std::vector<bool>(data_.getSize(), false)) {}
150 template <
typename... TArgs,
typename UType = TStackData,
151 typename =
typename std::enable_if<std::is_reference<UType>::value>::type>
155 , deleted_(
std::vector<bool>(data_.getSize(), false)) {}
161 unsigned int getCapacity()
const {
return data_.getCapacity(); }
163 unsigned int getErased()
const {
return nDeleted_; }
165 unsigned int getEntries()
const {
return getSize() - getErased(); }
167 template <
typename... TArgs>
168 void clear(TArgs... args);
181 const_stack_iterator_type begin()
const;
183 const_stack_iterator_type end()
const;
185 const_stack_iterator_type last()
const;
187 const_stack_iterator_type cbegin()
const;
189 const_stack_iterator_type cend()
const;
191 const_stack_iterator_type clast()
const;
195 const_stack_iterator_type at(
unsigned int i)
const;
199 const_stack_iterator_type cfirst()
const;
206 template <
typename... TArgs>
220 void erase(particle_interface_type p);
233 bool isErased(
const const_stack_iterator_type& p)
const;
235 bool isErased(
const particle_interface_type& p)
const;
254 unsigned int getSize()
const;
256 std::string asString()
const;
266 template <
typename... TArgs>
269 void swap(
unsigned int const a,
unsigned int const b);
271 void copy(
unsigned int const a,
unsigned int const b);
273 bool isErased(
unsigned int const i)
const;
275 void erase(
unsigned int const i);
281 void purge(
unsigned int i);
295 value_type& getStackData();
297 const value_type& getStackData()
const;
300 MSecondaryProducer, Stack>;
302 MSecondaryProducer, Stack>;
303 template <
typename T1,
304 template <
typename>
typename M1,
305 template <
class T2,
template <
class>
class T3>
class M2>
306 friend class SecondaryView;
311 unsigned int nDeleted_ = 0;
315 std::vector<bool> deleted_;
320 #include <corsika/detail/framework/stack/Stack.inl> bool isEmpty()
check if there are no further non-deleted particles on stack
Stack(TStackData vD)
if TStackData is a reference member we HAVE to initialize it in the constructor, this is typically ne...
void purge()
Function to ultimatively remove all entries from the stack marked as deleted.
Stack(TArgs... args)
This constructor takes any argument and passes it on to the TStackData user class.
StackIteratorInterface< value_type, MParticleInterface, MSecondaryProducer, Stack > stack_iterator_type
Via the StackIteratorInterface and ConstStackIteratorInterface specialization, the type of the stack_...
Stack()
create a new Stack, if there is already data associated prepare needed initialization.
The Stack class provides (and connects) the main particle data storage machinery. ...
bool purgeLastIfDeleted()
Function to ultimatively remove the last entry from the stack, if it was marked as deleted before...
stack_iterator_type::particle_interface_type particle_interface_type
this is the full type of the user-declared MParticleInterface
CORSIKA8 logging utilities.
TStackData stack_data_type
this is the type of the user-provided data structure
`, since they are used everywhere as integral part of the framework.
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 ...
bool isErased(const stack_iterator_type &p) const
check if this particle was already deleted
SecondaryView can only be constructed by giving a valid Projectile particle, following calls to addSe...
unsigned int getIndexFromIterator(const unsigned int vI) const
Function to perform eventual transformation from StackIterator::getIndex() to index in data stored in...
stack_iterator_type addParticle(const TArgs... v)
increase stack size, create new particle at end of stack
The base class to define the readout of particle properties from a particle stack.
Stack & operator=(Stack &)=delete
since Stack can be very big, we don't want to copy it
This is the iterator class for const-access to stack data.
The StackIteratorInterface is the main interface to iterator over particles on a stack.
stack_iterator_type particle_type
In all programming context, the object to access, copy, and transport particle data is via the stack_...