2017-02-16 13:12:20 +01:00
|
|
|
|
|
|
|
#include "range_base.h"
|
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
/*********************
|
|
|
|
* MultiRangeType *
|
|
|
|
*********************/
|
|
|
|
|
2017-02-17 18:10:03 +01:00
|
|
|
MultiRangeType::MultiRangeType(const RangeType& type) : mType(type), mMultiType(nullptr) {}
|
|
|
|
|
|
|
|
MultiRangeType::MultiRangeType(const std::vector<MultiRangeType>& multiType) :
|
|
|
|
mType(RangeType::NIL),
|
|
|
|
mMultiType(new std::vector<MultiRangeType>(multiType)) {}
|
|
|
|
|
|
|
|
MultiRangeType::~MultiRangeType()
|
|
|
|
{
|
|
|
|
delete mMultiType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MultiRangeType& MultiRangeType::operator=(const RangeType& type)
|
2017-02-16 13:12:20 +01:00
|
|
|
{
|
|
|
|
setType(type);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiRangeType& MultiRangeType::operator=(const std::vector<MultiRangeType>& 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
|
|
|
|
{
|
2017-02-17 18:10:03 +01:00
|
|
|
return mMultiType != nullptr;
|
2017-02-16 13:12:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MultiRangeType::operator==(const MultiRangeType& in) const
|
|
|
|
{
|
2017-02-22 19:06:23 +01:00
|
|
|
if(multi() xor in.multi()){
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-16 13:12:20 +01:00
|
|
|
if(multi()){
|
|
|
|
return *mMultiType == *in.mMultiType;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return mType == in.mType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MultiRangeType::operator!=(const MultiRangeType& in) const
|
|
|
|
{
|
2017-02-22 19:06:23 +01:00
|
|
|
if(multi() xor in.multi()){
|
|
|
|
return true;
|
|
|
|
}
|
2017-02-16 13:12:20 +01:00
|
|
|
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<MultiRangeType>& multiType)
|
|
|
|
{
|
|
|
|
mMultiType = new std::vector<MultiRangeType>( multiType );
|
|
|
|
mType = RangeType::NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************
|
|
|
|
* RangeBase *
|
|
|
|
******************/
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
bool RangeBase<Index>::isSubRange() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-17 18:10:03 +01:00
|
|
|
template <class Index>
|
|
|
|
RangeBase<Index>* RangeBase<Index>::base()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-02-16 13:12:20 +01:00
|
|
|
/*********************
|
|
|
|
* SubRangeBase *
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
bool SubRangeBase<Index>::isSubRange() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|