rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
ref.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
33 #ifndef _D_REF_
34 #define _D_REF_
35 
36 #include "raslib/oid.hh"
37 
38 class r_Object;
39 class r_Point;
40 class r_Sinterval;
41 class r_Minterval;
42 class r_Scalar;
43 class r_Primitive;
44 class r_Structure;
45 class r_Transaction;
46 
47 //@ManMemo: Module: <b>rasodmg</b>
48 
64 class r_Ref_Any
65 {
66 public:
68  r_Ref_Any();
69 
71  r_Ref_Any(const r_Ref_Any &);
72 
74  r_Ref_Any(const r_OId &initOId, r_Transaction *ta = NULL);
81 
83  r_Ref_Any(void *);
84 
86  ~r_Ref_Any();
87 
89  r_Ref_Any &operator=(const r_Ref_Any &);
90 
93 
95  void destroy();
96 
98  void delete_object();
99 
100  //@Man: Cast operators:
102 
105  operator const void *() const;
107  operator void *();
109  operator r_Point *();
111  operator r_Sinterval *();
113  operator r_Minterval *();
115  operator r_OId *();
117  operator r_Scalar *();
119  operator r_Structure *();
121  operator r_Primitive *();
122 
124 
125 
127  int operator!() const;
128 
130  int is_null() const;
135  //@Man: Comparison operators:
137 
140  int operator==(const r_Ref_Any &) const;
142  int operator!=(const r_Ref_Any &) const;
144  int operator==(const r_Object *) const;
146  int operator!=(const r_Object *) const;
147 
149 
150 
152  const r_OId &get_oid() const;
153 
154  //@Man: Methods for internal use only
156  r_Ref_Any(const r_OId &, r_Object *, r_Transaction *ta = NULL);
160  unsigned int is_oid_valid() const;
162  void *get_memory_ptr() const;
166 
167 
168 protected:
170 
171 private:
173  void *memptr{NULL};
174 
176  r_OId oid;
177 };
178 
179 //@ManMemo: Module: <b>rasodmg</b>
180 
196 template <class T>
197 class r_Ref
198 {
199 public:
201  r_Ref();
202 
204  r_Ref(const r_Ref_Any &);
205 
207  r_Ref(const r_OId &initOId, r_Transaction *ta = NULL);
212  r_Ref(const r_Ref<T> &);
214 
216  ~r_Ref();
217 
219  operator r_Ref_Any() const;
220 
221  // cast to const r_Ref_Any
222  // operator const r_Ref_Any() const;
223 
225  r_Ref<T> &operator=(const r_Ref_Any &);
226 
228  r_Ref<T> &operator=(T *);
229 
230  // assignment operator for assigning a r_Ref pointer
231  // r_Ref<T>& operator=( r_Ref<T>& );
232 
234  r_Ref<T> &operator=(const r_Ref<T> &);
235 
237  const T &operator*() const;
238 
240  T &operator*();
246  const T *operator->() const;
247 
249  T *operator->();
255  const T *ptr() const;
256 
258  T *ptr();
264  int operator!() const;
266 
268  int is_null() const;
273  //@Man: Comparison operators:
275 
278  int operator==(const r_Ref<T> &refR) const;
280  int operator!=(const r_Ref<T> &refR) const;
282  int operator==(const T *) const;
284  int operator!=(const T *) const;
285 
287 
288 
290  void destroy();
291 
293  void delete_object();
294 
296  const r_OId &get_oid() const;
297 
298  //@Man: Methods for internal use only
300  r_Ref(T *, r_Transaction *ta = NULL);
303 
305  r_Ref(const r_OId &, T *, r_Transaction *ta = NULL);
306 
308  T *get_memory_ptr() const;
309 
311  unsigned int is_oid_valid() const;
312 
314 
315 
316 protected:
318 
319 private:
321  void load_object() const;
322 
324  mutable T *memptr;
325 
327  r_OId oid;
328 };
329 
330 class r_GMarray;
331 extern template class r_Ref<r_GMarray>;
332 class r_Object;
333 extern template class r_Ref<r_Object>;
334 
335 template <typename T>
336 class r_Set;
337 extern template class r_Ref<r_Set<r_Ref<r_GMarray>>>;
338 
339 class r_Point;
340 extern template class r_Ref<r_Point>;
341 class r_Sinterval;
342 extern template class r_Ref<r_Sinterval>;
343 class r_Minterval;
344 extern template class r_Ref<r_Minterval>;
345 class r_OId;
346 extern template class r_Ref<r_OId>;
347 class r_Scalar;
348 extern template class r_Ref<r_Scalar>;
349 
350 #endif
r_Ref::get_memory_ptr
T * get_memory_ptr() const
get memory pointer (without loading the object)
r_Structure
Class r_Structure represents a structured value.
Definition: structure.hh:41
r_Ref_Any::operator==
int operator==(const r_Ref_Any &) const
The method delivers true iff the oid and/or the memory pointer are valid.
r_Ref_Any::r_Ref_Any
r_Ref_Any()
default constructor
r_Ref::is_null
int is_null() const
method for reference validity test
oid.hh
r_Ref::operator*
const T & operator*() const
dereference operator (error kinds: r_Error_RefNull, r_Error_RefInvalid)
r_Ref::delete_object
void delete_object()
deletes referenced object from main memory and database
r_Ref_Any
The class r_Ref_Any is defined to support a reference to any type.
Definition: ref.hh:64
r_Ref::r_Ref
r_Ref()
default constructor
r_Ref_Any::is_oid_valid
unsigned int is_oid_valid() const
r_Ref
References of type r_Ref in many respects behave like C++ pointers but provide an additional mechanis...
Definition: collection.hh:196
r_Ref::destroy
void destroy()
delete from main memory
r_Ref_Any::get_transaction
r_Transaction * get_transaction() const
get transaction
r_Ref_Any::get_oid
const r_OId & get_oid() const
get oid
r_Ref_Any::is_null
int is_null() const
method for reference validity test
r_Ref::~r_Ref
~r_Ref()
destructor deletes referenced object from main memory and database
r_Point
Class r_Point represents an n-dimensional point vector.
Definition: point.hh:42
r_Set
The class implements a set container.
Definition: oqlquery.hh:31
r_Ref_Any::operator!
int operator!() const
operator for validity test
r_Transaction
Transactions can be started, committed, aborted, and checkpointed.
Definition: transaction.hh:49
r_Ref_Any::delete_object
void delete_object()
deletes referenced object from main memory and database
r_Ref::ptr
const T * ptr() const
If the memory pointer is zero and the oid is valid, the object is loaded from the server and the new ...
r_Object
Through inheritance of this class, the type definer specifies that the subclass is capable of having ...
Definition: object.hh:61
r_Ref::operator==
int operator==(const r_Ref< T > &refR) const
The method delivers true iff the oid and/or the memory pointer are valid.
r_Scalar
Class r_Scalar represents a scalar type value which is either r_Primitive or r_Structure.
Definition: scalar.hh:42
r_Ref_Any::destroy
void destroy()
delete from main memory
r_GMarray
The class represents a generic MDD in the sense that it is independent of the cell base type.
Definition: gmarray.hh:65
r_Ref::operator->
const T * operator->() const
If the memory pointer is zero and the oid is valid, the object is loaded from the server and a refere...
r_Ref_Any::ta
r_Transaction * ta
Definition: ref.hh:169
r_Ref::ta
r_Transaction * ta
Definition: ref.hh:317
r_Ref::is_oid_valid
unsigned int is_oid_valid() const
r_Minterval
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition: minterval.hh:225
r_Ref::operator=
r_Ref< T > & operator=(const r_Ref_Any &)
assignment operator for assigning a r_Ref_Any
r_Ref_Any::~r_Ref_Any
~r_Ref_Any()
destructor deletes referenced object from main memory and database
r_Ref::operator!=
int operator!=(const r_Ref< T > &refR) const
r_OId
Class r_OId represents an object identifier.
Definition: oid.hh:38
r_Ref_Any::operator!=
int operator!=(const r_Ref_Any &) const
r_Ref::get_oid
const r_OId & get_oid() const
get oid
r_Sinterval
The class represents an interval with lower and upper bound.
Definition: sinterval.hh:213
r_Ref_Any::get_memory_ptr
void * get_memory_ptr() const
get memory pointer (without loading the object)
r_Primitive
Class r_Primitive represents a primitive (atomic) type value.
Definition: primitive.hh:42
r_Ref::operator!
int operator!() const
If the memory pointer is zero and the oid is valid, the object is loaded from the server and the new ...
r_Object::r_Object
r_Object(r_Transaction *transaction=NULL)
default constructor
r_Ref_Any::operator=
r_Ref_Any & operator=(const r_Ref_Any &)
assignment operator for assigning a r_Ref_Any pointer