rasdaman complete source
dbtile.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 _DBTILE_HH_
24 #define _DBTILE_HH_
25 
26 // -*-C++-*- (for Emacs)
27 
28 /*************************************************************
29  *
30  *
31  * PURPOSE:
32  *
33  *
34  * COMMENTS:
35  *
36  ************************************************************/
37 
38 class OId;
39 class r_Error;
40 #include "reladminif/dbobject.hh"
41 #include "raslib/mddtypes.hh"
42 #include "tileid.hh"
43 #include "relindexif/indexid.hh"
44 
45 //@ManMemo: Module: {\bf reldbif}.
46 
47 /*@Doc:
48 This class is used in tilemgr as an interface to the persistent tiles. There are subclasses of dbtile which store themselves differently. This class can also be used to get rid of tilemgr/TransTile. When no persistent tile is needed then a dbtile and not a blobtile/inlinetile can be used.
49 */
50 
54 class DBTile : public DBObject
55 {
56 public:
57  friend std::ostream& operator << (std::ostream& stream, DBTile& b);
58  /*@Doc:
59  prints info about the dbtile (flags, id, dbdata, size, modified)
60  */
61  //@Man: read methods
63  char* getCells();
65  /*@Doc:
66  Returns a pointer to the contents of the DBTile. This pointer
67  can be used as a char array with getSize() elements.
68  Retriving the contents with this method will mark this object dirty.
69  */
70 
72  const char* getCells() const;
73  /*@Doc:
74  Returns a pointer to the contents of the DBTile. This pointer
75  can be used as a char array with getSize() elements.
76  */
77 
79  char getCell(r_Bytes index) const;
80  /*@Doc:
81  Returns a copy of the char. This functions function should usually
82  not be used because of performance considerations.
83  */
84 
86  /*@Doc:
87  Returns the Data Format of this tile (r_Tiff, r_Array, ...)
88  */
89 
91  /*@Doc:
92  Returns the Data Format of the tiles contents (r_Tiff, r_Array, ...)
93  */
94 
95  void setDataFormat(const r_Data_Format& dataformat);
96  /*@Doc:
97  Sets the Data Format of this tile (r_Tiff, r_Array, ...)
98  This method will mark this object dirty.
99  */
100 
101  void setCurrentFormat(const r_Data_Format& dataformat) const;
102  /*@Doc:
103  Sets the Data Format of the contents of this tile (r_Array, or the compressed stuff)
104  This method will _not_ mark this object dirty.
105  */
106 
108  r_Bytes getSize() const;
109  /*@Doc:
110  Returns the size of this Tile in bytes.
111  */
113 
114  //@Man: write methods
116  void setCell(r_Bytes index, char newCell);
118  /*@Doc:
119  Usually modifications should be done directly on the char array
120  returned by getCells() because of much better performance.
121  This method will mark this object dirty.
122  */
123 
124  void setCells(char* newCells);
125  /*@Doc:
126  Completely replaces the character array of this tile.
127  The old arry is deleted.
128  Modification is set to dirty.
129  */
130 
132 
133  //@Man: constructors
135  DBTile(r_Data_Format dataformat = r_Array);
136  /*@Doc:
137  constructs a new empty DBTile. Length is 0.
138  */
139 
140  DBTile(const OId& BlobId) throw (r_Error);
141  /*@Doc:
142  Passes to DBObject.
143  */
144 
145  DBTile(r_Bytes newSize, char c = 0, r_Data_Format dataformat = r_Array);
146  /*@Doc:
147  constructs a new DBTile of size newSize filled with c.
148  */
149 
150  DBTile(r_Bytes newSize, r_Bytes patSize, const char* pat, r_Data_Format dataformat = r_Array);
151  /*@Doc:
152  Constructs a new DB Tile of size newSize filled with the repeated
153  char array pat of size patSize. If after filling some chars are
154  left, they are filled with 0
155  */
156  /*@ManMemo: constructs a new DB Tile with the char array newCells
157  with newSize elements as contents. */
158 
159  DBTile(r_Bytes newSize, const char* newCells, r_Data_Format dataformat = r_Array);
160  /*@Doc:
161  constructs a new DBTile of size newSize filled with the contents of newCells.
162  the newCells are copied.
163  */
165 
166  virtual ~DBTile();
167  /*@Doc:
168  validates the object. deletes it cells.
169  */
170 
171  void resize(r_Bytes newSize);
172  /*@Doc:
173  resize DBTile. previous contents are lost.
174  */
175 
176  virtual r_Bytes getMemorySize() const;
177  /*@Doc:
178  returns the space taken up by this object in memory:
179  size * sizeof(char) + sizeof(char*) +
180  DBObject::getMemorySize() + sizeof(r_Data_Format) + sizeof(r_Bytes)
181  */
182 
183  virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;
184  /*@Doc:
185  prints the status of DBObject, the dataformat, the size and the contents as (int)
186  */
187 
188  void setNoModificationData(char* data) const;
189  /*@Doc:
190  Completely replaces the array.
191  The object will not be marked dirty.
192  This is used for transparent compression/decompression.
193  */
194 
195  void setNoModificationSize(r_Bytes newSize) const;
196  /*@Doc:
197  Sets the size of this tile.
198  The object will not be marked dirty.
199  This is used for transparent compression/decompression.
200  */
201 
202 protected:
203  mutable r_Bytes size;
204  /*@Doc:
205  total size of the contents of DBTile in number of chars.
206  */
207 
208  mutable char* cells;
209  /*@Doc:
210  the data is allocated by malloc
211  */
212 
214  /*@Doc:
215  data format to construct a PersTile
216  */
217 
219  /*@Doc:
220  the current format of the contents. This is neccessary to know when getting mixed up compressed contents.
221  */
222 };
223 
224 #endif
r_Data_Format getDataFormat() const
void resize(r_Bytes newSize)
virtual r_Bytes getMemorySize() const
void setCells(char *newCells)
void setCurrentFormat(const r_Data_Format &dataformat) const
Definition: error.hh:88
r_Data_Format currentFormat
Definition: dbtile.hh:218
Definition: dbtile.hh:54
virtual void printStatus(unsigned int level=0, std::ostream &stream=std::cout) const
r_Data_Format dataFormat
Definition: dbtile.hh:213
r_Data_Format getCurrentFormat() const
void setNoModificationData(char *data) const
char * getCells()
get contents as array of chars for read access.
Definition: oidif.hh:67
void setCell(r_Bytes index, char newCell)
change one char in the contents of the DBTile.
r_Data_Format
Definition: mddtypes.hh:133
char * cells
Definition: dbtile.hh:208
char getCell(r_Bytes index) const
get one char in the contents of the DBTile.
void setDataFormat(const r_Data_Format &dataformat)
virtual ~DBTile()
Definition: mddtypes.hh:135
r_Bytes getSize() const
get size of contents of DBTile in chars.
void setNoModificationSize(r_Bytes newSize) const
unsigned int r_Bytes
Definition: mddtypes.hh:56
DBTile(r_Data_Format dataformat=r_Array)
friend std::ostream & operator<<(std::ostream &stream, DBTile &b)
r_Bytes size
Definition: dbtile.hh:203
Definition: dbobject.hh:54