From c349ff7bd08501d9c1a406cd3616e8c7e67c6fb3 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 25 Dec 2017 01:35:09 +0100 Subject: [PATCH] index info compiles... --- CMakeLists.txt | 2 +- src/ranges/index_info.cc | 43 +++++++++++++++++++++++++++++++++++++++- src/ranges/index_info.h | 32 +++++++++++++++++++++++++++--- src/ranges/vindex_base.h | 1 + 4 files changed, 73 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6a86a7..daab850 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ endif() include_directories(src) -set(INDEX_CC_FILES "${INDEX_CC_FILES}" "src/ranges/range_base.cc") +set(INDEX_CC_FILES "${INDEX_CC_FILES}" "src/ranges/range_base.cc" "src/ranges/index_info.cc") set(MA_CC_FILES "${MA_CC_FILES}" "${INDEX_CC_FILES}" "src/operation_utils.cc") add_executable(iutest src/ranges/tests/index_unit_test.cc ${INDEX_CC_FILES}) diff --git a/src/ranges/index_info.cc b/src/ranges/index_info.cc index f4c4f28..824051f 100644 --- a/src/ranges/index_info.cc +++ b/src/ranges/index_info.cc @@ -1,9 +1,41 @@ #include "index_info.h" +#include "range_base.h" namespace MultiArrayTools { + + bool IndexInfo::operator==(const IndexInfo& in) const + { + return mPtrNum == in.mPtrNum; + } + + bool IndexInfo::operator!=(const IndexInfo& in) const + { + return mPtrNum != in.mPtrNum; + } + bool IndexInfo::operator<=(const IndexInfo& in) const + { + return mPtrNum <= in.mPtrNum; + } + + bool IndexInfo::operator<(const IndexInfo& in) const + { + return mPtrNum < in.mPtrNum; + } + + bool IndexInfo::operator>(const IndexInfo& in) const + { + return mPtrNum > in.mPtrNum; + } + + bool IndexInfo::operator>=(const IndexInfo& in) const + { + return mPtrNum >= in.mPtrNum; + } + + const IndexInfo* IndexInfo::getPtr(size_t inum) const { return &mNext[inum]; @@ -18,10 +50,15 @@ namespace MultiArrayTools { return mDim; } + + size_t IndexInfo::max() const + { + return mMax; + } size_t IndexInfo::getStepSize(size_t inum) const { - return mNext[inum]->getStepSzize(); + return mNext[inum].getStepSize(); } size_t IndexInfo::getStepSize() const @@ -29,5 +66,9 @@ namespace MultiArrayTools return mStepSize; } + IndexType IndexInfo::type() const + { + return mType; + } } // end namespace MultiArrayTools diff --git a/src/ranges/index_info.h b/src/ranges/index_info.h index 427aedd..d58230d 100644 --- a/src/ranges/index_info.h +++ b/src/ranges/index_info.h @@ -4,7 +4,11 @@ #define __index_info_h__ #include +#include #include +#include +#include "vindex_base.h" +#include "index_type.h" namespace MultiArrayTools { @@ -13,29 +17,51 @@ namespace MultiArrayTools class IndexInfo { public: - IndexInfo() = delete; + IndexInfo(IndexInfo&& in) = default; + IndexInfo& operator=(IndexInfo&& in) = default; + IndexInfo(const IndexInfo& in) = default; + IndexInfo& operator=(const IndexInfo& in) = default; + + template IndexInfo(const IndexClass& ind, size_t stepSize = 1); + + bool operator==(const IndexInfo& in) const; + bool operator!=(const IndexInfo& in) const; + + bool operator<=(const IndexInfo& in) const; + bool operator<(const IndexInfo& in) const; + bool operator>(const IndexInfo& in) const; + bool operator>=(const IndexInfo& in) const; + const IndexInfo* getPtr(size_t inum) const; std::intptr_t getPtrNum() const; size_t dim() const; + size_t max() const; size_t getStepSize(size_t inum) const; size_t getStepSize() const; - + IndexType type() const; + private: + + IndexInfo() = default; + std::vector mNext; std::intptr_t mPtrNum; size_t mDim; + size_t mMax; size_t mStepSize; + IndexType mType; }; template IndexInfo::IndexInfo(const IndexClass& ind, size_t stepSize) : mNext(ind.infoVec()), mPtrNum( reinterpret_cast( &ind ) ), - mDim(ind.rangePtr()->dim()), + mDim(ind.vrange()->dim()), + mMax(ind.max()), mStepSize(stepSize) {} diff --git a/src/ranges/vindex_base.h b/src/ranges/vindex_base.h index cc971cf..114d2e1 100644 --- a/src/ranges/vindex_base.h +++ b/src/ranges/vindex_base.h @@ -4,6 +4,7 @@ //#include "ranges/range_base.h" #include "ranges/index_type.h" +#include "base_def.h" namespace MultiArrayTools {