// -*- C++ -*- #ifndef __range_base_h__ #define __range_base_h__ #include #include #include #include "base_def.h" namespace MultiArrayTools { enum class RangeType { NIL = 0, ANY = 1, SPACE = 2, MOMENTUM = 3, LORENTZ = 4, SPIN = 5, ENSEMBLE = 6, VALUE_ERROR = 7, DISTANCE = 8 }; class MultiRangeType { public: DEFAULT_MEMBERS(MultiRangeType); MultiRangeType(const RangeType& type); MultiRangeType(const std::vector& multiType); ~MultiRangeType(); MultiRangeType& operator=(const RangeType& type); MultiRangeType& operator=(const std::vector& multiType); MultiRangeType& operator[](size_t num); const MultiRangeType& operator[](size_t num) const; bool multi() const; bool operator==(const MultiRangeType& in) const; bool operator!=(const MultiRangeType& in) const; private: void setType(RangeType type); void setMultiType(const std::vector& multiType); RangeType mType; std::vector* mMultiType; }; class IndefinitRangeBase { public: virtual ~IndefinitRangeBase() = default; virtual size_t size() const = 0; virtual bool isSubRange() const = 0; virtual MultiRangeType type() const = 0; virtual std::shared_ptr indexInstance() const = 0; protected: // only constructable via Factory IndefinitRangeBase() = default; IndefinitRangeBase(const IndefinitRangeBase& in) = delete; IndefinitRangeBase& operator=(const IndefinitRangeBase& in) = delete; }; template class RangeBase : public IndefinitRangeBase { public: typedef Index IndexType; virtual IndexType begin() const = 0; virtual IndexType end() const = 0; virtual RangeBase* base(); virtual bool isSubRange() const override; virtual std::shared_ptr indexInstance() const override; protected: RangeBase() = default; RangeBase(const RangeBase& in) = delete; RangeBase& operator=(const RangeBase& in) = delete; }; //template //auto cross(const Range& r1, const Range& r2) -> /**/; //template //auto cross(const Range1& r1, const Range2& r2) -> /**/; template class SubRangeBase : public RangeBase { public: virtual bool isSubRange() const override; virtual RangeBase* base() override; protected: DEFAULT_MEMBERS(SubRangeBase); RangeBase* mBase; std::vector mOccupation; }; } #include "range_base.cc" #endif