CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
range_base.cc
Go to the documentation of this file.
1// -*- C++ -*-
12#include "ranges/ranges.h"
13#include "array/array.h"
14
15namespace CNORXZ
16{
17
18 /*=======================+
19 | RangeFactoryBase |
20 +=======================*/
21
22 Map<SizeT,Map<Vector<Uuid>,RangePtr>> RangeFactoryBase::sCreated;
23
25 {
26 if(not mProd) {
27 this->make();
28 mProd->mThis = mProd;
29 }
30 return mProd;
31 }
32
34 {
35 RangePtr out = nullptr;
36 if(sCreated.count(info.hash_code()) != 0){
37 if(sCreated[info.hash_code()].count(rids) != 0){
38 out = sCreated[info.hash_code()][rids];
39 }
40 }
41 return out;
42 }
43
45 {
46 sCreated[info.hash_code()][rids] = r;
47 }
48
50 {
51 CXZ_ASSERT(r != nullptr, "got range ptr to null");
52 auto& rx = sCreated[info.hash_code()][r->key()];
53 if(rx == nullptr){
54 rx = r;
55 }
56 return rx;
57 }
58
59 /*================+
60 | RangeBase |
61 +================*/
62
64 {
65 mId = mkUuid();
66 }
67
69 {
70 return nullptr;
71 }
72
74 {
75 return MArray<RangePtr>();
76 }
77
79 {
80 return this == &in;
81 }
82
84 {
85 return this != &in;
86 }
87
89 {
90 //return reinterpret_cast<PtrId>(this);
91 return mId;
92 }
93
95 {
96 return this->index(0);
97 }
98
100 {
101 return this->index(this->size());
102 }
103
104 /*==========================+
105 | Non-member functions |
106 +==========================*/
107
108 RangePack::operator RangePtr() const
109 {
110 return YRangeFactory(mRs).create();
111 }
112
114 {
115 CXZ_ASSERT(a != nullptr, "first operand not initialized");
116 CXZ_ASSERT(b != nullptr, "second operand not initialized");
117
118 return RangePack { Vector<RangePtr> { a, b } };
119 //return YRangeFactory(rvec).create();
120 }
121
123 {
124 CXZ_ASSERT(a != nullptr, "first operand not initialized");
125
126 RangePack o { { a } };
127 o.mRs.insert(o.mRs.end(), b.mRs.begin(), b.mRs.end());
128 return o;
129 }
130
132 {
133 CXZ_ASSERT(b != nullptr, "first operand not initialized");
134
135 RangePack o = a;
136 o.mRs.push_back(b);
137 return o;
138 }
139
141 {
142 RangePack o = a;
143 o.mRs.insert(o.mRs.end(), b.mRs.begin(), b.mRs.end());
144 return o;
145 }
146
148 {
149 RangePtr o = r->sub(num);
150 CXZ_ASSERT(o != nullptr, "try to access empty subrange at position " << num);
151 return o;
152 }
153
155 {
156 MArray<RangePtr> o = r->sub();
157 CXZ_ASSERT(o.range() != nullptr, "try to access subrange of single range");
158 return o;
159 }
160
161} // end namespace CNORXZ
Array main header.
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
virtual RangePtr range() const
DIndex begin() const
Definition range_base.cc:94
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 SizeT size() const =0
DIndex end() const
Definition range_base.cc:99
bool operator==(const RangeBase &in) const
Definition range_base.cc:78
virtual DIndex index(SizeT pos=0) 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
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)
Uuid mkUuid()
Definition uuid.cc:38
Ranges main header.
Vector< RangePtr > mRs
Definition range_base.h:237