From 451d58c037d88f53a00ba0ae646713abc2f6d594 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 18 May 2018 17:45:40 +0200 Subject: [PATCH] type operations (after debugging operation forwarding should be possible) --- src/include/multi_array_operation.h | 25 ++++++------- src/include/type_operations.h | 57 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 src/include/type_operations.h diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 25d713e..d8819fa 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -26,10 +26,7 @@ namespace MultiArrayTools } template - class TypeSpecificOperationSet { /* empty per default; specialize if needed */ }; - - template - class OperationTemplate : public TypeSpecificOperationSet + class OperationBase { public: @@ -60,6 +57,12 @@ namespace MultiArrayTools friend OperationClass; OperationTemplate() = default; }; + + template + class OperationTemplate : public OperationBase + { /* empty per default; specialize if needed */ }; + +#include "type_operations.h" template class OperationMaster @@ -119,14 +122,12 @@ namespace MultiArrayTools template - class ConstOperationRoot : /*public OperationBase,*/ - public OperationTemplate > + class ConstOperationRoot : public OperationTemplate > { public: typedef T value_type; - typedef OperationBase OB; - typedef OperationTemplate > OT; + typedef OperationBase > OT; typedef ContainerRange CRange; typedef ContainerIndex IndexType; @@ -158,8 +159,7 @@ namespace MultiArrayTools public: typedef T value_type; - typedef OperationBase OB; - typedef OperationTemplate > OT; + typedef OperationBase > OT; typedef ContainerRange CRange; typedef ContainerIndex IndexType; @@ -236,8 +236,7 @@ namespace MultiArrayTools public: typedef T value_type; - typedef OperationBase OB; - typedef OperationTemplate > OT; + typedef OperationBase > OT; typedef OpFunction F; static constexpr size_t SIZE = RootSum::SIZE; @@ -278,7 +277,7 @@ namespace MultiArrayTools public: typedef T value_type; - typedef OperationTemplate > OT; + typedef OperationBase > OT; static constexpr size_t SIZE = Op::SIZE; diff --git a/src/include/type_operations.h b/src/include/type_operations.h new file mode 100644 index 0000000..7889368 --- /dev/null +++ b/src/include/type_operations.h @@ -0,0 +1,57 @@ + +#ifndef __type_operations_h__ +#define __type_operations_h__ + +#include + +#include "base_def.h" +#include "mbase_def.h" + +#include "pack_num.h" + +namespace MultiArrayTools +{ + namespace + { + using namespace MultiArrayHelper; + } + + template + class operate + { + public: + static constexpr bool FISSTATIC = false; + + operate(const std::shared_ptr&... inds) : ituple(inds...) {} + + inline auto apply(const MultiArray& ma) + -> OperationRoot + { + return mkElemOperation(ma, ituple); // -> pack_num + } + + private: + + // this is, why non-static + std::tuple...> ituple; + } + + template + class OperationTemplate : public OperationBase,OperationClass> + { + typedef OperationBase,OperationClass> OB; + + auto operator()(const std::shared_ptr&... indices) + -> Operation,operate,OperationClass> + { + std::shared_ptr ff(indices...); + return Operation(ff, OB::THIS()); + } + + }; + + + +} // namespace MultiArrayTools + +#endif