rasdaman complete source
mddcoll.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 _MDDCOLL_HH_
34 #define _MDDCOLL_HH_
35 
36 #include <iostream>
37 #include <map>
38 #include <stdlib.h>
39 
40 #include "mddobj.hh"
41 #include "mddcolliter.hh"
42 #include "mddcoll.hh"
43 #include "reladminif/oidif.hh"
44 #include "raslib/error.hh"
45 #include "relmddif/mddid.hh"
46 #include "relcatalogif/collectiontype.hh" // from catalogif base DBMS interface module
47 
48 class CollectionType;
49 class DatabaseIf;
50 
51 //@ManMemo: Module: {\bf cachetamgr}
52 /*@Doc:
53  An MDDColl object is a collection of references to MDD objects.
54  This class is the abstract base class for all persistent and
55  transient collection classes.
56 
57  The objects pointed to by the collection exist in a storage domain
58  which may be either the main memory for the transient collections
59  or the database for the persistent cases.
60 
61  An MDDColl is responsible for managing the memory allocated for the
62  MDDObjs which belong to it. In the future, more functions will be provided
63  to allow selected releasing or keeping of MDD objects in an MDDColl.
64 
65  {\bf Example }
66 
67  {\tt MDDObj* accessedObj; }
68 
69  {\tt MDDColl* mddObjsColl; }
70 
71  {\tt mddObjsColl = new ... }
72 
73  {\tt // Initialize mddObjsColl to a PersMDDColl or TransMDDColl. }
74 
75  {\tt MDDCollIter* objsIt = mddObjsColl->createIterator(); }
76 
77  {\tt for(int i = 1 ; objsIt->notDone(); i++, objsIt->advance()) }
78 
79  {\tt \{ }
80 
81  {\tt accessedObj = objsIt->getElement(); }
82 
83  {\tt ...}
84 
85  {\tt } }
86 
87  {\tt delete objsIt; // Deallocate iterator. }
88 
89  {\tt ... // Here accessedObj may be used. }
90 
91  {\tt mddObjsColl->releaseAll(); }
92 
93  {\bf {\tt ... // In this part accessedObj is no longer valid. } }
94 
95  {\tt delete mddObjsColl; }
96 */
97 
98 class MDDColl
99 {
100 
101 public:
103  MDDColl(const CollectionType* newType, const char* name = 0);
104 
105  static const char* AllCollectionnamesName;
106 
107  static MDDColl* getMDDCollection(const char* collName) throw (r_Error);
113  static MDDColl* getMDDCollection(const OId& collOId) throw (r_Error);
119  static MDDColl* createMDDCollection(const char* name, const CollectionType* ct) throw (r_Error);
124  static MDDColl* createMDDCollection(const char* name, const OId& o, const CollectionType* ct) throw (r_Error);
129  static bool dropMDDCollection(const char* name);
135  static bool dropMDDCollection(const OId& id);
141  static bool removeMDDObject(const OId& coll, const OId& id);
147  void printStatus(unsigned int level = 0, ostream& stream = cout) const;
152  const CollectionType* getCollectionType() const;
157  unsigned long getCardinality() const;
162  bool getOId(OId& pOId) const;
167  bool getEOId(EOId& pEOId) const;
172  void insert(const MDDObj* newObj);
178  MDDCollIter* createIterator() const;
183  void remove(const MDDObj* obj);
188  void removeAll();
194  void releaseAll();
202  bool isPersistent() const;
207  const char* getName() const;
208 
209  ~MDDColl();
214 protected:
215 
216  friend class MDDCollIter;
217 
218  MDDObj* getMDDObj(const DBMDDObj*) const;
224  MDDColl(const DBMDDSetId& coll);
225 
226  DBMDDSetId getDBMDDSet() const;
232  void insertIntoCache(const MDDObj* objToInsert) const;
237  //void removeFromCache(DBMDDObjId& objToGet);
238 
239  DBMDDSetId dbColl;
245  typedef std::map<DBMDDObj*, MDDObj*, std::less<DBMDDObj*> > MDDObjMap;
246  mutable MDDObjMap mddCache;
251 };
252 
253 #endif
254 
Definition: eoid.hh:52
Definition: dbmddobj.hh:65
Definition: oidif.hh:67
Definition: relcatalogif/collectiontype.hh:59
Definition: dbobject.hh:29