rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
tiling.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 
24 #ifndef _R_TILING_HH_
25 #define _R_TILING_HH_
26 
27 #include "raslib/mddtypes.hh"
28 
29 #include <vector>
30 #include <iosfwd>
31 #include <memory>
32 
33 class r_Tiling;
34 class r_No_Tiling;
35 class r_Size_Tiling;
36 class r_Dimension_Tiling;
37 class r_Minterval;
38 
39 //@ManMemo: Module {\bf rasodmg}
40 
52 class r_Tiling
53 {
54 public:
55  virtual ~r_Tiling() = default;
56 
58  virtual void print_status(std::ostream &os) const = 0;
59 
61  virtual bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const = 0;
62 
64  virtual std::vector<r_Minterval> compute_tiles(const r_Minterval &obj_domain, r_Bytes cell_size) const = 0;
75  virtual r_Tiling *clone() const = 0;
81  virtual r_Tiling_Scheme get_tiling_scheme() const = 0;
86  static const char *ASTERIX;
87  static const char *TCOLON;
88  static const char *TCOMMA;
89  static const char *LSQRBRA;
90  static const char *RSQRBRA;
91  static const int DefaultBase;
92  static const r_Bytes defaultTileSize;
93 
94 protected:
95  void check_nonempty_tiling(const char *encoded) const;
96  void check_premature_stream_end(const char *currPos, const char *endPos) const;
97  r_Minterval parse_minterval(const char *encoded) const;
98  unsigned int parse_unsigned(const char *encoded) const;
99  unsigned long parse_unsigned_long(const char *encoded) const;
100  long parse_long(const char *encoded) const;
101  double parse_double(const char *encoded) const;
102  std::unique_ptr<char[]> copy_buffer(const char *buf, size_t len) const;
103  const char *advance_to_next_char(const char *p, const char *search) const;
104 };
105 
109 class r_No_Tiling : public r_Tiling
110 {
111 public:
114  explicit r_No_Tiling(const char *encoded);
115  r_No_Tiling() = default;
116  virtual ~r_No_Tiling() = default;
117 
119  void print_status(std::ostream &os) const override;
120 
122  bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override;
124 
126  std::vector<r_Minterval> compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override;
128 
129  r_Tiling *clone() const override;
130 
132 
133  static const char *description;
134 };
135 
139 class r_Size_Tiling : public r_Tiling
140 {
141 public:
143  explicit r_Size_Tiling(const char *encoded);
145  virtual ~r_Size_Tiling() = default;
146 
147  void print_status(std::ostream &os) const override;
148 
150  bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override;
151 
152  std::vector<r_Minterval> compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override;
153 
155  r_Tiling *clone() const override;
157 
158  static const char *description;
159 
160 protected:
163 };
164 
169 {
170 public:
173  virtual ~r_Dimension_Tiling() = default;
174 
175  void print_status(std::ostream &os) const override;
177  bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override;
178 
180  std::vector<r_Minterval> compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override = 0;
181  r_Tiling *clone() const override = 0;
182 
183 protected:
186 };
187 
188 extern std::ostream &operator<<(std::ostream &os, const r_Tiling &t);
189 
190 #endif
Definition: tiling.hh:169
r_Tiling * clone() const override=0
This method provides the core funcionality of this class.
r_Dimension_Tiling(r_Dimension dim, r_Bytes ts=r_Tiling::defaultTileSize)
Constructor for this object (Takes dim (no of dimension) and tile size as parameter)
void print_status(std::ostream &os) const override
Prints the current status of the object.
r_Dimension get_dimension() const
r_Dimension dimension
dimension the mdd must have
Definition: tiling.hh:185
virtual ~r_Dimension_Tiling()=default
std::vector< r_Minterval > compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override=0
Decompose an object in tiles.
bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override
returns true if the cellTypeSize is smaller or equal to the tile size and the dimension fits the obj_...
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition: minterval.hh:226
Definition: tiling.hh:110
void print_status(std::ostream &os) const override
Prints the current status of the object.
r_Tiling_Scheme get_tiling_scheme() const override
This method is similar to a copy constructor, this is, is returns a copy of the current object.
static const char * description
Definition: tiling.hh:133
bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override
Check compatibility of object domain with this tiling.
std::vector< r_Minterval > compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override
returns true
r_No_Tiling()=default
r_No_Tiling(const char *encoded)
Constructor that reads everything from a string e.g.
virtual ~r_No_Tiling()=default
r_Tiling * clone() const override
returns obj_domain
Definition: tiling.hh:140
std::vector< r_Minterval > compute_tiles(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override
Decompose an object in tiles.
bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const override
returns true if the cellTypeSize is smaller or equal to the tile size and obj_domain has more than 0 ...
static const char * description
Definition: tiling.hh:158
void print_status(std::ostream &os) const override
Prints the current status of the object.
r_Size_Tiling(const char *encoded)
Constructor that reads everything from a string e.g."100".
r_Size_Tiling(r_Bytes ts=r_Tiling::defaultTileSize)
virtual ~r_Size_Tiling()=default
r_Tiling_Scheme get_tiling_scheme() const override
This method is similar to a copy constructor, this is, is returns a copy of the current object.
r_Tiling * clone() const override
This method provides the core funcionality of this class.
r_Bytes tile_size
Tile size.
Definition: tiling.hh:162
r_Bytes get_tile_size() const
The r_Tiling class is used to specify in which way the tiling is done by the system.
Definition: tiling.hh:53
void check_premature_stream_end(const char *currPos, const char *endPos) const
void check_nonempty_tiling(const char *encoded) const
static const char * TCOLON
Definition: tiling.hh:87
unsigned int parse_unsigned(const char *encoded) const
static const int DefaultBase
Definition: tiling.hh:91
std::unique_ptr< char[]> copy_buffer(const char *buf, size_t len) const
static const char * TCOMMA
Definition: tiling.hh:88
virtual std::vector< r_Minterval > compute_tiles(const r_Minterval &obj_domain, r_Bytes cell_size) const =0
Decompose an object in tiles.
unsigned long parse_unsigned_long(const char *encoded) const
static const char * LSQRBRA
Definition: tiling.hh:89
virtual ~r_Tiling()=default
static const char * RSQRBRA
Definition: tiling.hh:90
static const r_Bytes defaultTileSize
Definition: tiling.hh:92
r_Minterval parse_minterval(const char *encoded) const
virtual r_Tiling_Scheme get_tiling_scheme() const =0
This method is similar to a copy constructor, this is, is returns a copy of the current object.
double parse_double(const char *encoded) const
virtual void print_status(std::ostream &os) const =0
Prints the current status of the object.
virtual r_Tiling * clone() const =0
This method provides the core funcionality of this class.
virtual bool is_compatible(const r_Minterval &obj_domain, r_Bytes cellTypeSize) const =0
Check compatibility of object domain with this tiling.
long parse_long(const char *encoded) const
const char * advance_to_next_char(const char *p, const char *search) const
static const char * ASTERIX
return the type of tiling scheme
Definition: tiling.hh:86
std::uint32_t r_Dimension
number of dimensions in r_Point and r_Minterval.
Definition: mddtypes.hh:56
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition: mddtypes.hh:43
r_Tiling_Scheme
Tiling of the object:
Definition: mddtypes.hh:317
std::ostream & operator<<(std::ostream &os, const r_Tiling &t)