#ifndef __cxz_array_base_h__ #define __cxz_array_base_h__ #include #include #include #include #include "base_def.h" #include "mbase_def.h" #include "ranges/rheader.h" namespace CNORXZ { template using IPTR = std::shared_ptr; template inline auto operator|(const IPTR& i1, const IPTR& i2) -> decltype(std::make_tuple(i1,i2)) { return std::make_tuple(i1,i2); } template inline auto operator|(const IPTR& i1, const std::tuple...>& i2) -> decltype(std::tuple_cat(std::make_tuple(i1),i2)) { return std::tuple_cat(std::make_tuple(i1),i2); } template inline auto operator|(const std::tuple...>& i1, const IPTR& i2) -> decltype(std::tuple_cat(i1,std::make_tuple(i2))) { return std::tuple_cat(i1,std::make_tuple(i2)); } template inline auto operator~(const IPTR& i) -> decltype(std::make_tuple(i)) { return std::make_tuple(i); } // Explicitely specify subranges in template argument !!! template class ArrayBase { public: typedef T value_type; typedef ContainerRange CRange; typedef ConstContainerIndex CIndexType; typedef ContainerIndex IndexType; protected: bool mInit = false; std::shared_ptr mRange; std::shared_ptr mProtoI; public: //DEFAULT_MEMBERS(ArrayBase); ArrayBase(const std::shared_ptr&... ranges); ArrayBase(const typename CRange::Space& space); ArrayBase() = default; ArrayBase(const ArrayBase& in); ArrayBase(ArrayBase&& in); ArrayBase& operator=(const ArrayBase& in); ArrayBase& operator=(ArrayBase&& in); virtual ~ArrayBase() = default; template const T& operator[](const ConstContainerIndex& i); const T& operator[](const std::tuple...>& is) const; virtual const T& operator[](const CIndexType& i) const = 0; virtual const T& at(const typename CRange::IndexType::MetaType& meta) const = 0; virtual const T* data() const = 0; virtual size_t size() const; virtual bool isSlice() const = 0; virtual CIndexType begin() const; virtual CIndexType end() const; virtual CIndexType cbegin() const; virtual CIndexType cend() const; virtual const std::shared_ptr& range() const; virtual bool isConst() const; virtual std::shared_ptr > anonymous(bool slice = false) const = 0; virtual ConstOperationRoot op(const std::shared_ptr& ind) const; virtual ConstOperationRoot operator()(const std::shared_ptr&... inds) const; template ConstOperationRoot m(const std::shared_ptr&... inds) const; virtual bool isInit() const; template auto getRangePtr() const -> decltype(mRange->template getPtr()); }; template class MutableArrayBase : public ArrayBase { public: typedef ContainerRange CRange; typedef ArrayBase MAB; typedef ContainerIndex IndexType; typedef ConstContainerIndex CIndexType; using ArrayBase::operator[]; using ArrayBase::at; using ArrayBase::data; using ArrayBase::begin; using ArrayBase::end; using ArrayBase::cbegin; using ArrayBase::cend; DEFAULT_MEMBERS(MutableArrayBase); MutableArrayBase(const std::shared_ptr&... ranges); MutableArrayBase(const typename CRange::Space& space); template T& operator[](const ConstContainerIndex& i); T& operator[](const std::tuple...>& is); virtual T& operator[](const CIndexType& i) = 0; virtual T& at(const typename CRange::IndexType::MetaType& meta) = 0; virtual T* data() = 0; virtual IndexType begin(); virtual IndexType end(); virtual bool isConst() const override; virtual ConstOperationRoot op(const std::shared_ptr& ind) const override; virtual ConstOperationRoot operator()(const std::shared_ptr&... inds) const override; virtual OperationRoot op(const std::shared_ptr& ind); virtual OperationRoot operator()(const std::shared_ptr&... inds); template OperationRoot m(const std::shared_ptr&... inds); template ConstOperationRoot m(const std::shared_ptr&... inds) const; }; } // end namespace CNORXZ /* ========================= * * --- TEMPLATE CODE --- * * ========================= */ #endif