rasdaman complete source
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/error.hh"
37 #include "raslib/oid.hh"
38 
39 class r_Object;
40 class r_Point;
41 class r_Sinterval;
42 class r_Minterval;
43 class r_Oid;
44 class r_Scalar;
45 class r_Primitive;
46 class r_Structure;
47 
48 //@ManMemo: Module: {\bf rasodmg}
49 
65 class r_Ref_Any
66 {
67 public:
69  r_Ref_Any();
70 
72  r_Ref_Any( const r_Ref_Any& );
73 
75  r_Ref_Any( const r_OId& initOId );
80  r_Ref_Any( r_Object* );
82 
84  r_Ref_Any( void* );
85 
87  ~r_Ref_Any();
88 
90  r_Ref_Any& operator=( const r_Ref_Any& );
91 
93  r_Ref_Any& operator=( r_Object* );
94 
96  void destroy();
97 
99  void delete_object();
100 
101  //@Man: Cast operators:
103 
106  operator const void*() const;
108  operator void*();
110  operator r_Point*();
112  operator r_Sinterval*();
114  operator r_Minterval*();
116  operator r_OId*();
118  operator r_Scalar*();
120  operator r_Structure*();
122  operator r_Primitive*();
123 
125 
126 
127 
129  int operator!() const;
130 
132  int is_null() const;
137  //@Man: Comparison operators:
139 
142  int operator==( const r_Ref_Any& ) const;
144  int operator!=( const r_Ref_Any& ) const;
146  int operator==( const r_Object* ) const;
148  int operator!=( const r_Object* ) const;
149 
151 
152 
154  inline const r_OId& get_oid() const;
155 
156  //@Man: Methods for internal use only
158  r_Ref_Any( const r_OId&, r_Object* );
162  inline unsigned int is_oid_valid() const;
164  void* get_memory_ptr() const;
166 
167 
168 private:
170  void* memptr;
171 
173  r_OId oid;
174 };
175 
176 
177 
178 
179 //@ManMemo: Module: {\bf rasodmg}
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 );
212  r_Ref( const r_Ref<T>& );
214 
216  ~r_Ref();
217 
219  operator r_Ref_Any() const;
220 
221  // cast to const \Ref{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 throw (r_Error);
238 
240  T& operator*() throw( r_Error );
246  const T* operator->() const throw (r_Error);
247 
249  T* operator->() throw( r_Error );
255  const T* ptr() const throw (r_Error);
256 
258  T* ptr() throw( r_Error );
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  inline const r_OId& get_oid() const;
297 
298  //@Man: Methods for internal use only
300  r_Ref( T* );
303 
305  r_Ref( const r_OId&, T* );
306 
308  T* get_memory_ptr() const;
309 
311  inline unsigned int is_oid_valid() const;
312 
314 
315 
316 private:
318  void load_object() const;
319 
321  mutable T* memptr;
322 
324  r_OId oid;
325 };
326 
327 #include "rasodmg/ref.icc"
328 
329 #endif