2017-02-16 11:20:40 +01:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#ifndef __index_base_h__
|
|
|
|
#define __index_base_h__
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
2017-02-16 16:06:23 +01:00
|
|
|
#include <vector>
|
2017-02-16 11:20:40 +01:00
|
|
|
|
|
|
|
#include "base_def.h"
|
|
|
|
#include "range_base.h"
|
2017-02-16 16:06:23 +01:00
|
|
|
#include "name.h"
|
2017-02-16 11:20:40 +01:00
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
2017-05-22 18:21:14 +02:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
class IndexBase
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-07-25 17:46:59 +02:00
|
|
|
DEFAULT_MEMBERS(IndexBase);
|
|
|
|
IndexBase(const RangeBase& range, size_t pos);
|
|
|
|
virtual ~IndexBase() = default;
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
virtual IndexBase& operator=(size_t pos) = 0;
|
|
|
|
virtual IndexBase& operator++() = 0;
|
|
|
|
virtual IndexBase& operator--() = 0;
|
|
|
|
virtual IndexBase& operator+=(int n) = 0;
|
|
|
|
virtual IndexBase& operator-=(int n) = 0;
|
2017-02-17 18:10:03 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
bool operator==(const IndexBase& in) const;
|
|
|
|
bool operator!=(const IndexBase& in) const;
|
2017-02-16 11:20:40 +01:00
|
|
|
|
|
|
|
virtual size_t dim() const = 0;
|
2017-02-21 17:41:48 +01:00
|
|
|
virtual size_t pos() const;
|
2017-07-25 17:46:59 +02:00
|
|
|
virtual size_t max() const;
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
virtual bool last() const = 0;
|
|
|
|
virtual bool first() const = 0;
|
2017-05-22 18:21:14 +02:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
virtual operator size_t() const;
|
2017-02-16 11:20:40 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
std::shared_ptr<RangeBase> mRangePtr;
|
|
|
|
size_t mPos;
|
2017-02-16 11:20:40 +01:00
|
|
|
};
|
2017-07-25 17:46:59 +02:00
|
|
|
|
|
|
|
template <typename MetaType>
|
|
|
|
class IndexInterface : public IndexBase
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-02-22 00:43:38 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
IndexInterface(const RangeBase& range, size_t pos);
|
2017-02-28 11:27:23 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
MetaType& meta() = 0;
|
|
|
|
const MetaType& meta() const = 0;
|
2017-02-16 11:20:40 +01:00
|
|
|
};
|
2017-07-25 17:46:59 +02:00
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "index_base.cc"
|
|
|
|
|
|
|
|
#endif
|