From 2097ee6929025b7005d3322a2fdf869d5ff8e1bb Mon Sep 17 00:00:00 2001 From: AAAlvesJr <aalvesju@gmail.com> Date: Sun, 29 Nov 2020 21:36:33 +0100 Subject: [PATCH] [refactory-2020] stack implementations: !290 headers --- corsika/framework/stack/CombinedStack.hpp | 6 ++--- corsika/framework/stack/ParticleBase.hpp | 5 ---- corsika/framework/stack/SecondaryView.hpp | 2 +- corsika/framework/stack/Stack.hpp | 28 ++++++++++---------- corsika/stack/GeometryNodeStackExtension.hpp | 2 +- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/corsika/framework/stack/CombinedStack.hpp b/corsika/framework/stack/CombinedStack.hpp index 10b2f903c..2e43a9425 100644 --- a/corsika/framework/stack/CombinedStack.hpp +++ b/corsika/framework/stack/CombinedStack.hpp @@ -66,13 +66,13 @@ namespace corsika { } template <typename... Args1> - void setParticleData(pi_a_type& p, const std::tuple<Args1...> vA) { + void setParticleData(PI_C& p, const std::tuple<Args1...> vA) { // static_assert(MT<I>::has_not, "error"); pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA); // original stack pi_b_type::setParticleData(static_cast<pi_b_type&>(p)); // addon stack } template <typename... Args1, typename... Args2> - void setParticleData(pi_c_type& p, const std::tuple<Args1...> vA, const std::tuple<Args2...> vB) { + void setParticleData(PI_C& p, const std::tuple<Args1...> vA, const std::tuple<Args2...> vB) { pi_a_type::setParticleData(static_cast<pi_a_type&>(p), vA); pi_b_type::setParticleData(static_cast<pi_b_type&>(p), vB); @@ -80,7 +80,7 @@ namespace corsika { ///@} std::string as_string() const { - return fmt::format("[[{}][{}]]", pi_a_type::as_string(), pi_b_type::as_string()); + return fmt::format("[[{}][{}]]", PI_A::as_string(), pi_b_type::as_string()); } private: diff --git a/corsika/framework/stack/ParticleBase.hpp b/corsika/framework/stack/ParticleBase.hpp index 75a4de78b..3af897ab8 100644 --- a/corsika/framework/stack/ParticleBase.hpp +++ b/corsika/framework/stack/ParticleBase.hpp @@ -68,11 +68,6 @@ namespace corsika { */ bool isDeleted() const { return this->getIterator().getStack().isDeleted(this->getIterator()); } - /** - * Method to retrieve the status of the Particle. Is it already deleted? Or not. - */ - bool isDeleted() const { return GetIterator().GetStack().isDeleted(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 diff --git a/corsika/framework/stack/SecondaryView.hpp b/corsika/framework/stack/SecondaryView.hpp index 7986159db..6fd7c2093 100644 --- a/corsika/framework/stack/SecondaryView.hpp +++ b/corsika/framework/stack/SecondaryView.hpp @@ -549,4 +549,4 @@ namespace corsika { } // namespace corsika -//#include <corsika/detail/framework/stack/SecondaryView.inl> +#include <corsika/detail/framework/stack/SecondaryView.inl> diff --git a/corsika/framework/stack/Stack.hpp b/corsika/framework/stack/Stack.hpp index 1d00b2a88..ad1e378d7 100644 --- a/corsika/framework/stack/Stack.hpp +++ b/corsika/framework/stack/Stack.hpp @@ -239,24 +239,24 @@ namespace corsika { */ template <typename... TArgs> stack_iterator_type addParticle(const TArgs... v) { - //C8LOG_TRACE("Stack::AddParticle"); + C8LOG_TRACE("Stack::AddParticle"); data_.incrementSize(); deleted_.push_back(false); return stack_iterator_type(*this, getSize() - 1, v...); } void swap(stack_iterator_type a, stack_iterator_type b) { - //C8LOG_TRACE("Stack::Swap"); + C8LOG_TRACE("Stack::Swap"); swap(a.getIndex(), b.getIndex()); } void copy(stack_iterator_type a, stack_iterator_type b) { - //C8LOG_TRACE("Stack::Copy"); + C8LOG_TRACE("Stack::Copy"); copy(a.getIndex(), b.getIndex()); } - void copy(const_stack_iterator_type a, stack_iterator_type b) { - //C8LOG_TRACE("Stack::Copy"); + void copy(stack_iterator_type a, stack_iterator_type b) { + C8LOG_TRACE("Stack::Copy"); data_.copy(a.getIndex(), b.getIndex()); if (deleted_[b.getIndex()] && !deleted_[a.getIndex()]) nDeleted_--; if (!deleted_[b.getIndex()] && deleted_[a.getIndex()]) nDeleted_++; @@ -264,7 +264,7 @@ namespace corsika { } void erase(stack_iterator_type p) { - //C8LOG_TRACE("Stack::Delete"); + C8LOG_TRACE("Stack::Delete"); if (this->isEmpty()) { /*error*/ throw std::runtime_error("Stack, cannot delete entry since size is zero"); } @@ -276,7 +276,7 @@ namespace corsika { /** * delete this particle */ - void erase(particle_interface_type p) { + void erase(ParticleInterfaceType p) { this->erase(p.getIterator()); } @@ -295,11 +295,11 @@ namespace corsika { return isDeleted(p.getIndex()); } - bool isDeleted(const const_stack_iterator_type& p) const { + bool isDeleted(const ConstStackIterator& p) const { return isDeleted(p.getIndex()); } - bool isDeleted(const particle_interface_type& p) const { + bool isDeleted(const ParticleInterfaceType& p) const { return isDeleted(p.getIterator()); } @@ -311,7 +311,7 @@ namespace corsika { bool purgeLastIfDeleted() { if (!deleted_.back()) return false; // the last particle is not marked for deletion. Do nothing. - //C8LOG_TRACE("Stack::purgeLastIfDeleted: yes"); + C8LOG_TRACE("Stack::purgeLastIfDeleted: yes"); data_.decrementSize(); nDeleted_--; deleted_.pop_back(); @@ -371,19 +371,19 @@ namespace corsika { */ template <typename... TArgs> stack_iterator_type addSecondary(stack_iterator_type& parent, const TArgs... v) { - //C8LOG_TRACE("Stack::AddSecondary"); + C8LOG_TRACE("Stack::AddSecondary"); data_.incrementSize(); deleted_.push_back(false); return stack_iterator_type(*this, getSize() - 1, parent, v...); } void swap(unsigned int a, unsigned int b) { - //C8LOG_TRACE("Stack::Swap(unsigned int)"); + C8LOG_TRACE("Stack::Swap(unsigned int)"); data_.swap(a, b); std::swap(deleted_[a], deleted_[b]); } void copy(unsigned int a, unsigned int b) { - //C8LOG_TRACE("Stack::Copy"); + C8LOG_TRACE("Stack::Copy"); data_.copy(a, b); if (deleted_[b] && !deleted_[a]) nDeleted_--; if (!deleted_[b] && deleted_[a]) nDeleted_++; @@ -423,7 +423,7 @@ namespace corsika { * should just be identiy. See class SecondaryView for an alternative implementation. */ unsigned int getIndexFromIterator(const unsigned int vI) const { - // this is too much: //C8LOG_TRACE("Stack::getIndexFromIterator({})={}", vI, vI); + // this is too much: C8LOG_TRACE("Stack::getIndexFromIterator({})={}", vI, vI); return vI; } diff --git a/corsika/stack/GeometryNodeStackExtension.hpp b/corsika/stack/GeometryNodeStackExtension.hpp index b92f16758..6c0c89b74 100644 --- a/corsika/stack/GeometryNodeStackExtension.hpp +++ b/corsika/stack/GeometryNodeStackExtension.hpp @@ -8,7 +8,7 @@ #pragma once -#include <corsika/framework/logging/Logging.hpp> +//#include <corsika/framework/logging/Logging.hpp> #include <corsika/framework/stack/Stack.hpp> #include <tuple> -- GitLab