From 225ecc0abc8ec6ea19a4b5a776fa1cdab93a9234 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 4 Aug 2017 11:27:47 +0200 Subject: [PATCH] fixing compile errors... not finished --- src/base_def.h | 8 +++--- src/container_range.cc | 29 ++++++++++--------- src/container_range.h | 11 ++++--- src/index_base.cc | 4 +-- src/multi_range.cc | 38 ++++++++++++------------ src/multi_range.h | 58 ++++++++++++++++++------------------- src/pack_num.h | 26 +++++++++++------ src/range_base.cc | 10 +++++++ src/range_base.h | 5 ++-- src/single_range.cc | 65 +++++++++++++++++++++--------------------- src/single_range.h | 20 +++++++------ 11 files changed, 151 insertions(+), 123 deletions(-) diff --git a/src/base_def.h b/src/base_def.h index bddb0a6..edf4360 100644 --- a/src/base_def.h +++ b/src/base_def.h @@ -48,12 +48,12 @@ namespace MultiArrayTools // range_base.h enum class RangeType; - // range_base.h - class RangeBase; - // range_base.h class RangeFactoryBase; + // range_base.h + class RangeBase; + // range_base.h template class RangeInterface; @@ -74,7 +74,7 @@ namespace MultiArrayTools class SingleRangeFactory; // single_range.h - template + template class SingleIndex; // multi_range.h diff --git a/src/container_range.cc b/src/container_range.cc index 75a4a5a..1477a9b 100644 --- a/src/container_range.cc +++ b/src/container_range.cc @@ -21,7 +21,8 @@ namespace MultiArrayTools } template - ContainerRangeFactory::ContainerRangeFactory(const ContainerRange::SpaceType& space) + ContainerRangeFactory:: + ContainerRangeFactory(const typename ContainerRange::SpaceType& space) { mProd = std::make_shared >( space ); } @@ -57,18 +58,18 @@ namespace MultiArrayTools } template - typename IndexType ContainerRange::begin() const + typename ContainerRange::IndexType ContainerRange::begin() const { ContainerIndex - i( std::dynamic_pointer_cast >( mThis ) ); + i( std::dynamic_pointer_cast >( RB::mThis ) ); return i = 0; } template - typename IndexType ContainerRange::end() const + typename ContainerRange::IndexType ContainerRange::end() const { ContainerIndex - i( std::dynamic_pointer_cast >( mThis ) ); + i( std::dynamic_pointer_cast >( RB::mThis ) ); return i = size(); } @@ -76,7 +77,7 @@ namespace MultiArrayTools std::shared_ptr ContainerRange::index() const { return std::make_shared > - ( std::dynamic_pointer_cast >( mThis ) ); + ( std::dynamic_pointer_cast >( RB::mThis ) ); } @@ -89,7 +90,7 @@ namespace MultiArrayTools IndexInterface >(in) { PackNum::copy(mIPack, in); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); } template @@ -97,7 +98,7 @@ namespace MultiArrayTools { IndexI::operator=(in); PackNum::copy(mIPack, in); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); return *this; } @@ -106,14 +107,14 @@ namespace MultiArrayTools ContainerIndex::ContainerIndex(const std::shared_ptr& range) { PackNum::construct(mIPack, *range); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); } template ContainerIndex& ContainerIndex::operator++() { PackNum::pp( mIPack ); - ++mPos; + ++IB::mPos; return *this; } @@ -121,7 +122,7 @@ namespace MultiArrayTools ContainerIndex& ContainerIndex::operator--() { PackNum::mm( mIPack ); - --mPos; + --IB::mPos; return *this; } @@ -129,7 +130,7 @@ namespace MultiArrayTools template ContainerIndex& ContainerIndex::operator=(size_t pos) { - mPos = pos; + IB::mPos = pos; PackNum::setIndexPack(mIPack, pos); return *this; } @@ -159,9 +160,9 @@ namespace MultiArrayTools size_t ContainerIndex::pos() const { if(mExternControl){ - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); } - return mPos; + return IB::mPos; } template diff --git a/src/container_range.h b/src/container_range.h index e6cd1b3..1245953 100644 --- a/src/container_range.h +++ b/src/container_range.h @@ -23,7 +23,7 @@ namespace MultiArrayTools ContainerRangeFactory() = delete; ContainerRangeFactory(const std::shared_ptr&... rs); - ContainerRangeFactory(const ContainerRange::SpaceType& space); + ContainerRangeFactory(const typename ContainerRange::SpaceType& space); virtual std::shared_ptr create() override; @@ -36,16 +36,17 @@ namespace MultiArrayTools { public: + typedef RangeBase RB; typedef std::tuple...> SpaceType; typedef typename RangeInterface >::IndexType IndexType; - static const size_t dim = sizeof...(Ranges); + static const size_t sdim = sizeof...(Ranges); virtual size_t dim() const override; virtual size_t size() const override; - virtual typename IndexType begin() const override; - virtual typename IndexType end() const override; + virtual IndexType begin() const override; + virtual IndexType end() const override; virtual std::shared_ptr index() const override; @@ -67,8 +68,10 @@ namespace MultiArrayTools { public: + typedef IndexBase IB; typedef std::tuple MetaType; typedef std::tuple...> IndexPack; + typedef IndexInterface > IndexI; ContainerIndex() = default; diff --git a/src/index_base.cc b/src/index_base.cc index 675728c..a59784d 100644 --- a/src/index_base.cc +++ b/src/index_base.cc @@ -31,7 +31,7 @@ namespace MultiArrayTools return mRangePtr->size(); } - operator IndexBase::size_t() const + IndexBase::operator size_t() const { return pos(); } @@ -41,7 +41,7 @@ namespace MultiArrayTools **********************/ template - IndexInterface::IndexInterface(const RangeBase& range, size_t pos) : + IndexInterface::IndexInterface(const RangeBase& range, size_t pos) : IndexBase(range, pos) {} } diff --git a/src/multi_range.cc b/src/multi_range.cc index 1c0f658..eca0b61 100644 --- a/src/multi_range.cc +++ b/src/multi_range.cc @@ -19,7 +19,7 @@ namespace MultiArrayTools IndexInterface >(in) { PackNum::copy(mIPack, in); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); } template @@ -27,7 +27,7 @@ namespace MultiArrayTools { IndexI::operator=(in); PackNum::copy(mIPack, in); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); return *this; } @@ -37,14 +37,14 @@ namespace MultiArrayTools IndexInterface >(range, 0) { PackNum::construct(mIPack, *range); - mPos = PackNum::makePos(mIPack); + IB::mPos = PackNum::makePos(mIPack); } template MultiIndex& MultiIndex::operator++() { PackNum::pp( mIPack ); - ++mPos; + ++IB::mPos; return *this; } @@ -52,14 +52,14 @@ namespace MultiArrayTools MultiIndex& MultiIndex::operator--() { PackNum::mm( mIPack ); - --mPos; + --IB::mPos; return *this; } template MultiIndex& MultiIndex::operator=(size_t pos) { - mPos = pos; + IB::mPos = pos; PackNum::setIndexPack(mIPack, pos); return *this; } @@ -69,7 +69,7 @@ namespace MultiArrayTools MultiIndex& MultiIndex::up() { static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); - mPos += PackNum::blockSize( mIPack ); + IB::mPos += PackNum::blockSize( mIPack ); PackNum::pp( mIPack ); return *this; } @@ -79,7 +79,7 @@ namespace MultiArrayTools MultiIndex& MultiIndex::down() { static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); - mPos -= PackNum::blockSize( mIPack ); + IB::mPos -= PackNum::blockSize( mIPack ); PackNum::mm( mIPack ); return *this; } @@ -92,7 +92,7 @@ namespace MultiArrayTools template template - auto MultiIndex::get() const -> const decltype(*std::get(mIPack))& + auto MultiIndex::get() const -> decltype( *std::get( mIPack ) )& { return *std::get(mIPack); } @@ -105,7 +105,7 @@ namespace MultiArrayTools // throw !! } MultiIndex const* t = this; - return IndexGetter::getIndex(*t, n); + return PackNum::getIndex(*t, n); } template @@ -134,7 +134,7 @@ namespace MultiArrayTools } template - MultiRangeFactory::MultiRangeFactory(const MultiRange::SpaceType& st) + MultiRangeFactory::MultiRangeFactory(const typename MultiRange::SpaceType& st) { mProd = std::make_shared< MultiRange >( st ); } @@ -154,11 +154,11 @@ namespace MultiArrayTools MultiRange::MultiRange(const std::shared_ptr&... rs) : mSpace(std::make_tuple(rs...)) {} template - MultiRange::MultiRange(const SpaceType& space) : mSpace(space) {} + MultiRange::MultiRange(const SpaceType& space) : mSpace( space ) {} template template - auto getRange() const -> const decltype(*std::get(mSpace))& + auto MultiRange::get() const -> decltype( *std::get( mSpace ) )& //typename std::tuple_element >::type const& MultiRange::getRange() const { return *std::get(mSpace); @@ -177,16 +177,18 @@ namespace MultiArrayTools } template - MultiIndex MultiRange::begin() const + typename MultiRange::IndexType MultiRange::begin() const { - MultiIndex i( std::dynamic_pointer_cast >( mThis ) ); + MultiIndex + i( std::dynamic_pointer_cast >( RB::mThis ) ); return i = 0; } template - MultiIndex MultiRange::end() const + typename MultiRange::IndexType MultiRange::end() const { - MultiIndex i( std::dynamic_pointer_cast >( mThis ) ); + MultiIndex + i( std::dynamic_pointer_cast >( RB::mThis ) ); return i = size(); } @@ -194,6 +196,6 @@ namespace MultiArrayTools std::shared_ptr MultiRange::index() const { return std::make_shared > - ( std::dynamic_pointer_cast >( mThis ) ); + ( std::dynamic_pointer_cast >( RB::mThis ) ); } } diff --git a/src/multi_range.h b/src/multi_range.h index d71bef8..0448691 100644 --- a/src/multi_range.h +++ b/src/multi_range.h @@ -19,12 +19,15 @@ namespace MultiArrayTools { public: + typedef IndexBase IB; typedef std::tuple...> IndexPack; typedef std::tuple MetaType; typedef IndexInterface IndexI; - + + protected: + IndexPack mIPack; + public: - MultiIndex() = default; // NO DEFAULT HERE !!! // ( have to assign sub-indices (ptr!) correctly ) @@ -45,7 +48,7 @@ namespace MultiArrayTools MultiIndex& down(); template - auto get() const -> decltype(*std::get(mIPack))&; + auto get() const -> decltype( *std::get( mIPack ) )&; const IndexBase& get(size_t n) const; @@ -53,11 +56,6 @@ namespace MultiArrayTools virtual MultiIndex& at(const MetaType& metaPos) override; virtual size_t dim() const override; - - protected: - - IndexPack mIPack; - }; /************************* @@ -72,7 +70,7 @@ namespace MultiArrayTools MultiRangeFactory() = delete; MultiRangeFactory(const std::shared_ptr&... rs); - MultiRangeFactory(const MultiRange::SpaceType& space); + MultiRangeFactory(const typename MultiRange::SpaceType& space); virtual std::shared_ptr create() override; }; @@ -85,30 +83,11 @@ namespace MultiArrayTools class MultiRange : public RangeInterface > { public: - + typedef RangeBase RB; typedef std::tuple...> SpaceType; typedef typename RangeInterface >::IndexType IndexType; - static const size_t dim = sizeof...(Ranges); - - template // !!! - auto get() const ->; - //typename std::tuple_element...> >::type const& getRange() const; - - virtual size_t dim() const override; - virtual size_t size() const override; - - const SpaceType& space() const; - - virtual typename IndexType begin() const override; - virtual typename IndexType end() const override; - - virtual std::shared_ptr index() const override; - - friend MultiRangeFactory; - protected: - MultiRange() = delete; MultiRange(const MultiRange& in) = delete; MultiRange& operator=(const MultiRange& in) = delete; @@ -117,6 +96,27 @@ namespace MultiArrayTools MultiRange(const SpaceType& space); SpaceType mSpace; + + public: + + static const size_t sdim = sizeof...(Ranges); + + template + auto get() const -> decltype( *std::get( mSpace ) )&; + //typename std::tuple_element...> >::type const& getRange() const; + + virtual size_t dim() const override; + virtual size_t size() const override; + + const SpaceType& space() const; + + virtual IndexType begin() const override; + virtual IndexType end() const override; + + virtual std::shared_ptr index() const override; + + friend MultiRangeFactory; + }; } diff --git a/src/pack_num.h b/src/pack_num.h index a346e6b..82215dd 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -1,12 +1,18 @@ // -*- C++ -*- +#ifndef __pack_num_h__ +#define __pack_num_h__ + #include #include #include #include +#include "base_def.h" + namespace MultiArrayHelper { + using namespace MultiArrayTools; template struct PackNum @@ -65,7 +71,7 @@ namespace MultiArrayHelper return std::get(rt).size() * PackNum::getSize(rt); } - template