CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
range_base.h
Go to the documentation of this file.
1// -*- C++ -*-
15#ifndef __cxz_range_base_h__
16#define __cxz_range_base_h__
17
18#include "base/base.h"
19#include "base/base.cc.h"
20#include "memory/memory.h"
21#include "memory/memory.cc.h"
22
23#ifdef HAVE_CEREAL
24#include <cereal/access.hpp>
25#endif
26
27namespace CNORXZ
28{
29
49 {
50 public:
51
53 RangeFactoryBase() = default;
54
56 virtual ~RangeFactoryBase() = default;
57
60
61 static RangePtr getRegistered(const TypeInfo& info, const RangePtr& r);
62 // check if range with uuid of r exists; if yes, return existing one, else add r and return it
63
64 protected:
65
67 virtual void make() = 0;
68
70 RangePtr fromCreated(const TypeInfo& info, const Vector<Uuid>& rids) const;
71
73 void addToCreated(const TypeInfo& info, const Vector<Uuid>& rids, const RangePtr& r);
74
77 private:
78
79 static Map<SizeT,Map<Vector<Uuid>,RangePtr>> sCreated;
81 };
82
95 {
96 public:
98
100 virtual ~RangeBase() = default;
101
107 virtual RangePtr sub(SizeT num) const;
108
113 virtual MArray<RangePtr> sub() const;
114
116 virtual SizeT size() const = 0;
117
123 virtual SizeT dim() const = 0;
124
126 virtual const TypeInfo& type() const = 0;
127
129 virtual const TypeInfo& metaType() const = 0;
130
134 virtual String stringMeta(SizeT pos) const = 0;
135
139 virtual DIndex index(SizeT pos = 0) const = 0;
140
146 virtual RangePtr extend(const RangePtr& r) const = 0;
147
149 bool operator==(const RangeBase& in) const;
150
152 bool operator!=(const RangeBase& in) const;
153
155 Uuid id() const;
156
158 DIndex begin() const;
159
161 DIndex end() const;
162
164
165 protected:
166
168 RangeBase();
169
170 virtual Vector<Uuid> key() const = 0;
171 // delete copy/move???
172 Uuid mId = {0,0};
174 };
175
184 template <class Range>
186 {
187 public:
188
189 typedef RangeBase RB;
190
192 decltype(auto) begin() const;
193
195 decltype(auto) end() const;
196
197 virtual DIndex index(SizeT pos) const override final;
198
199 protected:
201 RangeInterface() = default;
202 };
203
212 template <class Range>
214 {
218 static Sptr<Range> func(const RangePtr& r);
219 };
220
226 template <class Range>
228
236 {
240 operator RangePtr() const;
241 };
242
247 RangePack operator*(const RangePtr& a, const RangePtr& b);
248
253 RangePack operator*(const RangePtr& a, const RangePack& b);
254
259 RangePack operator*(const RangePack& a, const RangePtr& b);
260
265 RangePack operator*(const RangePack& a, const RangePack& b);
266
267 RangePtr getSub(const RangePtr& r, SizeT num);
269
270}
271
272#endif
basic cc headers
basic headers
DIndex begin() const
Definition range_base.cc:94
Wptr< RangeBase > mThis
Definition range_base.h:173
virtual MArray< RangePtr > sub() const
Definition range_base.cc:73
Uuid id() const
Definition range_base.cc:88
bool operator!=(const RangeBase &in) const
Definition range_base.cc:83
virtual ~RangeBase()=default
virtual SizeT size() const =0
friend RangeFactoryBase
Definition range_base.h:163
virtual String stringMeta(SizeT pos) const =0
DIndex end() const
Definition range_base.cc:99
virtual RangePtr extend(const RangePtr &r) const =0
virtual SizeT dim() const =0
virtual const TypeInfo & metaType() const =0
bool operator==(const RangeBase &in) const
Definition range_base.cc:78
virtual const TypeInfo & type() const =0
virtual DIndex index(SizeT pos=0) const =0
virtual Vector< Uuid > key() const =0
virtual void make()=0
RangePtr fromCreated(const TypeInfo &info, const Vector< Uuid > &rids) const
Definition range_base.cc:33
void addToCreated(const TypeInfo &info, const Vector< Uuid > &rids, const RangePtr &r)
Definition range_base.cc:44
static RangePtr getRegistered(const TypeInfo &info, const RangePtr &r)
Definition range_base.cc:49
virtual ~RangeFactoryBase()=default
virtual DIndex index(SizeT pos) const override final
decltype(auto) begin() const
decltype(auto) end() const
Memory template implementations main header.
Memory main heade.
std::string String
Definition types.h:42
std::type_info TypeInfo
Definition types.h:71
uint64_t SizeT
Definition types.h:38
Sptr< RangeBase > RangePtr
Definition types.h:157
RangePtr getSub(const RangePtr &r, SizeT num)
std::vector< T, Allocator< T > > Vector
Definition types.h:310
Sptr< Range > rangeCast(const RangePtr r)
constexpr decltype(auto) operator*(const COpInterface< Op1 > &op1, const COpInterface< Op2 > &op2)
std::map< K, V > Map
Definition types.h:69
std::weak_ptr< T > Wptr
Definition types.h:51
std::shared_ptr< T > Sptr
Definition types.h:48
static Sptr< Range > func(const RangePtr &r)
Vector< RangePtr > mRs
Definition range_base.h:237