summaryrefslogtreecommitdiffstats
path: root/rasodmg/tiling.hh
blob: e178e0a6777b016b0d3f70ee77ab2bdf5832a6d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/
/**
 * INCLUDE: tiling.hh
 *
 * MODULE:  rasodmg
 * CLASS:   r_Tiling
 *
 * COMMENTS:
 *			None
*/

#ifndef _R_TILING_HH_
#define _R_TILING_HH_

class r_Tiling;
class r_No_Tiling;
class r_Size_Tiling;
class r_Dimension_Tiling;
class r_Minterval;

// Include statements 

#include <vector>
#include <iostream>
using std::cout;

#include "raslib/rminit.hh"
#include "raslib/odmgtypes.hh"
#include "raslib/mddtypes.hh"
#include "raslib/error.hh"

//@ManMemo: Module {\bf rasodmg}

/*@Doc:

  The {\tt r_Tiling} class is used to specify in which way the tiling is done 
  by the system. The core method that does that is called {\tt decomposeMDD()}
  and must be implemented by all derived classes. It takes an object that 
  hasn't yet been split and divides it into tiles. Each derived class 
  implements a diferent decomposition method.
*/

class r_Tiling
	{
	public:

		/// does not do anything
		virtual ~r_Tiling();	
	
		/// Prints the current status of the object
		virtual void print_status(std::ostream& os) const = 0;
		
		/// Check compatibility of object domain with this tiling
		virtual bool is_compatible(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const = 0;

		/// Decompose an object in tiles
		virtual std::vector<r_Minterval>* compute_tiles(const r_Minterval& obj_domain, r_Bytes cell_size) const throw (r_Error) = 0;
		/**
		This method provides the core funcionality of this class. All derived 
		classes must implement it. As input parameters it takes the big object to 
		be decomposed and returns a set of tiles that compose the big object.
                This method throws an exeception when the dimension specified, extend or 
                the cell_size are incompatible with the current tiling.  You can check
                compatibility by invoking is_compatible.
		*/

		/// Clones this object
		virtual r_Tiling* clone() const = 0;
		/**
		This method is similar to a copy constructor, this is, is returns a copy of
		the current object. Derived classes must explicitly implement this method.
		*/

		virtual r_Tiling_Scheme get_tiling_scheme() const = 0;
		/**
		return the type of tiling scheme
		*/

		static const char* ASTERIX;
		static const char* COLON;
		static const char* COMMA;
		static const char* LSQRBRA;
		static const char* RSQRBRA;
		static const long DefaultBase;
 	};

class r_Size_Tiling :	public r_Tiling
	{
	public:
		/// Constructor that reads everything from a string
		/// e.g."100"
		r_Size_Tiling(const char* encoded) throw (r_Error);

		/// Constructor for this object (Takes tile size as parameter)
		r_Size_Tiling(r_Bytes ts = RMInit::clientTileSize);

		/// does not do anything
		virtual ~r_Size_Tiling();

		/// Gets the current tile size
		r_Bytes get_tile_size() const;

		virtual void print_status(std::ostream& os) const;
		
		/// returns true if the cellTypeSize is smaller or equal to the tile size and obj_domain has more than 0 dimensions
		virtual bool is_compatible(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const;

		virtual std::vector<r_Minterval>* compute_tiles(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const throw (r_Error);

		virtual r_Tiling* clone() const;

		virtual r_Tiling_Scheme get_tiling_scheme() const;

		static const char* description;

	protected:

		/// Tile size
		r_Bytes tile_size;
 	};


class r_Dimension_Tiling :	public r_Size_Tiling
	{
	public:
		/// Constructor for this object (Takes dim (no of dimension) and tile size as parameter)
		r_Dimension_Tiling(r_Dimension dim, r_Bytes ts = RMInit::clientTileSize);

		/// does not do anything
		virtual ~r_Dimension_Tiling();

		/// Gets the current dimension
		r_Dimension get_dimension() const;

		virtual void print_status(std::ostream& os) const;
		
		virtual bool is_compatible(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const;
		/// returns true if the cellTypeSize is smaller or equal to the tile size and the dimension fits the obj_domain

		virtual std::vector<r_Minterval>* compute_tiles(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const throw (r_Error) = 0;

		virtual r_Tiling* clone() const = 0;

	protected:

		/// dimension the mdd must have
		r_Dimension dimension;
 	};


class r_No_Tiling :	public r_Tiling
	{
	public:
		/// Constructor that reads everything from a string e.g."100"
		/// This string is ignored in the constructor, it is present 
		/// in order to have an uniform interface 
		r_No_Tiling(const char* encoded) throw (r_Error);	
		/// Constructor for this object 
		r_No_Tiling();

		/// does not do anything
		virtual ~r_No_Tiling();

		/// Prints the current status of the object
		virtual void print_status(std::ostream& os) const;
		
		/// Check compatibility of object domain with this tiling
		virtual bool is_compatible(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const;
		/// returns true

		/// Decompose an object in tiles
		virtual std::vector<r_Minterval>* compute_tiles(const r_Minterval& obj_domain, r_Bytes cellTypeSize) const throw (r_Error);
		/// returns obj_domain

		virtual r_Tiling* clone() const;

		virtual r_Tiling_Scheme get_tiling_scheme() const;

		static const char* description;
 	};


/*@Doc:
    Prints the status of a Tiling object to a stream
*/
//extern std::ostream& operator<<(std::ostream& os, const r_Size_Tiling& t);

/*@Doc:
    Prints the status of a Tiling object to a stream
*/
//extern std::ostream& operator<<(std::ostream& os, const r_No_Tiling& t);

/*@Doc:
    Prints the status of a Tiling object to a stream
*/
extern std::ostream& operator<<(std::ostream& os, const r_Tiling& t);

#include "rasodmg/tiling.hh"
#if (defined(__VISUALC__) && !defined(__EXECUTABLE__))
  #define __EXECUTABLE__
  #include "raslib/dlist.hh"
  #undef  __EXECUTABLE__
#else
  #include "raslib/dlist.hh"
#endif

#endif