cnorxz/src/ranges/index_info.h

82 lines
1.8 KiB
C
Raw Normal View History

2017-12-24 18:14:07 +01:00
// -*- C++ -*-
#ifndef __index_info_h__
#define __index_info_h__
#include <cstdlib>
2017-12-25 01:35:09 +01:00
#include <cstdint>
2017-12-24 18:14:07 +01:00
#include <vector>
2017-12-25 01:35:09 +01:00
#include <memory>
#include "vindex_base.h"
#include "index_type.h"
2017-12-24 18:14:07 +01:00
namespace MultiArrayTools
{
class IndexInfo;
class IndexInfo
{
public:
2017-12-25 01:35:09 +01:00
IndexInfo(IndexInfo&& in) = default;
IndexInfo& operator=(IndexInfo&& in) = default;
2017-12-25 13:44:55 +01:00
//IndexInfo(const IndexInfo& in) = default;
//IndexInfo& operator=(const IndexInfo& in) = default;
2017-12-25 01:35:09 +01:00
2017-12-24 18:14:07 +01:00
template <class IndexClass>
IndexInfo(const IndexClass& ind, size_t stepSize = 1);
2017-12-25 01:35:09 +01:00
2017-12-25 13:44:55 +01:00
template <class IndexClass>
IndexInfo& reassign(const IndexClass& ind, size_t stepSize = 1);
2017-12-25 01:35:09 +01:00
bool operator==(const IndexInfo& in) const;
bool operator!=(const IndexInfo& in) const;
bool operator<=(const IndexInfo& in) const;
bool operator<(const IndexInfo& in) const;
bool operator>(const IndexInfo& in) const;
bool operator>=(const IndexInfo& in) const;
2017-12-24 18:14:07 +01:00
const IndexInfo* getPtr(size_t inum) const;
std::intptr_t getPtrNum() const;
size_t dim() const;
2017-12-25 01:35:09 +01:00
size_t max() const;
2017-12-24 18:14:07 +01:00
size_t getStepSize(size_t inum) const;
size_t getStepSize() const;
2017-12-25 01:35:09 +01:00
IndexType type() const;
2017-12-24 18:14:07 +01:00
private:
2017-12-25 01:35:09 +01:00
IndexInfo() = default;
2017-12-24 18:14:07 +01:00
std::vector<IndexInfo> mNext;
std::intptr_t mPtrNum;
size_t mDim;
2017-12-25 01:35:09 +01:00
size_t mMax;
2017-12-24 18:14:07 +01:00
size_t mStepSize;
2017-12-25 01:35:09 +01:00
IndexType mType;
2017-12-24 18:14:07 +01:00
};
template <class IndexClass>
IndexInfo::IndexInfo(const IndexClass& ind, size_t stepSize) :
mNext(ind.infoVec()),
mPtrNum( reinterpret_cast<std::intptr_t>( &ind ) ),
2017-12-25 01:35:09 +01:00
mDim(ind.vrange()->dim()),
mMax(ind.max()),
2017-12-24 18:14:07 +01:00
mStepSize(stepSize)
{}
2017-12-25 13:44:55 +01:00
template <class IndexClass>
IndexInfo& IndexInfo::reassign(const IndexClass& ind, size_t stepSize)
{
IndexInfo ii(ind, stepSize);
(*this) = std::move(ii);
return *this;
}
2017-12-24 18:14:07 +01:00
} // end namespace MultiArrayTools
#endif