#include "range_base.h" namespace MultiArrayTools { /********************* * MultiRangeType * *********************/ MultiRangeType::MultiRangeType(const RangeType& type) : mType(type), mMultiType(nullptr) {} MultiRangeType::MultiRangeType(const std::vector& multiType) : mType(RangeType::NIL), mMultiType(new std::vector(multiType)) {} MultiRangeType::~MultiRangeType() { delete mMultiType; } MultiRangeType& MultiRangeType::operator=(const RangeType& type) { setType(type); return *this; } MultiRangeType& MultiRangeType::operator=(const std::vector& multiType) { setMultiType(multiType); return *this; } MultiRangeType& MultiRangeType::operator[](size_t num) { return mMultiType->at(num); } const MultiRangeType& MultiRangeType::operator[](size_t num) const { return mMultiType->at(num); } bool MultiRangeType::multi() const { return mMultiType != nullptr; } bool MultiRangeType::operator==(const MultiRangeType& in) const { if(multi() xor in.multi()){ return false; } if(multi()){ return *mMultiType == *in.mMultiType; } else { return mType == in.mType; } } bool MultiRangeType::operator!=(const MultiRangeType& in) const { if(multi() xor in.multi()){ return true; } if(multi()){ return *mMultiType != *in.mMultiType; } else { return mType != in.mType; } } void MultiRangeType::setType(RangeType type) { mType = type; if(mMultiType != nullptr){ delete mMultiType; } mMultiType = nullptr; } void MultiRangeType::setMultiType(const std::vector& multiType) { mMultiType = new std::vector( multiType ); mType = RangeType::NIL; } /****************** * RangeBase * ******************/ template bool RangeBase::isSubRange() const { return false; } template RangeBase* RangeBase::base() { return nullptr; } /********************* * SubRangeBase * *********************/ template bool SubRangeBase::isSubRange() const { return true; } }