rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
sinterval.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 Lesser 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Copyright 2003 - 2010 Peter Baumann / rasdaman GmbH.
18  *
19  * For more information please see <http://www.rasdaman.org>
20  * or contact Peter Baumann via <baumann@rasdaman.com>.
21 */
22 
23 #ifndef D_SINTERVAL_HH
24 #define D_SINTERVAL_HH
25 
26 #include "raslib/mddtypes.hh" // for r_Range, r_Bytes
27 #include <iosfwd> // for ostream, cout
28 #include <string>
29 
30 //@ManMemo: Module: {\bf raslib}
214 {
215 public:
217  using OffsetType = size_t;
218 
220  r_Sinterval() = default;
222  explicit r_Sinterval(const char *);
226  explicit r_Sinterval(r_Range point);
227 
228  // Constructors for intervals with at least one open bound.
230  r_Sinterval(char, r_Range high);
231  r_Sinterval(r_Range low, char);
232  r_Sinterval(char, char);
234 
235  // Equality comparison
237  bool operator==(const r_Sinterval &) const;
240  bool operator!=(const r_Sinterval &) const;
242 
243  // Read/Write methods:
245  r_Range low() const noexcept;
246  r_Range high() const noexcept;
248  OffsetType get_extent() const;
250  bool is_fixed() const noexcept;
251  bool is_low_fixed() const noexcept;
252  bool is_low_unbounded() const noexcept;
253  bool is_high_fixed() const noexcept;
254  bool is_high_unbounded() const noexcept;
256  bool is_slice() const noexcept;
257  void set_low(r_Range low);
258  void set_low(char) noexcept;
259  void set_high(r_Range high);
260  void set_high(char) noexcept;
262  void set_interval(char, r_Range high) noexcept;
263  void set_interval(r_Range low, char) noexcept;
264  void set_interval(char, char) noexcept;
265  void set_slice() noexcept;
266 
269  const std::string &get_axis_name() const;
272  void set_axis_name(const std::string &axis_name_arg);
274  bool has_axis_name() const;
275 
278  OffsetType get_offset_to(BoundType o) const noexcept;
281  OffsetType get_offset_to(const r_Sinterval &o) const noexcept;
284  r_Sinterval translate_by(BoundType offset) const;
286 
287  // Methods/Operators for the union operation:
289  r_Sinterval &union_of(const r_Sinterval &, const r_Sinterval &);
291  r_Sinterval &operator+=(const r_Sinterval &);
292  r_Sinterval create_union(const r_Sinterval &) const;
293  r_Sinterval operator+(const r_Sinterval &) const;
295  bool inside_of(const r_Sinterval &o) const;
297 
298  // Methods/Operators for the difference operation:
302  r_Sinterval &operator-=(const r_Sinterval &);
304  r_Sinterval operator-(const r_Sinterval &) const;
306 
307  // Methods/Operators for the intersection operation:
311  r_Sinterval &operator*=(const r_Sinterval &);
313  r_Sinterval operator*(const r_Sinterval &) const;
315  bool intersects_with(const r_Sinterval &) const;
317 
318  // Methods/Operators for the closure operation:
320  r_Sinterval &closure_of(const r_Sinterval &, const r_Sinterval &);
322  r_Sinterval create_closure(const r_Sinterval &) const;
324 
326  void print_status(std::ostream &s) const;
327 
330  char *get_string_representation() const;
331 
333  std::string to_string() const;
334 
335  // Methods for internal use only:
337  r_Bytes get_storage_size() const;
340 
341 
342 private:
343  // Calculation methods for the operations:
345  r_Sinterval calc_union(const r_Sinterval &a, const r_Sinterval &b) const;
346  r_Sinterval calc_difference(const r_Sinterval &a, const r_Sinterval &b) const;
347  r_Sinterval calc_intersection(const r_Sinterval &a, const r_Sinterval &b) const;
348  r_Sinterval calc_closure(const r_Sinterval &a, const r_Sinterval &b) const;
350  int classify(const r_Sinterval &a, const r_Sinterval &b) const;
352 
354  std::string axis_name;
356  r_Range lower_bound{};
358  r_Range upper_bound{};
359 
361  bool low_fixed{false};
363  bool high_fixed{false};
365  bool slice{false};
366 };
367 
368 //@ManMemo: Module: {\bf raslib}
372 extern std::ostream &operator<<(std::ostream &s, const r_Sinterval &d);
373 
374 #endif
r_Sinterval::operator!=
bool operator!=(const r_Sinterval &) const
non equal operator - negation of equal operator
r_Sinterval::operator==
bool operator==(const r_Sinterval &) const
Two intervals are equal if they have the same lower and upper bound.
mddtypes.hh
r_Sinterval::get_storage_size
r_Bytes get_storage_size() const
calculate the size of the storage space occupied
r_Sinterval::set_axis_name
void set_axis_name(const std::string &axis_name_arg)
set an axis name for this interval; an empty string will clear any axis name.
r_Sinterval::low
r_Range low() const noexcept
operator<<
std::ostream & operator<<(std::ostream &s, const r_Sinterval &d)
Output stream operator for objects of type const r_Sinterval.
r_Sinterval::create_difference
r_Sinterval create_difference(const r_Sinterval &) const
r_Sinterval::set_high
void set_high(r_Range high)
r_Sinterval::r_Sinterval
r_Sinterval()=default
default constructor creates an interval with open bounds
r_Sinterval::create_union
r_Sinterval create_union(const r_Sinterval &) const
r_Sinterval::is_low_unbounded
bool is_low_unbounded() const noexcept
r_Sinterval::is_low_fixed
bool is_low_fixed() const noexcept
r_Sinterval::get_extent
OffsetType get_extent() const
get the size of one dimensional interval as range (high() - low() + 1)
r_Sinterval::create_intersection
r_Sinterval create_intersection(const r_Sinterval &) const
r_Sinterval::closure_with
r_Sinterval & closure_with(const r_Sinterval &)
r_Sinterval::is_high_unbounded
bool is_high_unbounded() const noexcept
r_Sinterval::high
r_Range high() const noexcept
r_Sinterval::intersection_of
r_Sinterval & intersection_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval::difference_of
r_Sinterval & difference_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval::OffsetType
size_t OffsetType
Definition: sinterval.hh:217
r_Sinterval::translate_by
r_Sinterval translate_by(BoundType offset) const
translate this interval by a given offset; assumes that this interval has fixed bounds
r_Sinterval::closure_of
r_Sinterval & closure_of(const r_Sinterval &, const r_Sinterval &)
r_Bytes
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition: mddtypes.hh:43
r_Sinterval::print_status
void print_status(std::ostream &s) const
writes the state of the object to the specified stream
r_Sinterval::get_string_representation
char * get_string_representation() const
Returns a string representation of this sinterval as a pointer that should eventually be deallocated ...
r_Sinterval::to_string
std::string to_string() const
Returns a string representation of this sinterval as a string object.
r_Sinterval::create_closure
r_Sinterval create_closure(const r_Sinterval &) const
r_Sinterval::intersects_with
bool intersects_with(const r_Sinterval &) const
determines if the self interval intersects with the delivered one
r_Range
std::int64_t r_Range
for axis indexing, e.g.
Definition: mddtypes.hh:53
r_Sinterval::set_slice
void set_slice() noexcept
r_Sinterval::set_interval
void set_interval(r_Range low, r_Range high)
r_Sinterval::union_with
r_Sinterval & union_with(const r_Sinterval &)
r_Sinterval::union_of
r_Sinterval & union_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval::set_low
void set_low(r_Range low)
r_Sinterval::get_axis_name
const std::string & get_axis_name() const
r_Sinterval::inside_of
bool inside_of(const r_Sinterval &o) const
r_Sinterval::BoundType
r_Range BoundType
Definition: sinterval.hh:216
r_Sinterval::get_offset_to
OffsetType get_offset_to(BoundType o) const noexcept
get distance to lower bound of this interval from o; this interval is assumed to be fixed in the lowe...
r_Sinterval::intersection_with
r_Sinterval & intersection_with(const r_Sinterval &)
r_Sinterval::difference_with
r_Sinterval & difference_with(const r_Sinterval &)
r_Sinterval::is_high_fixed
bool is_high_fixed() const noexcept
r_Sinterval::is_fixed
bool is_fixed() const noexcept
r_Sinterval::has_axis_name
bool has_axis_name() const
r_Sinterval
The class represents an interval with lower and upper bound.
Definition: sinterval.hh:213
r_Sinterval::is_slice
bool is_slice() const noexcept