From a5292ef2ab50a0d4329b745925fa28526b488be1 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 17 Jul 2018 13:56:59 +0200 Subject: [PATCH] some utilities (move all to helper_tools.h) --- src/include/base_def.h | 4 ++++ src/include/helper_tools.h | 35 +++++++++++++++++++++++++++++++++++ src/include/utils.h | 30 ------------------------------ 3 files changed, 39 insertions(+), 30 deletions(-) delete mode 100644 src/include/utils.h diff --git a/src/include/base_def.h b/src/include/base_def.h index 10f833b..9628956 100644 --- a/src/include/base_def.h +++ b/src/include/base_def.h @@ -10,9 +10,13 @@ #ifdef DEBUG_MODE_X #include +#ifndef CHECK #define CHECK std::cout << __FILE__ << ": @" << __LINE__ << " in " << __func__ << std::endl; +#endif +#ifndef VCHECK #define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \ << " in " << __func__ << ": " << #a << " = " << a << std::endl; +#endif #else #define CHECK diff --git a/src/include/helper_tools.h b/src/include/helper_tools.h index e88f4b5..b5c11c1 100644 --- a/src/include/helper_tools.h +++ b/src/include/helper_tools.h @@ -4,9 +4,14 @@ #include "base_def.h" #include "slice.h" +#include +#include "pack_num.h" namespace MultiArrayTools { + + template + std::ostream& operator<<(std::ostream& out, const std::tuple& tp); template auto getIndex(std::shared_ptr range) @@ -27,6 +32,15 @@ namespace MultiArrayTools template auto mkMulti(std::tuple...> rangesTuple) -> MultiRange; + + template + auto createExplicit(RangeFactory& rf) + -> std::shared_ptr; + + template + auto createExplicit(std::shared_ptr rfp) + -> std::shared_ptr; + } /* ========================= * @@ -35,6 +49,13 @@ namespace MultiArrayTools namespace MultiArrayTools { + template + std::ostream& operator<<(std::ostream& out, const std::tuple& tp) + { + PackNum::printTuple(out, tp); + return out; + } + template auto getIndex(std::shared_ptr range) -> std::shared_ptr @@ -78,6 +99,20 @@ namespace MultiArrayTools return std::dynamic_pointer_cast >( mrf.create() ); } + template + auto createExplicit(RangeFactory& rf) + -> std::shared_ptr + { + return std::dynamic_pointer_cast( rf.create() ); + } + + template + auto createExplicit(std::shared_ptr rfp) + -> std::shared_ptr + { + return std::dynamic_pointer_cast( rfp->create() ); + } + } #endif diff --git a/src/include/utils.h b/src/include/utils.h deleted file mode 100644 index 6e1344c..0000000 --- a/src/include/utils.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef __utils_h__ -#define __utils_h__ - -#include -#include "pack_num.h" - -namespace MultiArrayHelper -{ - - using namespace MultiArrayTools; - - template - std::ostream& operator<<(std::ostream& out, const std::tuple& tp); - - /*==================* - * TEMPLATE CODE * - *==================*/ - - template - std::ostream& operator<<(std::ostream& out, const std::tuple& tp) - { - PackNum::printTuple(out, tp); - return out; - } - - -} // end namespace MultiArrayHelper - -#endif