IAP GITLAB

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AirShowerPhysics/corsika
  • rulrich/corsika
  • AAAlvesJr/corsika
  • Andre/corsika
  • arrabito/corsika
  • Nikos/corsika
  • olheiser73/corsika
  • AirShowerPhysics/papers/corsika
  • pranav/corsika
9 results
Show changes
Showing
with 0 additions and 1004 deletions
set (GEOMETRY_SOURCES CoordinateSystem.cc)
set (GEOMETRY_HEADERS Vector.h Point.h Sphere.h CoordinateSystem.h)
add_library (CORSIKAgeometry STATIC ${GEOMETRY_SOURCES})
set_target_properties (CORSIKAgeometry PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties (CORSIKAgeometry PROPERTIES SOVERSION 1)
set_target_properties (CORSIKAgeometry PROPERTIES PUBLIC_HEADER "${GEOMETRY_HEADERS}")
# target dependencies on other libraries (also header only)
target_link_libraries (CORSIKAgeometry CORSIKAunits)
target_include_directories (CORSIKAgeometry PRIVATE ${EIGEN3_INCLUDE_DIR})
target_include_directories (CORSIKAgeometry INTERFACE ${EIGEN3_INCLUDE_DIR})
target_include_directories (CORSIKAgeometry INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (TARGETS CORSIKAgeometry
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/Geometry)
# code testing
add_executable (testGeometry testGeometry.cc)
target_link_libraries (testGeometry CORSIKAgeometry CORSIKAunits CORSIKAthirdparty) # for catch2
add_test (NAME testGeometry COMMAND testGeometry -o report.xml -r junit)
#include <Geometry/CoordinateSystem.h>
EigenTransform CoordinateSystem::getTransformation(CoordinateSystem const& c1, CoordinateSystem const& c2)
{
CoordinateSystem const* a{&c1};
CoordinateSystem const* b{&c2};
CoordinateSystem const* commonBase{nullptr};
while (a != b && b != nullptr)
{
a = &c1;
while (a != b && a != nullptr)
{
a = a->getReference();
}
if (a == b)
break;
b = b->getReference();
}
if (a == b && a != nullptr)
{
commonBase = a;
}
else
{
throw std::string("no connection between coordinate systems found!");
}
EigenTransform t = EigenTransform::Identity();
auto* p = &c1;
while (p != commonBase)
{
t = p->getTransform() * t;
p = p->getReference();
}
p = &c2;
while (p != commonBase)
{
t = p->getTransform().inverse(Eigen::TransformTraits::Isometry) * t;
p = p->getReference();
}
return t;
}
#ifndef _include_COORDINATESYSTEM_H_
#define _include_COORDINATESYSTEM_H_
#include <Geometry/QuantityVector.h>
#include <Units/PhysicalUnits.h>
#include <Eigen/Dense>
typedef Eigen::Transform<double, 3, Eigen::Affine> EigenTransform;
typedef Eigen::Translation<double, 3> EigenTranslation;
class CoordinateSystem
{
CoordinateSystem const* reference = nullptr;
EigenTransform transf;
CoordinateSystem(CoordinateSystem const& reference, EigenTransform const& transf) :
reference(&reference),
transf(transf)
{
}
public:
static EigenTransform getTransformation(CoordinateSystem const& c1, CoordinateSystem const& c2);
CoordinateSystem() : // for creating the root CS
transf(EigenTransform::Identity())
{
}
auto& operator=(const CoordinateSystem& pCS)
{
reference = pCS.reference;
transf = pCS.transf;
return *this;
}
auto translate(QuantityVector<phys::units::length_d> vector) const
{
EigenTransform const translation{EigenTranslation(vector.eVector)};
return CoordinateSystem(*this, translation);
}
auto rotate(QuantityVector<phys::units::length_d> axis, double angle) const
{
EigenTransform const rotation{Eigen::AngleAxisd(M_PI / 6, axis.eVector.normalized())};
return CoordinateSystem(*this, rotation);
}
auto translateAndRotate(QuantityVector<phys::units::length_d> translation, QuantityVector<phys::units::length_d> axis, double angle)
{
EigenTransform const transf{Eigen::AngleAxisd(M_PI / 6, axis.eVector.normalized()) * EigenTranslation(translation.eVector)};
return CoordinateSystem(*this, transf);
}
auto const* getReference() const
{
return reference;
}
auto const& getTransform() const
{
return transf;
}
};
#endif
#ifndef _include_POINT_H_
#define _include_POINT_H_
#include <Geometry/BaseVector.h>
#include <Geometry/QuantityVector.h>
#include <Geometry/Vector.h>
#include <Units/PhysicalUnits.h>
class Point : public BaseVector<phys::units::length_d>
{
using Length = phys::units::quantity<phys::units::length_d, double>;
public:
Point(CoordinateSystem const& pCS, QuantityVector<phys::units::length_d> pQVector) :
BaseVector<phys::units::length_d>(pCS, pQVector)
{
}
Point(CoordinateSystem const& cs, Length x, Length y, Length z) :
BaseVector<phys::units::length_d>(cs, {x, y, z})
{
}
auto getCoordinates() const
{
return BaseVector<phys::units::length_d>::qVector;
}
auto getCoordinates(CoordinateSystem const& pCS) const
{
if (&pCS == BaseVector<phys::units::length_d>::cs)
{
return BaseVector<phys::units::length_d>::qVector;
}
else
{
return QuantityVector<phys::units::length_d>(CoordinateSystem::getTransformation(*BaseVector<phys::units::length_d>::cs, pCS) * BaseVector<phys::units::length_d>::qVector.eVector);
}
}
void rebase(CoordinateSystem const& pCS)
{
BaseVector<phys::units::length_d>::qVector = getCoordinates(pCS);
BaseVector<phys::units::length_d>::cs = &pCS;
}
Point operator+(Vector<phys::units::length_d> const& pVec) const
{
return Point(*BaseVector<phys::units::length_d>::cs, getCoordinates() + pVec.getComponents(*BaseVector<phys::units::length_d>::cs));
}
Vector<phys::units::length_d> operator-(Point const& pB) const
{
auto& cs = *BaseVector<phys::units::length_d>::cs;
return Vector<phys::units::length_d>(cs, getCoordinates() - pB.getCoordinates(cs));
}
};
#endif
#ifndef _include_QUANTITYVECTOR_H_
#define _include_QUANTITYVECTOR_H_
#include <Units/PhysicalUnits.h>
#include <Eigen/Dense>
#include <iostream>
template <typename dim>
class QuantityVector
{
protected:
using Quantity = phys::units::quantity<dim, double>;
using QuantitySquared = decltype(Quantity(phys::units::detail::magnitude_tag, 0) * Quantity(phys::units::detail::magnitude_tag, 0));
public:
Eigen::Vector3d eVector;
QuantityVector(Quantity a, Quantity b, Quantity c) :
eVector{a.magnitude(), b.magnitude(), c.magnitude()}
{
}
QuantityVector(Eigen::Vector3d pBareVector) :
eVector(pBareVector)
{
}
auto operator[](size_t index) const
{
return Quantity(phys::units::detail::magnitude_tag, eVector[index]);
}
auto norm() const
{
return Quantity(phys::units::detail::magnitude_tag, eVector.norm());
}
auto squaredNorm() const
{
return QuantitySquared(phys::units::detail::magnitude_tag, eVector.squaredNorm());
}
auto operator+(QuantityVector<dim> const& pQVec) const
{
return QuantityVector<dim>(eVector + pQVec.eVector);
}
auto operator-(QuantityVector<dim> const& pQVec) const
{
return QuantityVector<dim>(eVector - pQVec.eVector);
}
//auto operator*(
};
template <typename dim>
auto& operator<<(std::ostream& os, QuantityVector<dim> qv)
{
os << '(' << qv.eVector(0) << ' ' << qv.eVector(1) << ' ' << qv.eVector(2)
<< ") " << phys::units::to_unit_symbol(phys::units::quantity<dim, double>());
return os;
}
#endif
#ifndef _include_SPHERE_H_
#define _include_SPHERE_H_
#include <Geometry/Point.h>
#include <Units/PhysicalUnits.h>
class Sphere
{
using Length = phys::units::quantity<phys::units::length_d, double>;
Point center;
Length const radius;
public:
Sphere(Point const& pCenter, Length const pRadius) :
center(pCenter), radius(pRadius)
{
}
auto isInside(Point const& p) const
{
return radius*radius > (center - p).squaredNorm();
}
};
#endif
#ifndef _include_VECTOR_H_
#define _include_VECTOR_H_
#include <Geometry/BaseVector.h>
#include <Geometry/QuantityVector.h>
#include <Units/PhysicalUnits.h>
template <typename dim>
class Vector : public BaseVector<dim>
{
using Quantity = phys::units::quantity<dim, double>;
public:
Vector(CoordinateSystem const& pCS, QuantityVector<dim> pQVector) :
BaseVector<dim>(pCS, pQVector)
{
}
Vector(CoordinateSystem const& cs, Quantity x, Quantity y, Quantity z) :
BaseVector<dim>(cs, QuantityVector<dim>(x, y, z))
{
}
auto getComponents() const
{
return BaseVector<dim>::qVector;
}
auto getComponents(CoordinateSystem const& pCS) const
{
if (&pCS == BaseVector<dim>::cs)
{
return BaseVector<dim>::qVector;
}
else
{
return QuantityVector<dim>(CoordinateSystem::getTransformation(*BaseVector<dim>::cs, pCS).linear() * BaseVector<dim>::qVector.eVector);
}
}
void rebase(CoordinateSystem const& pCS)
{
BaseVector<dim>::qVector = getComponents(pCS);
BaseVector<dim>::cs = &pCS;
}
auto norm() const
{
return BaseVector<dim>::qVector.norm();
}
auto squaredNorm() const
{
return BaseVector<dim>::qVector.squaredNorm();
}
template <typename dim2>
auto parallelProjectionOnto(BaseVector<dim2> const& pVec, CoordinateSystem const& pCS) const
{
auto const ourCompVec = getComponents(pCS);
auto const otherCompVec = pVec.getComponents(pVec);
auto const& a = ourCompVec.eVector;
auto const& b = otherCompVec.eVector;
return Vector<dim>(pCS, (a * b) / b.squaredNorm() * b);
}
template <typename dim2>
auto parallelProjectionOnto(BaseVector<dim2> const& pVec)
{
return parallelProjectionOnto<dim2>(pVec, *BaseVector<dim>::cs);
}
//~ template <typename dim2>
//~ auto operator*(Vector<dim2> const& pVec)
//~ {
//~ auto constexpr resulting_dim = dimension
//~ return Vector<
//~ }
};
#endif
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include <catch2/catch.hpp>
#include <Units/PhysicalUnits.h>
using namespace phys::units;
TEST_CASE( "PhysicalUnits", "[Units]" )
{
SECTION( "sectionOne" )
{
REQUIRE( 1_m/1_m == 1 );
}
SECTION( "sectionTwo" )
{
REQUIRE_FALSE( 1_m/1_m == 2 );
}
SECTION( "sectionThree" )
{
REQUIRE( 1_s/1_s == 2 );
}
}
add_library (CORSIKAlogging INTERFACE)
target_include_directories (CORSIKAlogging INTERFACE ${PROJECT_SOURCE_DIR}/Framework)
target_include_directories (CORSIKAlogging INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (FILES Logger.h
DESTINATION include/Logging)
#ifndef _include_logger_h_
#define _include_logger_h_
#include <string>
#include <sstream>
#include <iostream>
#include <typeinfo>
#include <fstream>
#include <boost/format.hpp>
using namespace std;
using namespace boost;
class MessageOff {
protected:
template<typename First, typename ... Strings> std::string message(const First& arg, const Strings&... rest) {
return "";
}
};
class messageconst {
protected:
std::string message() { return "\n"; }
template<typename First, typename ... Strings> std::string message(const First& arg, const Strings&... rest) {
std::ostringstream ss;
ss << arg << message(rest...);
return ss.str();
}
template<typename ... Strings> std::string message(const int& arg, const Strings&... rest) {
return std::to_string(arg) + message(rest...);
}
template<typename ... Strings> std::string message(const double& arg, const Strings&... rest) {
return std::to_string(arg) + message(rest...);
}
template<typename ... Strings> std::string message(char const * arg, const Strings&... rest) {
return std::string(arg) + message(rest...);
}
template<typename ... Strings> std::string message(const std::string& arg, const Strings&... rest) {
return arg + message(rest...);
}
// ----------------------
// boost format
template<typename ... Strings> std::string message(const boost::format& fmt, const Strings&... rest) {
boost::format FMT(fmt);
return bformat(FMT, rest...);
}
template<typename Arg, typename ... Strings> std::string bformat(boost::format& fmt, const Arg& arg, const Strings&... rest) {
fmt % arg;
return bformat(fmt, rest...);
}
std::string bformat(boost::format& fmt) { return fmt.str() + "\n"; }
};
struct NoBuffer {
inline bool Test(const std::string&) const { return false; }
inline std::string GetString() const { return std::string(""); }
inline void Clear() {}
inline void Add(const std::string&) {}
};
struct StdBuffer {
StdBuffer(const int size) : fSize(size) {}
inline bool Test(const std::string& s) { return int(fBuffer.tellp())+s.length() < fSize; }
inline std::string GetString() const { return fBuffer.str(); }
inline void Clear() { fBuffer.str(""); }
inline void Add(const std::string& s) { fBuffer << s; }
private:
int fSize;
std::ostringstream fBuffer;
};
template<typename TStream, typename TBuffer=StdBuffer>
class Sink {
public:
Sink(TStream& out, TBuffer buffer = {} ) : fOutput(out), fBuffer(std::move(buffer)) {}
void operator<<(const std::string& msg) {
if (!fBuffer.Test(msg)) {
fOutput << fBuffer.GetString();
fBuffer.Clear();
}
if (!fBuffer.Test(msg))
fOutput << msg;
else
fBuffer.Add(msg);
}
void Close() { fOutput << fBuffer.GetString(); }
private:
TStream& fOutput;
TBuffer fBuffer;
};
struct NoSink { inline void operator<<(const std::string&) {} inline void Close() {} };
template<typename TSink=NoSink,typename M=messageconst>
class logger : private M {
using M::message;
public:
// logger() : fName("") {}
logger(const std::string color, const std::string name, TSink& sink) : fSink(sink), fName(color+"["+name+"]\033[39m ") {}
~logger() { fSink.Close(); }
// logger(const logger&) = delete;
template<typename ... Strings>
void log(const Strings&... inputs) {
fSink << M::message(inputs...);
}
const std::string& GetName() const { return fName; }
private:
TSink& fSink;
std::string fName;
};
#define LOG(__LOGGER,...) \
__LOGGER.log(__LOGGER.GetName(), __FILE__,":", __LINE__, " (", __func__, ") -> ", ##__VA_ARGS__);
#endif
#ifndef _include_logging_h_
#define _include_logging_h_
#include <logger.h>
#include <map>
#include <string>
#include <any>
class Logging {
Logging() {}
public:
static Logging& GetInstance() { static Logging fgLog; return fgLog; }
template<typename TLogger>
void AddLogger(const std::string& name, const TLogger& logger) { fLoggers[name] = logger; }
auto& GetLogger(const std::string& name) { return fLoggers[name]; }
private:
std::map<std::string, std::any> fLoggers;
};
#endif
CXXFLAGS+=-I. --std=c++14 -O3
all: test test_off
#test: test.o
# $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@
clean:
rm -rf *.o test test_off *.dat *.log
set (STACK_HEADERS StackOne.h)
add_library (CORSIKAstack INTERFACE)
#set_target_properties (CORSIKAstack PROPERTIES VERSION ${PROJECT_VERSION})
#set_target_properties (CORSIKAstack PROPERTIES SOVERSION 1)
#set_target_properties (CORSIKAstack PROPERTIES PUBLIC_HEADER "${STACK_HEADERS}")
#target_link_libraries (CORSIKAstackinterface CORSIKAunits)
#target_include_directories (CORSIKAstack PRIVATE ${EIGEN3_INCLUDE_DIR})
target_include_directories (CORSIKAstack INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (FILES StackOne.h DESTINATION include/Stack)
#ifndef _include_StackIterator_h__
#define _include_StackIterator_h__
#include <iostream>
#include <iomanip>
namespace stack {
template<class Stack, class Particle> class StackIteratorInfo;
/**
The main interface to iterator over objects on a stack.
*/
template<typename Stack, typename Particle>
class StackIterator : public Particle
{
friend Stack;
friend Particle;
friend StackIteratorInfo<Stack,Particle>;
private:
int fIndex;
//#warning stacks should not be copied because of this:
Stack* fData;
public:
StackIterator() : fData(0), fIndex(0) { }
StackIterator(Stack& data, const int index) : fData(&data), fIndex(index) { }
StackIterator(const StackIterator& mit) : fData(mit.fData), fIndex(mit.fIndex) { }
StackIterator& operator++() { ++fIndex; return *this; }
StackIterator operator++(int) { StackIterator tmp(*this); ++fIndex; return tmp; }
bool operator==(const StackIterator& rhs) { return fIndex == rhs.fIndex; }
bool operator!=(const StackIterator& rhs) { return fIndex != rhs.fIndex; }
StackIterator& operator*() { return *this; }
const StackIterator& operator*() const { return *this; }
protected:
int GetIndex() const { return fIndex; }
Stack& GetStack() { return *fData; }
const Stack& GetStack() const { return *fData; }
inline StackIterator<Stack,Particle>& base_ref() { return static_cast<StackIterator<Stack, Particle>&>(*this); }
inline const StackIterator<Stack,Particle>& base_ref() const { return static_cast<const StackIterator<Stack, Particle>&>(*this); }
};
/**
Internal helper class for StackIterator
*/
template<class _Stack, class Particle>
class StackIteratorInfo {
friend Particle;
private:
StackIteratorInfo() {}
protected:
inline _Stack& Stack() { return static_cast<StackIterator<_Stack, Particle>*>(this)->GetStack(); }
inline int Index() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetIndex(); }
inline const _Stack& Stack() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetStack(); }
};
} // end namespace stack
#endif
#ifndef _include_stackone_h_
#define _include_stackone_h_
#include <vector>
#include <string>
#include <StackInterface/Stack.h>
namespace stack {
/**
Example of a particle object on the stack.
*/
template<typename _Stack>
class ParticleReadOne : public StackIteratorInfo<_Stack, ParticleReadOne<_Stack> >
{
using StackIteratorInfo<_Stack, ParticleReadOne>::GetIndex;
using StackIteratorInfo<_Stack, ParticleReadOne>::GetStack;
public:
void SetId(const int id) { GetStack().SetId(GetIndex(), id); }
void SetEnergy(const double e) { GetStack().SetEnergy(GetIndex(), e); }
int GetId() const { GetStack().GetId(GetIndex()); }
double GetEnergy() const { GetStack().GetEnergy(GetIndex()); }
double GetPDG() const { return 0; } // ConvertToPDG(GetId()); }
void SetPDG(double v) { GetStack().SetId(0, 0); } //fIndex, ConvertFromPDG(v)); }
};
/**
Memory implementation of the most simple particle stack object.
*/
class StackOneImpl
{
private:
/// the actual memory to store particle data
std::vector<int> fId;
std::vector<double> fData;
public:
void Clear() { fData.clear(); }
int GetSize() const { return fData.size(); }
int GetCapacity() const { return fData.size(); }
void SetId(const int i, const int id) { fId[i] = id; }
void SetEnergy(const int i, const double e) { fData[i] = e; }
const int GetId(const int i) const { return fId[i]; }
const double GetEnergy(const int i) const { return fData[i]; }
/**
Function to copy particle at location i2 in stack to i1
*/
void Copy(const int i1, const int i2) {
fData[i2] = fData[i1];
fId[i2] = fId[i1];
}
protected:
void IncrementSize() { fData.push_back(0.); fId.push_back(0.); }
void DecrementSize() { if (fData.size()>0) { fData.pop_back(); fId.pop_back(); } }
};
typedef StackIterator<StackOneImpl, ParticleReadOne<StackOneImpl> > ParticleOne;
typedef Stack<StackOneImpl, ParticleOne> StackOne;
} // end namespace
#endif
add_library (CORSIKAprocesssequence INTERFACE)
target_include_directories (CORSIKAprocesssequence INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (FILES ProcessSequence.h
DESTINATION include/ProcessSequence)
#ifndef _include_ProcessSequence_h_
#define _include_ProcessSequence_h_
#include <iostream>
#include <typeinfo>
using namespace std;
namespace processes {
/**
/class Base
The structural base type of a process object in a
ProcessSequence. Both, the ProcessSequence and all its elements
are of type Base<T>
*/
template <typename derived>
struct Base
{
const derived& GetRef() const
{
return static_cast<const derived&>(*this);
}
};
/**
\class ProcessSequence
A compile time static list of processes. The compiler will
generate a new type based on template logic containing all the
elements.
\comment Using CRTP pattern, https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
*/
template <typename T1, typename T2>
class ProcessSequence : public Base <ProcessSequence<T1,T2> >
{
public:
const T1& A;
const T2& B;
ProcessSequence(const T1& in_A, const T2& in_B)
: A(in_A)
, B(in_B)
{ }
template<typename D>
inline void DoContinuous(D& d) const { A.DoContinuous(d); B.DoContinuous(d); } // add trajectory
template<typename D>
inline double MinStepLength(D& d) const { return min(A.MinStepLength(d), B.MinStepLength(d)); }
//template<typename D>
//inline Trajectory Transport(D& d, double& length) const { A.Transport(d, length); B.Transport(d, length); }
template<typename D>
inline void DoDiscrete(D& d) const { A.DoDiscrete(d); B.DoDiscrete(d); }
};
template <typename T1, typename T2>
inline
const ProcessSequence<T1,T2>
operator+ (const Base<T1>& A, const Base<T2>& B)
{
return ProcessSequence<T1,T2>( A.GetRef(), B.GetRef() );
}
/*
template <typename T1>
struct depth_lhs
{
static const int num = 0;
};
// terminating condition
template <typename T1, typename T2>
struct depth_lhs< Sequence<T1,T2> >
{
// try to expand the left node (T1) which might be a Sequence type
static const int num = 1 + depth_lhs<T1>::num;
};
*/
/*
template <typename T1>
struct mat_ptrs
{
static const int num = 0;
inline static void
get_ptrs(const Process** ptrs, const T1& X)
{
ptrs[0] = reinterpret_cast<const Process*>(&X);
}
};
template <typename T1, typename T2>
struct mat_ptrs< Sequence<T1,T2> >
{
static const int num = 1 + mat_ptrs<T1>::num;
inline static void
get_ptrs(const Process** in_ptrs, const Sequence<T1,T2>& X)
{
// traverse the left node
mat_ptrs<T1>::get_ptrs(in_ptrs, X.A);
// get address of the matrix on the right node
in_ptrs[num] = reinterpret_cast<const Process*>(&X.B);
}
};
*/
/*
template<typename T1, typename T2>
const Process&
Process::operator=(const Sequence<T1,T2>& X)
{
int N = 1 + depth_lhs< Sequence<T1,T2> >::num;
const Process* ptrs[N];
mat_ptrs< Sequence<T1,T2> >::get_ptrs(ptrs, X);
int r = ptrs[0]->rows;
int c = ptrs[0]->cols;
// ... check that all matrices have the same size ...
set_size(r, c);
for(int j=0; j<r*c; ++j)
{
double sum = ptrs[0]->data[j];
for(int i=1; i<N; ++i)
{
sum += ptrs[i]->data[j];
}
data[j] = sum;
}
return *this;
}
*/
} // end namespace
#endif
add_library (CORSIKAstack INTERFACE)
target_include_directories (CORSIKAstack INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (FILES Stack.h StackIterator.h
DESTINATION include/Stack)
add_library (CORSIKAstackinterface INTERFACE)
target_include_directories (CORSIKAstackinterface INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Framework>
$<INSTALL_INTERFACE:include/Framework>
)
install (FILES Stack.h StackIterator.h
DESTINATION include/StackInterface)
#ifndef _include_Stack_h__
#define _include_Stack_h__
#include <StackInterface/StackIterator.h> // to help application programmres
namespace stack {
/**
Interface definition of a Stack object.
*/
template<typename DataImpl, typename Particle>
class Stack : public DataImpl {
public:
using DataImpl::GetCapacity;
using DataImpl::GetSize;
using DataImpl::Clear;
using DataImpl::Copy;
using DataImpl::IncrementSize;
using DataImpl::DecrementSize;
public:
typedef Particle iterator;
typedef const Particle const_iterator;
/// these are functions required by std containers and std loops
iterator begin() { return iterator(*this, 0); }
iterator end() { return iterator(*this, GetSize()); }
iterator last() { return iterator(*this, GetSize()-1); }
/// these are functions required by std containers and std loops
const_iterator cbegin() const { return const_iterator(*this, 0); }
const_iterator cend() const { return const_iterator(*this, GetSize()); }
const_iterator clast() const { return const_iterator(*this, GetSize()-1); }
iterator NewParticle() { IncrementSize(); return iterator(*this, GetSize()-1); }
void DeleteLast() { DecrementSize(); }
};
} // end namespace
#endif