IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 08a7ef53 authored by ralfulrich's avatar ralfulrich
Browse files

documentation

parent c9523526
No related branches found
No related tags found
1 merge request!6848 particle creator
set ( set (
CORSIKAstackinterface_HEADERS CORSIKAstackinterface_HEADERS
Stack.h Stack.h
StackIterator.h StackIteratorInterface.h
ParticleBase.h ParticleBase.h
) )
......
...@@ -16,11 +16,8 @@ class StackData; // forward decl ...@@ -16,11 +16,8 @@ class StackData; // forward decl
namespace corsika::stack { namespace corsika::stack {
// template <typename> class PI;// : public ParticleBase<StackIteratorInterface> {
// template <typename, template <typename> typename> class Stack; // forward decl
/** /**
\class ParticleBase @class ParticleBase
The base class to define the readout of particle properties from a The base class to define the readout of particle properties from a
particle stack. Every stack must implement this readout via the particle stack. Every stack must implement this readout via the
...@@ -34,6 +31,7 @@ namespace corsika::stack { ...@@ -34,6 +31,7 @@ namespace corsika::stack {
ParticleBase() = default; ParticleBase() = default;
private: private:
// those copy constructors and assigments should never be implemented
ParticleBase(ParticleBase&) = delete; ParticleBase(ParticleBase&) = delete;
ParticleBase operator=(ParticleBase&) = delete; ParticleBase operator=(ParticleBase&) = delete;
ParticleBase(ParticleBase&&) = delete; ParticleBase(ParticleBase&&) = delete;
...@@ -42,30 +40,44 @@ namespace corsika::stack { ...@@ -42,30 +40,44 @@ namespace corsika::stack {
ParticleBase operator=(const ParticleBase&) = delete; ParticleBase operator=(const ParticleBase&) = delete;
public: public:
/// delete this particle on the stack. The corresponding iterator /** delete this particle on the stack. The corresponding iterator
/// will be invalidated by this operation * will be invalidated by this operation
*/
void Delete() { GetIterator().GetStack().Delete(GetIterator()); } void Delete() { GetIterator().GetStack().Delete(GetIterator()); }
/**
* Add a secondary particle based on *this on the stack @param
* args is a variadic list of input data that has to match the
* function description in the user defined ParticleInterface::AddSecondary(...)
*/
template <typename... Args> template <typename... Args>
StackIterator AddSecondary(const Args... v) { StackIterator AddSecondary(const Args... args) {
return GetStack().AddSecondary(GetIterator(), v...); return GetStack().AddSecondary(GetIterator(), args...);
} }
// protected: // todo should be proteced, but don't now how to 'friend Stack' // protected: // todo should [MAY]be proteced, but don't now how to 'friend Stack'
/// Function to provide CRTP access to inheriting class (type) // Function to provide CRTP access to inheriting class (type)
/**
* return the corresponding StackIterator for this particle
*/
StackIterator& GetIterator() { return static_cast<StackIterator&>(*this); } StackIterator& GetIterator() { return static_cast<StackIterator&>(*this); }
const StackIterator& GetIterator() const { const StackIterator& GetIterator() const {
return static_cast<const StackIterator&>(*this); return static_cast<const StackIterator&>(*this);
} }
protected: protected:
/// access to underling stack data /** @name Access to underlying stack data
@{
*/
auto& GetStackData() { return GetIterator().GetStackData(); } auto& GetStackData() { return GetIterator().GetStackData(); }
const auto& GetStackData() const { return GetIterator().GetStackData(); } const auto& GetStackData() const { return GetIterator().GetStackData(); }
auto& GetStack() { return GetIterator().GetStack(); } auto& GetStack() { return GetIterator().GetStack(); }
const auto& GetStack() const { return GetIterator().GetStack(); } const auto& GetStack() const { return GetIterator().GetStack(); }
///@}
/// return the index number of the underlying iterator object /**
* return the index number of the underlying iterator object
*/
int GetIndex() const { return GetIterator().GetIndex(); } int GetIndex() const { return GetIterator().GetIndex(); }
}; };
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
\endverbatim \endverbatim
All functionality and algorithms for stack data access is located in the namespace corsika::stack
The minimal example of how to use this is shown in stack_example.cc The minimal example of how to use this is shown in stack_example.cc
*/ */
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#ifndef _include_Stack_h__ #ifndef _include_Stack_h__
#define _include_Stack_h__ #define _include_Stack_h__
#include <corsika/stack/StackIterator.h> // include here, to help application programmres #include <corsika/stack/StackIteratorInterface.h>
#include <stdexcept> #include <stdexcept>
...@@ -22,8 +22,16 @@ ...@@ -22,8 +22,16 @@
namespace corsika::stack { namespace corsika::stack {
/**
This is just a forward declatation for the user-defined
ParticleInterface, which is one of the essential template
parameters for the Stack.
Important: ParticleInterface must inherit from ParticleBase !
*/
template <typename> template <typename>
class PI; // forward decl class ParticleInterface; // forward decl
/** /**
Interface definition of a Stack object. The Stack implements the Interface definition of a Stack object. The Stack implements the
...@@ -31,17 +39,17 @@ namespace corsika::stack { ...@@ -31,17 +39,17 @@ namespace corsika::stack {
loops etc. loops etc.
*/ */
template <typename StackData, template <typename> typename PI> template <typename StackData, template <typename> typename ParticleInterface>
class Stack : public StackData { class Stack : public StackData {
public: public:
typedef Stack<StackData, PI> StackType; typedef Stack<StackData, ParticleInterface> StackType;
typedef StackIteratorInterface<StackData, PI> StackIterator; typedef StackIteratorInterface<StackData, ParticleInterface> StackIterator;
typedef ConstStackIteratorInterface<StackData, PI> ConstStackIterator; typedef ConstStackIteratorInterface<StackData, ParticleInterface> ConstStackIterator;
// typedef const StackIterator ConstStackIterator; // typedef const StackIterator ConstStackIterator;
typedef typename StackIterator::ParticleInterfaceType ParticleType; typedef typename StackIterator::ParticleInterfaceType ParticleType;
friend class StackIteratorInterface<StackData, PI>; friend class StackIteratorInterface<StackData, ParticleInterface>;
friend class ConstStackIteratorInterface<StackData, PI>; friend class ConstStackIteratorInterface<StackData, ParticleInterface>;
public: public:
using StackData::GetCapacity; using StackData::GetCapacity;
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
* the license. * the license.
*/ */
#ifndef _include_StackIterator_h__ #ifndef _include_StackIteratorinterface_h__
#define _include_StackIterator_h__ #define _include_StackIteratorinterface_h__
#include <corsika/stack/ParticleBase.h> #include <corsika/stack/ParticleBase.h>
...@@ -112,9 +112,9 @@ namespace corsika::stack { ...@@ -112,9 +112,9 @@ namespace corsika::stack {
} }
public: public:
/** @name Iterator interface /** @name Iterator interface
*/ @{
///@{ */
StackIteratorInterface& operator++() { StackIteratorInterface& operator++() {
++fIndex; ++fIndex;
return *this; return *this;
......
/** /**
@mainpage CORSIKA air shower simulations framework
@mainpage CORSIKA 8 air shower simulations framework
Documentation and reference guide for the CORSIKA8 (CORSIKA version 8) Documentation and reference guide for the CORSIKA8 (CORSIKA version 8)
software framework for air shower simulations. CORSIKA8 is developed software framework for air shower simulations. CORSIKA8 is developed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment