diff --git a/src/include/cxz_darray_base.cc.h b/src/include/cxz_darray_base.cc.h new file mode 100644 index 0000000..228c3e1 --- /dev/null +++ b/src/include/cxz_darray_base.cc.h @@ -0,0 +1,108 @@ + +#include "cxz_darray_base.h" + +namespace CNORXZ +{ + /**************** + * DArrayBase * + ***************/ + + template + DArrayBase::DArrayBase(const RangePtr& range) : mRange(range), mInit(true) + { + mIt = this->begin(); + } + + template + template + const value_type& DArrayBase::operator[](const IndexInterface& i) const + { + return *mIt(i); + } + + template + template + const value_type& DArrayBase::at(const IndexInterface& i) const + { + return *mIt.at(i); + } + + template + size_t DArrayBase::size() const + { + return mRange->size(); + } + + template + RangePtr DArrayBase::range() const + { + return mRange; + } + + template + DArrayBase::const_iterator DArrayBase::begin() const + { + return this->cbegin(); + } + + template + DArrayBase::const_iterator DArrayBase::end() const + { + return this->cend(); + } + + template + virtual bool DArrayBase::isInit() const + { + return mInit; + } + + template + template + ConstOperationRoot DArrayBase::operator()(const IndexPtr& i) const + { + return ConstOperationRoot(/**/); + } + + + /***************** + * MDArrayBase * + ****************/ + + template + MDArrayBase::MDArrayBase(const RangePtr& range) : DArrayBase(range) {} + + template + template + value_type& MDArrayBase::operator[](const IndexInterface& i) + { + return *mIt(i); + } + + template + template + value_type& MDArrayBase::at(const IndexInterface& i) + { + return *mIt.at(i); + } + + template + MDArrayBase::iterator MDArrayBase::begin() + { + return iterator(this->data(), this->cbegin()); + } + + template + MDArrayBase::iterator MDArrayBase::end() + { + return iterator(this->data(), this->cend()); + } + + template + template + OperationRoot MDArrayBase::operator()(const IndexPtr& i) + { + return OperationRoot(/**/); + } + +} diff --git a/src/include/cxz_darray_base.h b/src/include/cxz_darray_base.h new file mode 100644 index 0000000..a971cde --- /dev/null +++ b/src/include/cxz_darray_base.h @@ -0,0 +1,101 @@ + +#ifndef __cxz_darray_base_h__ +#define __cxz_darray_base_h__ + +#include +#include +#include +#include + +#include "base_def.h" +#include "mbase_def.h" + +#include "ranges/rheader.h" + +namespace CNORXZ +{ + template + class DArrayBase + { + public: + typedef T value_type; + typedef ConstContainerIndex const_iterator; + + protected: + RangePtr mRange; + const_iterator mIt; + bool mInit = false; + + public: + + DArrayBase(const RangePtr& range); + DEFAULT_MEMBERS(DArrayBase); + + virtual ~DArrayBase() = default; + + template + const value_type& operator[](const IndexInterface& i) const; + + template + const value_type& at(const IndexInterface& i) const; + + template + DArrayBase sl(const IndexInterface& i) const; + + virtual const T* data() const = 0; + virtual size_t size() const; + virtual RangePtr range() const; + + virtual const_iterator begin() const; + virtual const_iterator end() const; + virtual const_iterator cbegin() const = 0; + virtual const_iterator cend() const = 0; + + virtual bool isView() const = 0; + virtual bool isInit() const; + + template + ConstOperationRoot operator()(const IndexPtr& i) const; + }; + + template + class MDArrayBase : public DArrayBase + { + public: + typedef DArrayBase DAB; + typedef DAB::value_type value_type; + typedef DAB::const_iterator const_iterator; + typedef DContainerIndex iterator; + + using DAB::operator[]; + using DAB::at; + using DAB::data; + using DAB::begin; + using DAB::end; + using DAB::cbegin; + using DAB::cend; + using DAB::operator(); + + MDArrayBase(const RangePtr& range); + DEFAULT_MEMBERS(MDArrayBase); + + template + value_type& operator[](const IndexInterface& i); + + template + value_type& at(const IndexInterface& i); + + template + DArrayBase sl(const IndexInterface& i); + + virtual T* data() = 0; + + virtual iterator begin(); + virtual iterator end(); + + template + OperationRoot operator()(const IndexPtr& i); + }; +} + +#endif diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 627a907..e4fdacc 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -100,6 +100,9 @@ namespace CNORXZ return iptr; } + template + using IndexPtr = std::shared_ptr> + } /* ========================= * diff --git a/src/include/ranges/range_base.h b/src/include/ranges/range_base.h index 548d3da..b81508a 100644 --- a/src/include/ranges/range_base.h +++ b/src/include/ranges/range_base.h @@ -126,7 +126,10 @@ namespace CNORXZ protected: RangeInterface() = default; }; - + + typedef std::shared_ptr RangePtr; + + RangePtr operator*(const RangePtr& a, const RangePtr& b); // -> Ptr to MultiRange } #endif