diff --git a/src/include/cxz_darray_base.h b/src/include/cxz_darray_base.h index a971cde..a6cc75f 100644 --- a/src/include/cxz_darray_base.h +++ b/src/include/cxz_darray_base.h @@ -19,7 +19,7 @@ namespace CNORXZ { public: typedef T value_type; - typedef ConstContainerIndex const_iterator; + typedef DConstContainerIndex const_iterator; protected: RangePtr mRange; @@ -65,7 +65,7 @@ namespace CNORXZ typedef DArrayBase DAB; typedef DAB::value_type value_type; typedef DAB::const_iterator const_iterator; - typedef DContainerIndex iterator; + typedef DContainerIndex iterator; using DAB::operator[]; using DAB::at; diff --git a/src/include/dcontainer_index.h b/src/include/dcontainer_index.h new file mode 100644 index 0000000..1a5c95c --- /dev/null +++ b/src/include/dcontainer_index.h @@ -0,0 +1,58 @@ + +#ifndef __dcontainer_index_h__ +#define __dcontainer_index_h__ + +#include +#include +#include + +#include "ranges/range_base.h" +#include "ranges/index_base.h" +#include "mbase_def.h" +#include "statics/static_for.h" +#include "ranges/range_helper.h" + +namespace CNORXZ +{ + // Future DynamicIndex + class XIndexBase : public IndexInterface + { + public: + DEFAULT_MEMBERS(XIndexBase); + // ...!!! + }; + + typedef std::shared_ptr XIndexPtr; + + // MultiIndex Wrapper: + template + class XIndex + { + private: + std::shared_ptr> mI; + + public: + DEFAULT_MEMBERS(XIndex); + XIndex(const std::shared_ptr>& i); + + // ....!!!! + }; + + template + class DConstContainerIndex : public IndexInterface,DType> + { + protected: + XIndexPtr mI; + const T* mCData = nullptr; + size_t mCPos = 0; + }; + + template + class MDConstContainerIndex : public DConstContainerIndex + { + private: + T* mData = nullptr; + }; +} + +#endif diff --git a/src/include/ranges/dynamic_meta.h b/src/include/ranges/dynamic_meta.h index a1a4d60..7e1fb1d 100644 --- a/src/include/ranges/dynamic_meta.h +++ b/src/include/ranges/dynamic_meta.h @@ -9,7 +9,7 @@ namespace CNORXZ { - + // DEP: typedef std::pair DynamicMetaElem; template @@ -25,6 +25,7 @@ namespace CNORXZ } }; + // DEP: template <> struct DynamicMetaSetter<0> { @@ -38,6 +39,7 @@ namespace CNORXZ }; + // DEP: class DynamicMetaT { private: @@ -65,7 +67,94 @@ namespace CNORXZ const DynamicMetaElem& operator[](size_t pos) const; }; + // NEW: + // Type Eraser: + class DType + { + public: + DEFAULT_MEMBERS(DType); + virtual std::string str() const = 0; + virtual bool operator==(const DType& in) const = 0; + virtual bool operator!=(const DType& in) const = 0; + virtual size_t size() const = 0; + virtual std::shared_ptr operator[](size_t pos) const = 0; + }; + + // NEW: + template + class TypeWrapper : public DType + { + private: + T mD; + + public: + TypeWrapper(const T& d) : mD(d) {} + DEFAULT_MEMBERS(TypeWrapper); + + virtual std::string str() const { return std::to_string(mD); /*wrapper*/ } + virtual bool operator==(const DType& in) const { return this->str() == in.str(); } + virtual bool operator!=(const DType& in) const { return this->str() != in.str(); } + virtual size_t size() const { return 1; } + virtual std::shared_ptr operator[](size_t pos) const { return nullptr; } + }; + + // NEW: + template + class TypeRefWrapper : public DType + { + private: + const T* mD; + + public: + TypeRefWrapper(const T* d) : mD(d) {} + DEFAULT_MEMBERS(TypeRefWrapper); + + virtual std::string str() const { return to_string(*mD); /*wrapper*/ } + virtual bool operator==(const DType& in) const { return this->str() == in.str(); } + virtual bool operator!=(const DType& in) const { return this->str() != in.str(); } + virtual size_t size() const { return 1; } + virtual std::shared_ptr operator[](size_t pos) const { return nullptr; } + }; + + // NEW: + template + class TypeWrapper> : public DType + { + private: + std::vector mD; + + public: + TypeWrapper(const std::vector& d) : mD(d) {} + DEFAULT_MEMBERS(TypeWrapper); + + virtual std::string str() const { return to_string(mD); /* overload before!!! */ } + virtual bool operator==(const DType& in) const { return this->str() == in.str(); } + virtual bool operator!=(const DType& in) const { return this->str() != in.str(); } + virtual size_t size() const { return mD.size(); } + virtual std::shared_ptr operator[](size_t pos) const { return std::make_shared(&mD[pos]); } + }; + + // NEW: + template + class TypeRefWrapper> : public DType + { + private: + const std::vector* mD; + + public: + TypeWrapper(const std::vector* d) : mD(d) {} + DEFAULT_MEMBERS(TypeWrapper); + + virtual std::string str() const { return to_string(*mD); /* overload before!!! */ } + virtual bool operator==(const DType& in) const { return this->str() == in.str(); } + virtual bool operator!=(const DType& in) const { return this->str() != in.str(); } + virtual size_t size() const { return mD->size(); } + virtual std::shared_ptr operator[](size_t pos) const { return std::make_shared(&(*mD)[pos]); } + }; + + // SPECIALIZE: for std::array and std::tuple + } // namespace CNORXZ #endif