rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
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/oid.hh"
37 
38 #include <cstdlib>
39 
40 // forward declarations
41 class r_Database;
42 class r_Transaction;
43 class r_Type;
44 
45 //@ManMemo: Module: {\bf rasodmg}
46 
61 class r_Object
62 {
63 public:
66 
68  r_Object(unsigned short objType, r_Transaction *transaction = NULL);
75  r_Object(const r_Object &, unsigned short objType = 0, r_Transaction *transaction = NULL);
83  virtual ~r_Object();
85 
87  void mark_modified();
88 
90  void *operator new(size_t size);
91 
93  void *operator new(size_t size, r_Database *database, const char *type_name = 0);
94 
96  void *operator new(size_t size, const char *type_name);
97 
99  void operator delete(void *obj_ptr);
100 
102  void set_type_by_name(const char *name);
113  void set_type_structure(const char *name);
115 
117  const char *get_type_name() const;
118 
120  const char *get_type_structure() const;
121 
123  const r_OId &get_oid() const;
124 
126  const r_Type *get_type_schema();
127 
128  void set_type_schema(const r_Type *type);
129 
130  //@Man: Methods and types for internal use only:
132 
136  {
142  transient
143  };
154  enum ObjectType
156  {
160  };
161 
164  virtual void insert_obj_into_db() = 0;
166  virtual void insert_obj_into_db(const char *) = 0;
168  virtual void update_obj_in_db();
170  virtual void load_obj_from_db();
172  void delete_obj_from_db();
173 
176  void initialize_oid(const r_OId &initOId);
177 
180  virtual void r_activate()
181  {
182  ;
183  }
185  virtual void r_deactivate();
186 
189  bool test_status(ObjectStatus status);
191  ObjectStatus get_status() const;
192 
195  void set_object_name(const char *name);
197  const char *get_object_name() const;
198 
201  void *operator new(size_t size, r_Database *database, ObjectStatus status, const r_OId &oid);
202 
204 
205 
207 
208 protected:
210  void update_transaction();
211 
213  bool test_type(ObjectType type);
214 
216  char *object_name{0};
217 
219  char *type_name{0};
220 
222  char *type_structure{0};
223 
226 
228  unsigned short internal_obj_type{0};
229 
233 
234 private:
236  ObjectStatus object_status;
237 
239  ObjectType object_type;
240 
242  r_OId oid;
243 
245  static ObjectType next_object_type;
246 
248  static ObjectStatus next_object_status;
249 
251  static char *next_object_type_name;
252 
254  static r_OId next_object_oid;
255 
257  static ObjectType last_object_type;
258 };
259 
260 #endif
r_Object::ObjectType
ObjectType
created - The object was created in the current transaction and has to be stored in the database.
Definition: object.hh:155
r_Object::r_deactivate
virtual void r_deactivate()
it is called when an object leaves transient memory
r_Object::test_type
bool test_type(ObjectType type)
test object type returns 1 if it matches
r_Object::test_status
bool test_status(ObjectStatus status)
test object status returns 1 if it matches
r_Object::r_activate
virtual void r_activate()
it is called when an object comes into transient memory
Definition: object.hh:180
r_Object::type_structure
char * type_structure
store type structure as string if it has one
Definition: object.hh:222
r_Object::transaction
r_Transaction * transaction
pointer to the transaction this object belongs to.
Definition: object.hh:232
r_Object::type_schema
r_Type * type_schema
pointer to type schema (built on request)
Definition: object.hh:225
r_Object::load_obj_from_db
virtual void load_obj_from_db()
load an object from the database
r_Object::created
@ created
Definition: object.hh:139
oid.hh
r_Object::delete_obj_from_db
void delete_obj_from_db()
deletes an object from the database
r_Object::type_name
char * type_name
stores object type name if it has one
Definition: object.hh:219
r_Object::internal_obj_type
unsigned short internal_obj_type
internal object type (1 marray, 2 collection)
Definition: object.hh:228
r_Object::get_transaction
r_Transaction * get_transaction() const
r_Object::update_obj_in_db
virtual void update_obj_in_db()
updates an object in database
r_Object::object_name
char * object_name
stores object name if it has one
Definition: object.hh:216
r_Object::~r_Object
virtual ~r_Object()
objType specifies the type of the object (1=Marray, 2=Collection).
r_Object::initialize_oid
void initialize_oid(const r_OId &initOId)
initialize oid of the object
r_Object::modified
@ modified
Definition: object.hh:140
r_Type
This class the superclass for all types in the ODMG conformant representation of the RasDaMan type sy...
Definition: type.hh:50
r_Object::get_type_structure
const char * get_type_structure() const
get object type structure
r_Object::no_status
@ no_status
Definition: object.hh:137
r_Object::transient_object
@ transient_object
Definition: object.hh:159
r_Object::get_type_schema
const r_Type * get_type_schema()
get type schema. returns NULL in case of error
r_Object::deleted
@ deleted
Definition: object.hh:138
r_Object::set_object_name
void set_object_name(const char *name)
set object name. object name should contain only [a-zA-Z0-9_]
r_Object::persistent_object
@ persistent_object
Definition: object.hh:158
r_Transaction
Transactions can be started, committed, aborted, and checkpointed.
Definition: transaction.hh:49
r_Object::set_type_schema
void set_type_schema(const r_Type *type)
r_Object
Through inheritance of this class, the type definer specifies that the subclass is capable of having ...
Definition: object.hh:61
r_Object::mark_modified
void mark_modified()
mark the object as modified
r_Object::read
@ read
Definition: object.hh:141
r_Object::get_object_name
const char * get_object_name() const
get object name
r_Object::get_status
ObjectStatus get_status() const
gets the status of the object
r_Object::no_object
@ no_object
Definition: object.hh:157
r_Object::ObjectStatus
ObjectStatus
object life status
Definition: object.hh:135
r_Object::insert_obj_into_db
virtual void insert_obj_into_db()=0
inserts an object into the database
r_Database
A database object must be instantiated and opened before starting any transaction which uses the data...
Definition: database.hh:59
r_Object::get_type_name
const char * get_type_name() const
get object type name
r_Object::update_transaction
void update_transaction()
resets to the global r_Transaction::actual_transaction if necessary
r_Object::set_type_structure
void set_type_structure(const char *name)
With this method a type name has to be given by the user for each object which he wants to make persi...
r_OId
Class r_OId represents an object identifier.
Definition: oid.hh:38
r_Object::set_type_by_name
void set_type_by_name(const char *name)
set object type by name
r_Object::r_Object
r_Object(r_Transaction *transaction=NULL)
default constructor
r_Object::get_oid
const r_OId & get_oid() const
get oid