From c277fbde53964ec4e8dfe1e7b24ad93941b4ff59 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Thu, 14 Mar 2019 19:10:06 +0100 Subject: [PATCH] fixes regarding last commit --- src/include/helper_tools.cc.h | 4 +-- src/include/helper_tools.h | 2 +- src/include/multi_array.h | 3 +- src/include/ranges/dynamic_range.cc.h | 2 +- src/include/ranges/dynamic_range.h | 45 ++++++++++++++------------- src/include/ranges/single_range.h | 16 +++++++++- src/include/ranges/value_range.h | 7 +++-- 7 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/include/helper_tools.cc.h b/src/include/helper_tools.cc.h index 0037d75..2d37f4c 100644 --- a/src/include/helper_tools.cc.h +++ b/src/include/helper_tools.cc.h @@ -121,10 +121,10 @@ namespace MultiArrayTools } template - auto createRangeE(const Args&... args) + auto createRangeE(Args&&... args) -> std::shared_ptr { - typename Range::Factory f(args...); + typename Range::FType f(args...); return createExplicit(f); } diff --git a/src/include/helper_tools.h b/src/include/helper_tools.h index 17bee87..24403ed 100644 --- a/src/include/helper_tools.h +++ b/src/include/helper_tools.h @@ -65,7 +65,7 @@ namespace MultiArrayTools -> std::shared_ptr; template - auto createRangeE(const Args&... args) + auto createRangeE(Args&&... args) -> std::shared_ptr; template diff --git a/src/include/multi_array.h b/src/include/multi_array.h index cfab630..1c4e367 100644 --- a/src/include/multi_array.h +++ b/src/include/multi_array.h @@ -83,7 +83,8 @@ namespace MultiArrayTools virtual T* data() override; virtual vector& vdata() { return mCont; } virtual const vector& vdata() const { return mCont; } - + vector&& vmove() { MAB::mInit = false; return std::move(mCont); } + virtual std::shared_ptr > anonymous(bool slice = false) const override; virtual std::shared_ptr > anonymousMove() override; diff --git a/src/include/ranges/dynamic_range.cc.h b/src/include/ranges/dynamic_range.cc.h index 0816a78..74e3515 100644 --- a/src/include/ranges/dynamic_range.cc.h +++ b/src/include/ranges/dynamic_range.cc.h @@ -439,7 +439,7 @@ namespace MultiArrayTools template typename DynamicRange::MetaType DynamicRange::get(size_t pos) const { - std::vector out(cmeta(nullptr,0)); + vector out(cmeta(nullptr,0)); cmeta(out.data(),pos); return out; } diff --git a/src/include/ranges/dynamic_range.h b/src/include/ranges/dynamic_range.h index 339ddfc..a803bca 100644 --- a/src/include/ranges/dynamic_range.h +++ b/src/include/ranges/dynamic_range.h @@ -90,6 +90,8 @@ namespace MultiArrayTools IndexWrapperBase(IndexWrapperBase&& in) = default; IndexWrapperBase& operator=(const IndexWrapperBase& in) = default; IndexWrapperBase& operator=(IndexWrapperBase&& in) = default; + + using AbstractIW::operator=; template ExpressionHolder ifor(size_t step, ExpressionHolder ex) const; @@ -134,17 +136,17 @@ namespace MultiArrayTools virtual IndexType type() const final { return mI->type(); } - virtual IndexWrapper& operator=(size_t pos) final { (*mI) = pos; return *this; } - virtual IndexWrapper& operator++() final { ++(*mI); return *this; } - virtual IndexWrapper& operator--() final { --(*mI); return *this; } + virtual IndexWrapper& operator=(size_t pos) override final { (*mI) = pos; return *this; } + virtual IndexWrapper& operator++() override final { ++(*mI); return *this; } + virtual IndexWrapper& operator--() override final { --(*mI); return *this; } - virtual size_t pos() const final { return mI->pos(); } - virtual size_t max() const final { return mI->max(); } + virtual size_t pos() const override final { return mI->pos(); } + virtual size_t max() const override final { return mI->max(); } - virtual int pp(std::intptr_t idxPtrNum) final { return mI->pp(idxPtrNum); } - virtual int mm(std::intptr_t idxPtrNum) final { return mI->mm(idxPtrNum); } + virtual int pp(std::intptr_t idxPtrNum) override final { return mI->pp(idxPtrNum); } + virtual int mm(std::intptr_t idxPtrNum) override final { return mI->mm(idxPtrNum); } - virtual std::string stringMeta() const final { return mI->stringMeta(); } + virtual std::string stringMeta() const override final { return mI->stringMeta(); } //virtual DynamicMetaT meta() const final { return DynamicMetaT(mI->meta()); } //virtual const DynamicMetaT* metaPtr() const final { return nullptr; } IndexWrapper& at(const typename Index::MetaType& metaPos) { mI->at(metaPos); return *this; } @@ -152,24 +154,24 @@ namespace MultiArrayTools //virtual bool isMeta(const U& metaPos) const final { return mI->isMeta(); } - virtual size_t dim() const final { return mI->dim(); } - virtual bool last() const final { return mI->last(); } - virtual bool first() const final { return mI->first(); } + virtual size_t dim() const override final { return mI->dim(); } + virtual bool last() const override final { return mI->last(); } + virtual bool first() const override final { return mI->first(); } - virtual std::shared_ptr range() const final { return mI->range(); } + virtual std::shared_ptr range() const override final { return mI->range(); } - virtual size_t getStepSize(size_t n) const final { return mI->getStepSize(n); } - virtual size_t getStepSizeComp(std::intptr_t j) const final; + virtual size_t getStepSize(size_t n) const override final { return mI->getStepSize(n); } + virtual size_t getStepSizeComp(std::intptr_t j) const override final; - virtual std::intptr_t get() const final { return reinterpret_cast(mI.get()); } - virtual std::intptr_t ptrNum() const final { return mI->ptrNum(); } + virtual std::intptr_t get() const override final { return reinterpret_cast(mI.get()); } + virtual std::intptr_t ptrNum() const override final { return mI->ptrNum(); } }; //typedef SingleRange DynamicRange; template - class DynamicIndex : public IndexInterface,std::vector> + class DynamicIndex : public IndexInterface,vector> { private: typedef vector>,size_t>> IVecT; @@ -177,8 +179,8 @@ namespace MultiArrayTools IVecT mIVec; public: - typedef IndexInterface,std::vector> IB; - typedef std::vector MetaType; + typedef IndexInterface,vector> IB; + typedef vector MetaType; typedef DynamicRange RangeType; typedef DynamicIndex IType; @@ -287,8 +289,9 @@ namespace MultiArrayTools typedef RangeBase RB; typedef DynamicIndex IndexType; typedef DynamicRange RangeType; - typedef std::vector MetaType; - + typedef vector MetaType; + typedef DynamicRangeFactory FType; + private: DynamicRange() = default; DynamicRange(const DynamicRange& in) = default; diff --git a/src/include/ranges/single_range.h b/src/include/ranges/single_range.h index 2eb738f..b79ca7b 100644 --- a/src/include/ranges/single_range.h +++ b/src/include/ranges/single_range.h @@ -108,6 +108,7 @@ namespace MultiArrayTools GenSingleRangeFactory() = delete; GenSingleRangeFactory(const vector& space); + GenSingleRangeFactory(vector&& space); std::shared_ptr create(); }; @@ -264,6 +265,7 @@ namespace MultiArrayTools GenSingleRange(const GenSingleRange& in) = delete; GenSingleRange(const vector& space); + GenSingleRange(vector&& space); vector mSpace; //std::map mMSpace; @@ -498,6 +500,12 @@ namespace MultiArrayTools mProd = std::shared_ptr( new GenSingleRange( space ) ); } + template + GenSingleRangeFactory::GenSingleRangeFactory(vector&& space) + { + mProd = std::shared_ptr( new GenSingleRange( space ) ); + } + template std::shared_ptr GenSingleRangeFactory::create() { @@ -518,7 +526,13 @@ namespace MultiArrayTools // mMSpace[mSpace[i]] = i; //} } - + + template + GenSingleRange::GenSingleRange(vector&& space) : + RangeInterface >(), + mSpace(space), mMSpace(mSpace) {} + + template const U& GenSingleRange::get(size_t pos) const { diff --git a/src/include/ranges/value_range.h b/src/include/ranges/value_range.h index 8e8fb9b..49de5b2 100644 --- a/src/include/ranges/value_range.h +++ b/src/include/ranges/value_range.h @@ -104,15 +104,16 @@ namespace MultiArrayTools typedef ValueIndex IndexType; typedef ValueRange RangeType; typedef U MetaType; - + typedef ValueRangeFactory FType; + virtual size_t size() const final; virtual size_t dim() const final; virtual SpaceType spaceType() const final; virtual DataHeader dataHeader() const final; - virtual size_t typeNum() const = 0; - virtual size_t cmeta(char* target, size_t pos) const = 0; + virtual size_t typeNum() const final; + virtual size_t cmeta(char* target, size_t pos) const final; virtual std::string stringMeta(size_t pos) const final; virtual vector data() const final;