2020-08-27 12:00:47 +02:00
|
|
|
|
|
|
|
#include "index_wrapper.h"
|
2021-05-27 23:29:04 +02:00
|
|
|
#include "range_helper.h"
|
2020-08-27 12:00:47 +02:00
|
|
|
|
2021-07-28 20:29:56 +02:00
|
|
|
namespace CNORXZ
|
2020-08-27 12:00:47 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
template <class Index>
|
2020-09-11 23:29:58 +02:00
|
|
|
IndexWrapper<Index>::IndexWrapper(const std::shared_ptr<Index>& i) : mI(i)
|
|
|
|
{
|
|
|
|
ClassicRF crf(mI->max());
|
|
|
|
mCI = std::make_shared<ClassicIndex>
|
|
|
|
( std::dynamic_pointer_cast<ClassicRange>( crf.create() ) );
|
|
|
|
(*mCI) = mI->pos();
|
|
|
|
}
|
2020-08-27 12:00:47 +02:00
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
IndexType IndexWrapper<Index>::type() const
|
|
|
|
{
|
|
|
|
return mI->type();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
IndexWrapper<Index>& IndexWrapper<Index>::operator=(size_t pos)
|
|
|
|
{
|
|
|
|
(*mI) = pos;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
IndexWrapper<Index>& IndexWrapper<Index>::operator++()
|
|
|
|
{
|
|
|
|
++(*mI);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
IndexWrapper<Index>& IndexWrapper<Index>::operator--()
|
|
|
|
{
|
|
|
|
--(*mI);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::pos() const
|
|
|
|
{
|
|
|
|
return mI->pos();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::max() const
|
|
|
|
{
|
|
|
|
return mI->max();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
int IndexWrapper<Index>::pp(std::intptr_t idxPtrNum)
|
|
|
|
{
|
|
|
|
return mI->pp(idxPtrNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
int IndexWrapper<Index>::mm(std::intptr_t idxPtrNum)
|
|
|
|
{
|
|
|
|
return mI->mm(idxPtrNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::string IndexWrapper<Index>::stringMeta() const
|
|
|
|
{
|
|
|
|
return mI->stringMeta();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
IndexWrapper<Index>& IndexWrapper<Index>::at(const typename Index::MetaType& metaPos)
|
|
|
|
{
|
|
|
|
mI->at(metaPos);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::posAt(const typename Index::MetaType& metaPos)
|
|
|
|
{
|
|
|
|
return mI->posAt(metaPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::dim() const
|
|
|
|
{
|
|
|
|
return mI->dim();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
bool IndexWrapper<Index>::last() const
|
|
|
|
{
|
|
|
|
return mI->last();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
bool IndexWrapper<Index>::first() const
|
|
|
|
{
|
|
|
|
return mI->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::shared_ptr<RangeBase> IndexWrapper<Index>::range() const
|
|
|
|
{
|
|
|
|
return mI->range();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::getStepSize(size_t n) const
|
|
|
|
{
|
|
|
|
return mI->getStepSize(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
size_t IndexWrapper<Index>::getStepSizeComp(std::intptr_t j) const
|
|
|
|
{
|
2021-05-27 23:29:04 +02:00
|
|
|
size_t out = RangeHelper::getStepSize(*mI, j);
|
2020-09-11 23:29:58 +02:00
|
|
|
if(out == 0){
|
2021-05-27 23:29:04 +02:00
|
|
|
out = RangeHelper::getStepSize(*mCI, j);
|
2020-09-11 23:29:58 +02:00
|
|
|
}
|
|
|
|
return out;
|
2020-08-27 12:00:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::intptr_t IndexWrapper<Index>::get() const
|
|
|
|
{
|
|
|
|
return reinterpret_cast<std::intptr_t>(mI.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::intptr_t IndexWrapper<Index>::ptrNum() const
|
|
|
|
{
|
|
|
|
return mI->ptrNum();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
DynamicExpression IndexWrapper<Index>::ifor(size_t step, DynamicExpression ex) const
|
|
|
|
{
|
|
|
|
return mI->ifor(step, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
DynamicExpression IndexWrapper<Index>::iforh(size_t step, DynamicExpression ex) const
|
|
|
|
{
|
|
|
|
return mI->iforh(step, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::shared_ptr<IndexWrapperBase> IndexWrapper<Index>::duplicate() const
|
|
|
|
{
|
|
|
|
return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) );
|
|
|
|
}
|
2021-06-11 18:57:00 +02:00
|
|
|
|
2020-09-11 23:29:58 +02:00
|
|
|
template <class Index>
|
|
|
|
std::shared_ptr<Index> IndexWrapper<Index>::getIndex() const
|
|
|
|
{
|
|
|
|
return mI;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Index>
|
|
|
|
std::shared_ptr<ClassicIndex> IndexWrapper<Index>::reduced() const
|
|
|
|
{
|
|
|
|
(*mCI) = mI->pos();
|
|
|
|
return mCI;
|
|
|
|
}
|
2020-09-10 22:50:26 +02:00
|
|
|
|
2020-08-27 12:00:47 +02:00
|
|
|
template <class Index>
|
2020-08-27 14:02:18 +02:00
|
|
|
inline std::shared_ptr<IndexWrapperBase> mkIndexWrapper(const Index& i)
|
2020-08-27 12:00:47 +02:00
|
|
|
{
|
|
|
|
return std::make_shared<IndexWrapper<Index>>(std::make_shared<Index>(i));
|
|
|
|
}
|
2020-09-11 23:29:58 +02:00
|
|
|
|
2020-08-27 12:00:47 +02:00
|
|
|
}
|