rasdaman complete source
dbmddobj.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 _DBMDDOBJ_HH_
24 #define _DBMDDOBJ_HH_
25 
26 #include <iostream>
27 class ObjectBroker;
28 class BaseType;
29 class MDDBaseType;
30 class OIdIf;
31 class r_Minterval;
32 class r_Error;
33 class DBMinterval;
34 
35 #include "mddid.hh"
36 #include "relindexif/indexid.hh"
37 #include "reladminif/dbobject.hh"
38 #include "raslib/mddtypes.hh"
41 
42 //@ManMemo: Module: {\bf relmddif}
43 /*@Doc:
44 A {\tt DBMDDObj} object links all neccessary persistent data for an MDD
45 object. One DBMDDObj can be inserted in multiple MDD Collections. It will
46 only be deleted from the database when there are no more references in MDD
47 Collections. This is done through persistent reference counting.
48 
49 The DBMDDObj stores the following data:
50 -MDDBaseType: type information on the data that is stored in it.
51 -Definition domain: the spatial domain this object may extend to. This
52  domain may have open boundaries.
53 -Index: a refernce to the index which holds the actual data.
54 -Storagelayout: has asorted methods for modifying how the data is stored in the database.
55 The definition domain is stored in an extensible but inefficient way.
56 */
65 class DBMDDObj : public DBObject
66 {
67 public:
68  DBMDDObj( const MDDBaseType* type,
69  const r_Minterval& domain,
70  const DBObjectId& i,
71  const DBStorageLayoutId& s,
72  const OId& theMDDObj) throw (r_Error);
73  /*@Doc:
74  type: it contains the basetype which will be used to create perstiles.
75  domain: the definition domain. the extend to which the mdd object may grow.
76  i: the index structure which should be used. there has to be some way to use DBRef<IndexDS>.
77  s: the storage layout object.
78  theMDDObj: this oid may not be assigned to an mdd object yet!
79  */
80 
81  DBMDDObj( const MDDBaseType* newMDDType,
82  const r_Minterval& domain,
83  const DBObjectId& newObjIx,
84  const DBStorageLayoutId& newSL);
85  /*@Doc:
86  newMDDType: it contains the basetype which will be used to create perstiles.
87  domain: the definition domain. the extend to which the mdd object may grow.
88  newObjIx: the index structure which should be used. there has to be some way to use DBRef<IndexDS>.
89  s: the storage layout object.
90  The oid is generated by the object itself.
91  */
92 
93  const MDDBaseType* getMDDBaseType() const;
94  /*@Doc:
95  return the mddbasetype for this object.
96  */
97 
99  /*@Doc:
100  return the storage layout object for this mdd object.
101  */
102 
103  const char* getCellTypeName() const;
104  /*@Doc:
105  Returns the name of the base type of this MDD object cells.
106  */
107 
108  const BaseType* getCellType() const;
109  /*@Doc:
110  Returns the base type of this MDD object cells.
111  */
112 
113  r_Dimension dimensionality() const;
114  /*@Doc:
115  Returns dimensionality of the object.
116  */
117 
118  r_Minterval getDefinitionDomain() const;
119  /*@Doc:
120  Returns the definition domain of the object.
121  */
122 
123  r_Bytes getHeaderSize() const;
124  /*@Doc:
125  Returns the size of the header for an MDD object.
126  The size returned by this funtion is an approximation to
127  the size of the actual physical storage space used by the
128  base DBMS. In the current implementation:
129  HeaderSize = MDDBaseType*Size + r_Minterval*Size +
130  DBMDDObjIxSize + DBObjectSize
131  This should be reviewed and renamed to
132  getPhysicalStorageSize
133  */
134 
135  virtual void printStatus(unsigned int level = 0, std::ostream& stream = cout) const;
136  /*@Doc:
137  Prints the status of the object:
138  the name of the cell type
139  the definition domain
140  the index contents
141  */
142 
143  void setIx(const DBObjectId& newObjIx);
144  /*@Doc:
145  make the mdd object use newObjIx instead of its old index structure.
146  the old index structure is not deleted from the database!
147  */
148 
149  DBObjectId getDBIndexDS() const;
150  /*@Doc:
151  Returns the reference to the index.
152  */
153 
154  DBMDDObj(const DBMDDObj& old);
155  /*@Doc:
156  Copy constructor should never be used.
157  Should raise a r_Error.
158  */
159 
160  virtual ~DBMDDObj();
161  /*@Doc:
162  Validates the object and deletes the definition domain.
163  */
164 
165  virtual void setPersistent(bool t = true) throw (r_Error);
166  /*@Doc:
167  Was overridden to pass changes to definition domain, storage layout and
168  to the index.
169  */
170 
171  virtual void setCached(bool ic);
172  /*@Doc:
173  overrides DBObject to handle the DBMinterval
174  */
175 
176  void incrementPersRefCount();
177  /*@Doc:
178  used by mddset to tell the mddobj that there is an
179  additional mddset ref to it
180  */
181 
182  void decrementPersRefCount();
183  /*@Doc:
184  used by mddset to tell the mddobj that there is an mddset
185  ref less to it
186  */
187 
188  int getPersRefCount() const;
189  /*@Doc:
190  returns the number of persistent references to this object.
191  when zero, the object may be deleted
192  */
193 
194  virtual r_Bytes getMemorySize() const;
195  /*@Doc:
196  Calculates the size of this object in main memory.
197  */
198 
199 protected:
200  friend class ObjectBroker;
201 
202  DBMDDObj(const OId& id) throw (r_Error);
203  /*@Doc:
204  Constructs a DBMDDObj from the database.
205  */
206 
207  virtual void insertInDb() throw (r_Error);
208  /*@Doc:
209 
210  */
211 
212  virtual void deleteFromDb() throw (r_Error);
213  /*@Doc:
214 
215  */
216 
217  virtual void readFromDb() throw (r_Error);
218  /*@Doc:
219 
220  */
221 
222  virtual void updateInDb() throw (r_Error);
223  /*@Doc:
224 
225  */
226 
227 private:
228 
229  int persistentRefCount;
230  /*@Doc:
231  number of persistent references (by mddsets) to this object
232  */
233 
234  DBMDDObj();
235  /*@Doc:
236  creates an empty object and does NOT register it
237  with ObjectBroker.
238  */
239 
240  const MDDBaseType* mddType;
241  /*@Doc:
242  Type of this object.
243  */
244 
245  DBMinterval* myDomain;
246  /*@Doc:
247  Definition domain for the object.
248  */
249 
250  DBStorageLayoutId storageLayoutId;
251  /*@Doc:
252  StorageLayout OId
253  */
254 
255  DBObjectId objIxId;
256  /*@Doc:
257  Index OId
258  */
259 };
260 
261 #endif
virtual void printStatus(unsigned int level=0, std::ostream &stream=cout) const
virtual void readFromDb()
DBStorageLayoutId getDBStorageLayout() const
DBObjectId getDBIndexDS() const
void setIx(const DBObjectId &newObjIx)
const BaseType * getCellType() const
Definition: dbmddobj.hh:65
r_Bytes getHeaderSize() const
Definition: objectbroker.hh:71
Definition: mddbasetype.hh:57
Definition: oidif.hh:67
virtual void deleteFromDb()
virtual void setCached(bool ic)
const char * getCellTypeName() const
virtual void updateInDb()
virtual r_Bytes getMemorySize() const
virtual ~DBMDDObj()
virtual void insertInDb()
void incrementPersRefCount()
Definition: relcatalogif/basetype.hh:66
int getPersRefCount() const
void decrementPersRefCount()
const MDDBaseType * getMDDBaseType() const
virtual void setPersistent(bool t=true)
Definition: dbminterval.hh:47
r_Dimension dimensionality() const
r_Minterval getDefinitionDomain() const
Definition: dbobject.hh:54