rasdaman base DBMS
objectbroker.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 */
23 #ifndef _OBJECTBROKER_HH_
24 #define _OBJECTBROKER_HH_
25 
26 class ObjectBroker;
27 class ULongType;
28 class LongType;
29 class CharType;
30 class BoolType;
31 class UShortType;
32 class ShortType;
33 class OctetType;
34 class DoubleType;
35 class FloatType;
36 class ComplexType1;
37 class ComplexType2;
38 class StructType;
39 class BaseType;
40 class SetType;
41 class MDDType;
42 class Type;
43 class DBObject;
44 
45 #include "oidif.hh"
46 #include "raslib/error.hh"
47 #include "lists.h"
48 
49 #ifdef RMANBENCHMARK
50 #include "raslib/rmdebug.hh"
51 #endif
52 
53 //@ManMemo: Module: {\bf reladminif}.
54 /*@Doc:
55 the ObjectBroker is one of the three columns one which the persistence layer rests:
56 ObjectBroker, DBRef, DBObject.
57 the ObjectBroker keeps track of all persistent objects which are loaded into memory.
58 objects register themselves at this facility and deregister themselves when they are
59 deleted.
60 
61 The ObjectBroker supplies functionality for accessing persistent objects by oid and by
62 name.
63 The ObjectBroker can be configured to serve as a cross transaction cache.
64 The ObejctBroker can retrieve the oids of all objects of a specific type which are stored
65 in the database.
66 The list of objects which are kept by the ObjectBroker are cleared by TransactionIf.
67 */
72 {
73 public:
74  static bool freeMemory() throw (r_Error);
75  /*@Doc:
76  this will handle the memory issue.
77  returns true if memory was freed, false otherwise.
78  if false is returned there is really to much memory allocated and the transaction should be stopped.
79  */
80 
81  static void deregisterTileIndexMapping(const OId& tileoid, const OId& indexoid);
82  /*@Doc:
83  deletes the object in the correct list
84  */
85 
86  static void registerTileIndexMapping(const OId& tileoid, const OId& indexoid);
87  /*@Doc:
88  inserts the object in the correct list
89  */
90 
91  static void registerDBObject(DBObject* object);
92  /*@Doc:
93  inserts the object in the correct list
94  */
95 
96  static void deregisterDBObject(const OId& id);
97  /*@Doc:
98  removes the object with the specified oid from the list
99  */
100 
101  static DBObject* getObjectByOId(const OId& id) throw (r_Error);
102  /*@Doc:
103  retrieve a dbobject from db. passes (r_Error)s from DBObject up.
104  */
105 
106  static DBObject* isInMemory(const OId& id) throw (r_Error);
107  /*@Doc:
108  does not retrieve the object from db. only retrieves from memory.
109  if there is no matching object a 0 pointer is returned.
110  throws an (r_Error) if the OId has a invalid type
111  */
112 
113  static OIdSet* getAllObjects(OId::OIdType type);
114  /*@Doc:
115  generates a list of all objects in the db and in memory with the
116  specified type. the vector must be deleted by the calling function
117  */
118 
119  static MDDType* getMDDTypeByName(const char* name) throw (r_Error);
120  /*@Doc:
121  retrieves an object with that name and that type from the db.
122  this method was introduced to remove the spurious sqlwarnings.
123  passes (r_Error)s from DBObject up or ObjectNotFound when there is
124  no matching object
125  */
126 
127  static DBObject* getObjectByName(OId::OIdType type, const char* name) throw (r_Error);
128  /*@Doc:
129  retrieves an object with that name and that type from the db.
130  passes (r_Error)s from DBObject up or ObjectNotFound when there is
131  no matching object
132  */
133 
134  static void clearBroker() throw (r_Error);
135  /*@Doc:
136  deletes persistent objects from memory, depending on cache ofcourse.
137  any (r_Error)s thrown during the deletion/update/insert process are
138  handed up. the objects are removed before errors can occur. multiple
139  calls to clearBroker until the method completes are possible. memory
140  leaks may occur in this event.
141  */
142 
143  static void clearCache() throw (r_Error);
144  /*@Doc:
145  deletes _all_ persistent objects from memory.
146  any (r_Error)s thrown during the deletion/update/insert process are
147  handed up. the objects are removed before errors can occur. multiple
148  calls to clearBroker until the method completes are possible. memory
149  leaks may occur in this event.
150  */
151 
152  static void init();
153  /*@Doc:
154  initialize the atomic types and maps
155  */
156 
157  static void deinit();
158  /*@Doc:
159  delete the atomic types and maps
160  */
161 
162  static DBObjectPMap& getMap(OId::OIdType type) throw (r_Error);
163  /*@Doc:
164  returns a pointer to the store of objects of that particular type.
165  (r_Error) is thrown if there is no map for that type
166  */
167 
168 protected:
169  static DBObject* loadDBMDDObj(const OId& id) throw (r_Error);
170  /*@Doc:
171  retrieves MDDObjects from memory and from database
172  */
173 
174  static DBObject* loadMDDSet(const OId& id) throw (r_Error);
175  /*@Doc:
176  retrieves MDDSets from memory and from database
177  */
178 
179  static DBObject* loadMDDType(const OId& id) throw (r_Error);
180  /*@Doc:
181  retrieves MDDTypes from memory and from database
182  */
183 
184  static DBObject* loadMDDBaseType(const OId& id) throw (r_Error);
185  /*@Doc:
186  retrieves MDDBaseTypes from memory and from database
187  */
188 
189  static DBObject* loadMDDDimensionType(const OId& id) throw (r_Error);
190  /*@Doc:
191  retrieves MDDDimTypes from memory and from database
192  */
193 
194  static DBObject* loadMDDDomainType(const OId& id) throw (r_Error);
195  /*@Doc:
196  retrieves MDDDomTypes from memory and from database
197  */
198 
199  static DBObject* loadStructType(const OId& id) throw (r_Error);
200  /*@Doc:
201  retrieves StructTypes from memory and from database
202  */
203 
204  static DBObject* loadSetType(const OId& id) throw (r_Error);
205  /*@Doc:
206  retrieves SetTypes from memory and from database
207  */
208 
209  static DBObject* loadBLOBTile(const OId& id) throw (r_Error);
210  /*@Doc:
211  retrieves BLOBTiles from memory and from database.
212  knows how to get a inlinetile from a dbtcindex.
213  */
214 
215  static DBObject* loadDBMinterval(const OId& id) throw (r_Error);
216  /*@Doc:
217  retrieves DBMintervals from memory and from database
218  */
219 
220  static DBObject* loadDBStorage(const OId& id) throw (r_Error);
221  /*@Doc:
222  retrieves DBStorageLayout from memory and from database
223  */
224 
225  static DBObject* loadDBHierIndex(const OId& id) throw (r_Error);
226  /*@Doc:
227  retrieves HierIxs from memory and from database
228  */
229 
230  static DBObject* loadDBTCIndex(const OId& id) throw (r_Error);
231  /*@Doc:
232  retrieves DBTCIndex from memory and from database
233  */
234 
235  static DBObject* loadInlineTile(const OId& id) throw (r_Error);
236  /*@Doc:
237  retrieves InlineTiles from memory and from database
238  */
239 
240  static DBObject* loadDBRCIndexDS(const OId& id) throw (r_Error);
241  /*@Doc:
242  retrieves DBRCIndexDS from memory and from database
243  */
244 
245  static OId getOIdByName(OId::OIdType type, const char* name) throw (r_Error);
246  /*@Doc:
247  finds the oid of an object with the given type and name
248  */
249 
250  static void clearMap(DBObjectPMap& theMap) throw (r_Error);
251  /*@Doc:
252  deletes entries in this map as long as they are not cached
253  (r_Error) is thrown when there is a problem in ~DBObject.
254  the object is removed from the map though.
255  */
256 
257  static void completelyClearMap(DBObjectPMap& theMap) throw (r_Error);
258  /*@Doc:
259  deletes entries in this map
260  (r_Error) is thrown when there is a problem in ~DBObject.
261  the object is removed from the map though.
262  */
263 
264 
265  static OId getOIdOfMDDSet(const char* name) throw (r_Error);
266  /*@Doc:
267  retrieves MDDSets from memory and from database
268  */
269 
270  static OId getOIdOfMDDType(const char* name) throw (r_Error);
271  /*@Doc:
272  retrieves MDDTypes from memory and from database
273  */
274 
275  static OId getOIdOfMDDBaseType(const char* name) throw (r_Error);
276  /*@Doc:
277  retrieves MDDBaseTypes from memory and from database
278  */
279 
280  static OId getOIdOfMDDDimensionType(const char* name) throw (r_Error);
281  /*@Doc:
282  retrieves MDDDimTypes from memory and from database
283  */
284 
285  static OId getOIdOfMDDDomainType(const char* name) throw (r_Error);
286  /*@Doc:
287  retrieves MDDDomTypes from memory and from database
288  */
289 
290  static OId getOIdOfStructType(const char* name) throw (r_Error);
291  /*@Doc:
292  retrieves StructTypes from memory and from database
293  */
294 
295  static OId getOIdOfSetType(const char* name) throw (r_Error);
296  /*@Doc:
297  retrieves SetTypes from memory and from database
298  */
299 
300  static OIdSet* getAllMDDObjects() throw (r_Error);
301  /*@Doc:
302  retrieves the oids of all MDD Objects from memory and from database
303  oidlist must be deallocated by the caller
304  (r_Error) occures in a database failure
305  */
306 
307  static OIdSet* getAllMDDSets() throw (r_Error);
308  /*@Doc:
309  retrieves the oids of all MDDSets from memory and from database
310  oidlist must be deallocated by the caller
311  (r_Error) occures in a database failure
312  */
313 
314  static OIdSet* getAllMDDTypes() throw (r_Error);
315  /*@Doc:
316  retrieves the oids of all MDDTypes from memory and from database
317  oidlist must be deallocated by the caller
318  (r_Error) occures in a database failure
319  */
320 
321  static OIdSet* getAllMDDBaseTypes() throw (r_Error);
322  /*@Doc:
323  retrieves the oids of all MDDBaseTypes from memory and from database
324  oidlist must be deallocated by the caller
325  (r_Error) occures in a database failure
326  */
327 
328  static OIdSet* getAllMDDDimensionTypes() throw (r_Error);
329  /*@Doc:
330  retrieves the oids of all MDDDimTypes from memory and from database
331  oidlist must be deallocated by the caller
332  (r_Error) occures in a database failure
333  */
334 
335  static OIdSet* getAllMDDDomainTypes() throw (r_Error);
336  /*@Doc:
337  retrieves the oids of all MDDDomTypes from memory and from database
338  oidlist must be deallocated by the caller
339  (r_Error) occures in a database failure
340  */
341 
342  static OIdSet* getAllStructTypes() throw (r_Error);
343  /*@Doc:
344  retrieves the oids of all StructTypes from memory and from database
345  oidlist must be deallocated by the caller
346  (r_Error) occures in a database failure
347  */
348 
349  static OIdSet* getAllSetTypes() throw (r_Error);
350  /*@Doc:
351  retrieves the oids of all SetTypes from memory and from database
352  oidlist must be deallocated by the caller
353  (r_Error) occures in a database failure
354  */
355 
356  static OIdSet* getAllAtomicTypes() throw (r_Error);
357  /*@Doc:
358  retrieves the oids of all AtomicTypes from memory
359  oidlist must be deallocated by the caller
360  (r_Error) should never occur
361  */
362 
363 private:
365  static ULongType* theULong;
366  /*@Doc:
367  a pointer to this member is returned by getObjectByOId().
368  */
369 
370  static CharType* theChar;
371  /*@Doc:
372  a pointer to this member is returned by getObjectByOId().
373  */
374 
375  static BoolType* theBool;
376  /*@Doc:
377  a pointer to this member is returned by getObjectByOId().
378  */
379 
380  static UShortType* theUShort;
381  /*@Doc:
382  a pointer to this member is returned by getObjectByOId().
383  */
384 
385  static LongType* theLong;
386  /*@Doc:
387  a pointer to this member is returned by getObjectByOId().
388  */
389 
390  static ShortType* theShort;
391  /*@Doc:
392  a pointer to this member is returned by getObjectByOId().
393  */
394 
395  static OctetType* theOctet;
396  /*@Doc:
397  a pointer to this member is returned by getObjectByOId().
398  */
399 
400  static DoubleType* theDouble;
401  /*@Doc:
402  a pointer to this member is returned by getObjectByOId().
403  */
404 
405  static FloatType* theFloat;
406  /*@Doc:
407  a pointer to this member is returned by getObjectByOId().
408  */
409 
410  static ComplexType1* theComplex1;
411  /*@Doc:
412  a pointer to this member is returned by getObjectByOId().
413  */
414 
415  static ComplexType2* theComplex2;
416  /*@Doc:
417  a pointer to this member is returned by getObjectByOId().
418  */
419 
420  static DBObjectPMap theDBMDDObjs;
421  /*@Doc:
422  holds all MDDObjects in memory
423  */
424 
425  static DBObjectPMap theMDDSets;
426  /*@Doc:
427  holds all MDDSets in memory
428  */
429 
430  static DBObjectPMap theMDDTypes;
431  /*@Doc:
432  holds all MDDTypes in memory
433  */
434 
435  static DBObjectPMap theMDDBaseTypes;
436  /*@Doc:
437  holds all MDDBaseTypes in memory
438  */
439 
440  static DBObjectPMap theMDDDimensionTypes;
441  /*@Doc:
442  holds all MDDDimTypes in memory
443  */
444 
445  static DBObjectPMap theMDDDomainTypes;
446  /*@Doc:
447  holds all MDDDomTypes in memory
448  */
449 
450  static DBObjectPMap theStructTypes;
451  /*@Doc:
452  holds all StructTypes in memory
453  */
454 
455  static DBObjectPMap theSetTypes;
456  /*@Doc:
457  holds all SetTypes in memory
458  */
459 
460  static DBObjectPMap theBLOBTiles;
461  /*@Doc:
462  holds all BLOBTiles in memory
463  */
464 
465  static DBObjectPMap theDBMintervals;
466  /*@Doc:
467  holds all DBMintervals in memory
468  */
469 
470  static DBObjectPMap theDBStorages;
471  /*@Doc:
472  holds all MDDEntries in memory
473  */
474 
475  static DBObjectPMap theDBHierIndexs;
476  /*@Doc:
477  holds all HierIxs in memory
478  */
479 
480  static DBObjectPMap theDBTCIndexs;
481  /*@Doc:
482  holds all HierIxs in memory
483  */
484 
485  static DBObjectPMap theInlineTiles;
486  /*@Doc:
487  holds all InlineTiles in memory
488  */
489 
490  static DBObjectPMap theAtomicTypes;
491  /*@Doc:
492  holds all SetTypes in memory
493  */
494 
495  static DBObjectPMap theRCIndexes;
496  /*@Doc:
497  holds all RC Indexes in memory
498  */
499 
500  static OIdMap theTileIndexMappings;
501  /*@Doc:
502  key (first/double) is oid of tile, value (second/oid) is oid of index.
503  */
504 
505 };
506 
507 #endif
508 
static OIdSet * getAllMDDObjects()
Definition: longtype.hh:57
Definition: ushorttype.hh:55
Definition: settype.hh:57
static OIdSet * getAllMDDBaseTypes()
static void completelyClearMap(DBObjectPMap &theMap)
Definition: floattype.hh:56
std::map< double, OId, std::less< double > > OIdMap
Definition: lists.h:99
static void init()
static void deregisterTileIndexMapping(const OId &tileoid, const OId &indexoid)
static OId getOIdOfMDDSet(const char *name)
static OId getOIdByName(OId::OIdType type, const char *name)
static void clearCache()
static void registerTileIndexMapping(const OId &tileoid, const OId &indexoid)
Definition: chartype.hh:58
static DBObject * loadMDDDomainType(const OId &id)
static OIdSet * getAllMDDDimensionTypes()
std::map< double, DBObject *, std::less< double > > DBObjectPMap
Definition: lists.h:91
static void clearMap(DBObjectPMap &theMap)
static DBObject * loadDBStorage(const OId &id)
static DBObject * getObjectByName(OId::OIdType type, const char *name)
static void deregisterDBObject(const OId &id)
static OIdSet * getAllObjects(OId::OIdType type)
static OId getOIdOfMDDBaseType(const char *name)
static DBObject * getObjectByOId(const OId &id)
static DBObject * loadDBTCIndex(const OId &id)
Definition: objectbroker.hh:71
static DBObjectPMap & getMap(OId::OIdType type)
static DBObject * loadMDDSet(const OId &id)
Definition: oidif.hh:67
static DBObject * isInMemory(const OId &id)
static DBObject * loadMDDBaseType(const OId &id)
Definition: ulongtype.hh:56
static OIdSet * getAllMDDTypes()
Definition: octettype.hh:59
static OId getOIdOfMDDDomainType(const char *name)
Definition: structtype.hh:68
Definition: mddtype.hh:58
static DBObject * loadInlineTile(const OId &id)
static MDDType * getMDDTypeByName(const char *name)
static OIdSet * getAllSetTypes()
static OIdSet * getAllAtomicTypes()
static void clearBroker()
static OIdSet * getAllStructTypes()
static DBObject * loadMDDDimensionType(const OId &id)
Definition: complextype.hh:110
Definition: basetype.hh:66
static OId getOIdOfStructType(const char *name)
static DBObject * loadDBRCIndexDS(const OId &id)
static DBObject * loadStructType(const OId &id)
OIdType
Definition: oidif.hh:70
static DBObject * loadMDDType(const OId &id)
Definition: booltype.hh:58
static bool freeMemory()
Definition: type.hh:68
static DBObject * loadDBHierIndex(const OId &id)
static DBObject * loadBLOBTile(const OId &id)
static void deinit()
static OId getOIdOfSetType(const char *name)
static OIdSet * getAllMDDDomainTypes()
static DBObject * loadDBMinterval(const OId &id)
static OId getOIdOfMDDType(const char *name)
std::set< OId, std::less< double > > OIdSet
Definition: lists.h:38
Definition: complextype.hh:74
static void registerDBObject(DBObject *object)
static DBObject * loadSetType(const OId &id)
static OId getOIdOfMDDDimensionType(const char *name)
Definition: shorttype.hh:58
static OIdSet * getAllMDDSets()
Definition: doubletype.hh:56
static DBObject * loadDBMDDObj(const OId &id)
Definition: dbobject.hh:54