2017-02-16 11:20:40 +01:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
#ifndef __cxz_mrange_h__
|
|
|
|
#define __cxz_mrange_h__
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
#include "base/base.h"
|
|
|
|
#include "range_base.h"
|
|
|
|
#include "index_base.h"
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2021-07-28 20:29:56 +02:00
|
|
|
namespace CNORXZ
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
template <class... Indices>
|
2022-09-18 18:53:38 +02:00
|
|
|
class MIndex : public IndexInterface<MIndex<Indices...>,
|
|
|
|
Tuple<typename Indices::MetaType...> >
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
2017-02-20 17:18:53 +01:00
|
|
|
public:
|
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
typedef IndexInterface<MIndex<Indices...>,
|
2022-09-11 02:48:30 +02:00
|
|
|
Tuple<typename Indices::MetaType...> > IB;
|
|
|
|
typedef Tuple<Sptr<Indices>...> IndexPack;
|
|
|
|
typedef Tuple<typename Indices::MetaType...> MetaType;
|
2022-09-18 18:53:38 +02:00
|
|
|
typedef MRange<typename Indices::RangeType...> RangeType;
|
2018-07-28 15:27:11 +02:00
|
|
|
|
2017-02-28 19:29:52 +01:00
|
|
|
// NO DEFAULT HERE !!!
|
2017-07-26 16:45:09 +02:00
|
|
|
// ( have to assign sub-indices (ptr!) correctly )
|
2022-09-18 18:53:38 +02:00
|
|
|
MIndex(const MIndex& i);
|
|
|
|
MIndex(MIndex&& i);
|
|
|
|
MIndex& operator=(const MIndex& i);
|
|
|
|
MIndex& operator=(MIndex&& i);
|
2017-05-24 19:01:02 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
MIndex(const RangePtr& range, SizeT pos = 0);
|
2017-08-28 18:28:43 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
// replace sub-index instances; only use if you know what you are doing!
|
|
|
|
MIndex& operator()(Sptr<Indices>&... indices);
|
|
|
|
MIndex& operator()(const MIndex& indices);
|
2017-07-26 16:45:09 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
const IndexPack& pack() const { return mIPack; }
|
|
|
|
const auto& getBlockSizes() const { return mBlockSizes; }
|
2017-07-25 17:46:59 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
MIndex& operator=(SizeT pos);
|
|
|
|
MIndex& operator++();
|
|
|
|
MIndex& operator--();
|
|
|
|
MIndex operator+(Int n) const;
|
|
|
|
MIndex operator-(Int n) const;
|
|
|
|
MIndex& operator+=(Int n);
|
|
|
|
MIndex& operator-=(Int n);
|
2017-12-11 18:49:43 +01:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
SizeT operator*() const;
|
|
|
|
SizeT operator->() const;
|
2017-12-11 18:49:43 +01:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
int pp(PtrId idxPtrNum);
|
|
|
|
int mm(PtrId idxPtrNum);
|
2017-12-11 18:49:43 +01:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
SizeT dim();
|
|
|
|
Sptr<RangeType> range();
|
2022-09-18 22:50:07 +02:00
|
|
|
SizeT getStepSize(PtrId iptr) const;
|
2017-12-11 18:49:43 +01:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
String stringMeta() const;
|
|
|
|
MetaType meta() const;
|
|
|
|
MIndex& at(const MetaType& metaPos);
|
|
|
|
|
|
|
|
/*
|
2018-01-13 18:07:52 +01:00
|
|
|
template <class Exprs>
|
2022-09-11 02:48:30 +02:00
|
|
|
auto ifor(SizeT step, Exprs exs) const;
|
2018-01-15 14:56:22 +01:00
|
|
|
|
|
|
|
template <class Exprs>
|
2022-09-11 02:48:30 +02:00
|
|
|
auto iforh(SizeT step, Exprs exs) const;
|
2018-01-15 14:56:22 +01:00
|
|
|
|
2019-01-15 17:41:43 +01:00
|
|
|
template <class Exprs>
|
2022-09-11 02:48:30 +02:00
|
|
|
auto pifor(SizeT step, Exprs exs) const;
|
2022-09-18 18:53:38 +02:00
|
|
|
*/
|
|
|
|
private:
|
|
|
|
MIndex() = default;
|
|
|
|
|
|
|
|
IndexPack mIPack;
|
|
|
|
Arr<SizeT,sizeof...(Indices)+1> mBlockSizes;
|
|
|
|
Sptr<RangeType> mRange;
|
2019-01-15 17:41:43 +01:00
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
};
|
|
|
|
|
2017-07-26 18:38:11 +02:00
|
|
|
|
2018-07-16 17:40:39 +02:00
|
|
|
// NOT THREAD SAVE
|
2017-07-26 18:38:11 +02:00
|
|
|
template <class... Ranges>
|
2022-09-18 18:53:38 +02:00
|
|
|
class MRangeFactory : public RangeFactoryBase
|
2017-07-26 18:38:11 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-09-18 18:53:38 +02:00
|
|
|
MRangeFactory() = delete;
|
|
|
|
MRangeFactory(const Sptr<Ranges>&... rs);
|
|
|
|
MRangeFactory(const Tuple<Sptr<Ranges>...>& rs);
|
2017-07-28 11:33:31 +02:00
|
|
|
|
2018-07-16 17:40:39 +02:00
|
|
|
private:
|
2022-09-18 18:53:38 +02:00
|
|
|
virtual void make() override final;
|
|
|
|
|
|
|
|
Tuple<Sptr<Ranges>...> mRs;
|
2017-07-26 18:38:11 +02:00
|
|
|
};
|
2017-02-21 17:41:48 +01:00
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
template <class... Ranges>
|
2022-09-18 18:53:38 +02:00
|
|
|
class MRange : public RangeInterface<MIndex<typename Ranges::IndexType...> >
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-08-04 11:27:47 +02:00
|
|
|
typedef RangeBase RB;
|
2022-09-18 18:53:38 +02:00
|
|
|
typedef MIndex<typename Ranges::IndexType...> IndexType;
|
2022-09-11 02:48:30 +02:00
|
|
|
typedef Tuple<typename Ranges::IndexType::MetaType...> MetaType;
|
2017-02-20 17:18:53 +01:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
const Space& space() const;
|
2017-08-04 14:57:19 +02:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
SizeT getMeta(const MetaType& metaPos) const;
|
2021-01-11 11:16:29 +01:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
virtual Sptr<RangeBase> sub(SizeT num) const override;
|
2018-11-30 00:16:28 +01:00
|
|
|
|
2022-09-11 02:48:30 +02:00
|
|
|
virtual SizeT dim() const final;
|
|
|
|
virtual SizeT size() const final;
|
2018-07-21 18:05:53 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
virtual String stringMeta(SizeT pos) const final;
|
2017-02-28 19:29:52 +01:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
friend MRangeFactory<Ranges...>;
|
2017-05-24 19:01:02 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
protected:
|
|
|
|
MRange() = delete;
|
|
|
|
MRange(const MRange& in) = delete;
|
|
|
|
MRange& operator=(const MRange& in) = delete;
|
2018-05-20 20:03:44 +02:00
|
|
|
|
2022-09-18 18:53:38 +02:00
|
|
|
Tuple<Sptr<Ranges>...> mRs;
|
2017-12-15 14:47:02 +01:00
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|