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{
215public:
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.
232 r_Sinterval(char, char);
234
235 // Equality comparison
237
238 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;
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;
258 void set_low(char) noexcept;
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
281 OffsetType get_offset_to(const r_Sinterval &o) const noexcept;
286
287 // Methods/Operators for the union operation:
291 r_Sinterval &operator+=(const r_Sinterval &);
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:
324
326 void print_status(std::ostream &s) const;
327
331
333 std::string to_string() const;
334
335 // Methods for internal use only:
337
340
341
342private:
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}
372extern std::ostream &operator<<(std::ostream &s, const r_Sinterval &d);
373
374#endif
The class represents an interval with lower and upper bound.
Definition sinterval.hh:214
r_Sinterval create_union(const r_Sinterval &) const
bool operator!=(const r_Sinterval &) const
non equal operator - negation of equal operator
bool is_high_fixed() const noexcept
r_Sinterval & union_with(const r_Sinterval &)
r_Sinterval(r_Range low, r_Range high)
constructor for an interval with fixed bounds
bool is_low_unbounded() const noexcept
bool is_high_unbounded() const noexcept
bool is_fixed() const noexcept
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.
void set_interval(r_Range low, r_Range high)
bool operator==(const r_Sinterval &) const
Two intervals are equal if they have the same lower and upper bound.
bool intersects_with(const r_Sinterval &) const
determines if the self interval intersects with the delivered one
char * get_string_representation() const
Returns a string representation of this sinterval as a pointer that should eventually be deallocated ...
std::string to_string() const
Returns a string representation of this sinterval as a string object.
r_Sinterval & difference_with(const r_Sinterval &)
r_Sinterval(char, char)
r_Range low() const noexcept
r_Sinterval & closure_with(const r_Sinterval &)
r_Sinterval & closure_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval create_intersection(const r_Sinterval &) const
r_Sinterval(r_Range point)
constructor for a slice (TODO)
r_Sinterval(const char *)
constructor taking string representation (e.g. *:200 )
void set_high(r_Range high)
size_t OffsetType
Definition sinterval.hh:217
bool has_axis_name() const
OffsetType get_extent() const
get the size of one dimensional interval as range (high() - low() + 1)
r_Range BoundType
Definition sinterval.hh:216
r_Sinterval & union_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval create_closure(const r_Sinterval &) const
bool inside_of(const r_Sinterval &o) const
r_Sinterval & difference_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval(r_Range low, char)
void print_status(std::ostream &s) const
writes the state of the object to the specified stream
r_Sinterval & intersection_with(const r_Sinterval &)
void set_low(r_Range low)
bool is_slice() const noexcept
r_Bytes get_storage_size() const
calculate the size of the storage space occupied
r_Sinterval create_difference(const r_Sinterval &) const
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...
void set_slice() noexcept
const std::string & get_axis_name() const
bool is_low_fixed() const noexcept
r_Sinterval translate_by(BoundType offset) const
translate this interval by a given offset; assumes that this interval has fixed bounds
r_Sinterval(char, r_Range high)
r_Sinterval & intersection_of(const r_Sinterval &, const r_Sinterval &)
r_Sinterval()=default
default constructor creates an interval with open bounds
r_Range high() const noexcept
std::int64_t r_Range
for axis indexing, e.g.
Definition mddtypes.hh:53
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition mddtypes.hh:43
std::ostream & operator<<(std::ostream &s, const r_Sinterval &d)
Output stream operator for objects of type const r_Sinterval.