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:
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 
87 
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);
213  r_Ref(const r_Ref<T> &);
214 
217 
219  operator r_Ref_Any() const;
220 
221  // cast to const r_Ref_Any
222  // operator const r_Ref_Any() const;
223 
226 
229 
230  // assignment operator for assigning a r_Ref pointer
231  // r_Ref<T>& operator=( r_Ref<T>& );
232 
235 
237  const T &operator*() const;
238 
240  T &operator*();
246  const T *operator->() const;
247 
255  const T *ptr() const;
256 
258  T *ptr();
265  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 
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
The class represents a generic MDD in the sense that it is independent of the cell base type.
Definition: gmarray.hh:66
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition: minterval.hh:226
Class r_OId represents an object identifier.
Definition: oid.hh:39
Through inheritance of this class, the type definer specifies that the subclass is capable of having ...
Definition: object.hh:62
r_Object(r_Transaction *transaction=NULL)
default constructor
Class r_Point represents an n-dimensional point vector.
Definition: point.hh:43
Class r_Primitive represents a primitive (atomic) type value.
Definition: primitive.hh:43
The class r_Ref_Any is defined to support a reference to any type.
Definition: ref.hh:65
int operator!=(const r_Object *) const
compares the memory pointer (does not load the object)
r_Ref_Any(const r_Ref_Any &)
copy constructor
int is_null() const
method for reference validity test
unsigned int is_oid_valid() const
r_Ref_Any(void *)
constructor getting a general pointer
r_Transaction * get_transaction() const
get transaction
int operator==(const r_Ref_Any &) const
The method delivers true iff the oid and/or the memory pointer are valid.
int operator!=(const r_Ref_Any &) const
const r_OId & get_oid() const
get oid
r_Ref_Any()
default constructor
int operator==(const r_Object *) const
compares the memory pointer (does not load the object)
r_Ref_Any(const r_OId &initOId, r_Transaction *ta=NULL)
constructor for creating a reference with an oid
void delete_object()
deletes referenced object from main memory and database
r_Ref_Any & operator=(r_Object *)
assignment operator for assigning a pointer to a persistent capable object
r_Ref_Any(r_Object *)
Dereferencing the self object results in loading the object with initOId.
void * get_memory_ptr() const
get memory pointer (without loading the object)
r_Ref_Any & operator=(const r_Ref_Any &)
assignment operator for assigning a r_Ref_Any pointer
~r_Ref_Any()
destructor deletes referenced object from main memory and database
void destroy()
delete from main memory
int operator!() const
operator for validity test
r_Transaction * ta
Definition: ref.hh:169
References of type r_Ref in many respects behave like C++ pointers but provide an additional mechanis...
Definition: ref.hh:198
~r_Ref()
destructor deletes referenced object from main memory and database
r_Ref()
default constructor
void destroy()
delete from main memory
int is_null() const
method for reference validity test
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 ...
int operator!=(const r_Ref< T > &refR) const
r_Ref< T > & operator=(const r_Ref< T > &)
assignment operator for assigning a r_Ref pointer
int operator!=(const T *) const
compares the memory pointer (does not load the object)
r_Ref< T > & operator=(T *)
assignment operator for assigning a C pointer
void delete_object()
deletes referenced object from main memory and database
r_Ref(const r_Ref_Any &)
constructor for r_Ref_Any objects
const r_OId & get_oid() const
get oid
r_Transaction * ta
Definition: ref.hh:317
T * ptr()
method for dereferencing the reference (error kinds: r_Error_RefNull, r_Error_RefInvalid)
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...
T * get_memory_ptr() const
get memory pointer (without loading the object)
r_Ref(const r_OId &, T *, r_Transaction *ta=NULL)
constructor getting oid and memory pointer
r_Ref< T > & operator=(const r_Ref_Any &)
assignment operator for assigning a r_Ref_Any
T & operator*()
dereference operator (error kinds: r_Error_RefNull, r_Error_RefInvalid)
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_Ref(const r_Ref< T > &)
Dereferencing the self object results in loading the object with initOId.
unsigned int is_oid_valid() const
T * operator->()
operator for dereferencing the reference (error kinds: r_Error_RefNull, r_Error_RefInvalid)
r_Ref(const r_OId &initOId, r_Transaction *ta=NULL)
constructor for creating a reference with an oid
int operator==(const r_Ref< T > &refR) const
The method delivers true iff the oid and/or the memory pointer are valid.
int operator==(const T *) const
compares the memory pointer (does not load the object)
const T & operator*() const
dereference operator (error kinds: r_Error_RefNull, r_Error_RefInvalid)
Class r_Scalar represents a scalar type value which is either r_Primitive or r_Structure.
Definition: scalar.hh:43
The class implements a set container.
Definition: set.hh:42
The class represents an interval with lower and upper bound.
Definition: sinterval.hh:214
Class r_Structure represents a structured value.
Definition: structure.hh:42
Transactions can be started, committed, aborted, and checkpointed.
Definition: transaction.hh:50