rasdaman API
object.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_OBJECT_
34 #define _D_OBJECT_
35 
36 #include "raslib/error.hh"
37 #include "raslib/oid.hh"
38 #include "raslib/rminit.hh"
39 
40 #include <stdlib.h>
41 
42 // forward declarations
43 class r_Database;
44 class r_Type;
45 
46 //@ManMemo: Module: {\bf rasodmg}
47 
48 /*@Doc:
49 
50  Through inheritance of this class, the type definer specifies that
51  the subclass is capable of having persistent as well as transient
52  instances.
53 
54  {\bf Attention: }Right now, just the classes \Ref{r_Set} and \Ref{r_Marray}
55  inherit from \Ref{r_Object} which, therefore, are the only persistent
56  capable classes. In fact, just objects of type {\tt r_Set<r_Ref<r_Marray<...>>>}
57  can be made persitent right now.
58 
59 */
60 
64 class r_Object
65 {
66 public:
68  r_Object();
69 
71  r_Object( unsigned short objType ) throw(r_Error);
77  r_Object( const r_Object&, unsigned short objType=0 ) throw(r_Error);
84  virtual ~r_Object();
86 
88  inline void mark_modified();
89 
91  void* operator new( size_t size );
92 
94  void* operator new( size_t size, r_Database *database, const char* type_name = 0 );
95 
97  void* operator new( size_t size, const char* type_name );
98 
100  void operator delete( void* obj_ptr );
101 
103  inline void set_type_by_name( const char* name ) throw(r_Error);
115  inline void set_type_structure( const char* name ) throw(r_Error);
117 
119  inline const char* get_type_name() const;
120 
122  inline const char* get_type_structure() const;
123 
125  inline const r_OId& get_oid() const;
126 
128  const r_Type* get_type_schema();
129 
130  void set_type_schema(const r_Type* type) throw (r_Error);
131 
132  //@Man: Methods and types for internal use only:
134 
150 
153  virtual void insert_obj_into_db()=0;
155  virtual void insert_obj_into_db( const char* )=0;
157  virtual void update_obj_in_db();
159  virtual void load_obj_from_db();
161  void delete_obj_from_db();
162 
165  void initialize_oid( const r_OId& initOId );
166 
169  virtual void r_activate()
170  {
171  ;
172  };
174  virtual void r_deactivate();
175 
178  int test_status( ObjectStatus status );
180  inline ObjectStatus get_status() const;
181 
184  inline void set_object_name( const char* name ) throw(r_Error);
186  inline const char* get_object_name() const;
187 
190  void* operator new( size_t size, r_Database *database, ObjectStatus status, const r_OId& oid );
191 
193 
194 
195 protected:
197  int test_type( ObjectType type );
198 
200  char* object_name;
201 
203  char* type_name;
204 
207 
210 
212  unsigned short internal_obj_type;
213 
214 private:
216  ObjectStatus object_status;
217 
219  ObjectType object_type;
220 
222  r_OId oid;
223 
225  static ObjectType next_object_type;
226 
228  static ObjectStatus next_object_status;
229 
231  static char* next_object_type_name;
232 
234  static r_OId next_object_oid;
235 
237  static ObjectType last_object_type;
238 };
239 
240 #include "rasodmg/object.icc"
241 
242 #endif
243 
244 
245 
246 
virtual void update_obj_in_db()
updates an object in database
r_Object()
default constructor
void delete_obj_from_db()
deletes an object from the database
int test_type(ObjectType type)
test object type returns 1 if it matches
Definition: object.hh:149
virtual void r_deactivate()
it is called when an object leaves transient memory
Definition: object.hh:137
Definition: error.hh:88
Definition: type.hh:56
void initialize_oid(const r_OId &initOId)
initialize oid of the object
const char * get_object_name() const
get object name
Definition: object.hh:149
Definition: database.hh:60
unsigned short internal_obj_type
internal object type (1 marray, 2 collection)
Definition: object.hh:212
void set_type_structure(const char *name)
set object type by name
char * object_name
stores object name if it has one
Definition: object.hh:200
virtual ~r_Object()
virtual destructor
const char * get_type_name() const
get object type name
const char * get_type_structure() const
get object type structure
Definition: object.hh:149
virtual void r_activate()
it is called when an object comes into transient memory
Definition: object.hh:169
virtual void load_obj_from_db()
load an object from the database
Definition: object.hh:137
void set_type_by_name(const char *name)
set object type by name
ObjectStatus
object life status
Definition: object.hh:137
char * type_name
stores object type name if it has one
Definition: object.hh:203
Definition: object.hh:64
const r_Type * get_type_schema()
get type schema
const r_OId & get_oid() const
get oid
Definition: object.hh:137
virtual void insert_obj_into_db()=0
inserts an object into the database
void mark_modified()
mark the object as modified
void set_object_name(const char *name)
set object name. object name should contain only [a-zA-Z0-9_]
Definition: object.hh:137
ObjectType
object types
Definition: object.hh:149
void set_type_schema(const r_Type *type)
ObjectStatus get_status() const
gets the status of the object
Definition: object.hh:137
char * type_structure
store type structure as string if it has one
Definition: object.hh:206
Definition: oid.hh:47
int test_status(ObjectStatus status)
test object status returns 1 if it matches
r_Type * type_schema
pointer to type schema (built on request)
Definition: object.hh:209