| 47 | namespace tiledb { |
| 48 | |
| 49 | class NDRectangle { |
| 50 | public: |
| 51 | /* ********************************* */ |
| 52 | /* CONSTRUCTORS & DESTRUCTORS */ |
| 53 | /* ********************************* */ |
| 54 | |
| 55 | /** |
| 56 | * Constructor |
| 57 | * |
| 58 | * @param ctx The TileDB context |
| 59 | * @param domain The input Domain |
| 60 | */ |
| 61 | explicit NDRectangle(const tiledb::Context& ctx, const tiledb::Domain& domain) |
| 62 | : ctx_(ctx) { |
| 63 | tiledb_ndrectangle_t* capi_ndrect; |
| 64 | ctx.handle_error(tiledb_ndrectangle_alloc( |
| 65 | ctx.ptr().get(), domain.ptr().get(), &capi_ndrect)); |
| 66 | ndrect_ = std::shared_ptr<tiledb_ndrectangle_t>(capi_ndrect, deleter_); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Constructor |
| 71 | * |
| 72 | * @param ctx The TileDB context |
| 73 | * @param ndrect The NDRectangle C API pointer |
| 74 | * |
| 75 | * @note The object will manage the lifetime of tiledb_ndrectangle_t* |
| 76 | */ |
| 77 | NDRectangle(const tiledb::Context& ctx, tiledb_ndrectangle_t* ndrect) |
| 78 | : ctx_(ctx) { |
| 79 | ndrect_ = std::shared_ptr<tiledb_ndrectangle_t>(ndrect, deleter_); |
| 80 | } |
| 81 | |
| 82 | NDRectangle(const NDRectangle&) = default; |
| 83 | NDRectangle(NDRectangle&&) = default; |
| 84 | NDRectangle& operator=(const NDRectangle&) = default; |
| 85 | NDRectangle& operator=(NDRectangle&&) = default; |
| 86 | |
| 87 | /* ********************************* */ |
| 88 | /* API */ |
| 89 | /* ********************************* */ |
| 90 | |
| 91 | /** |
| 92 | * Adds an 1D range along a dimension name, in the form (start, end). The |
| 93 | * datatype of the range must be the same as the dimension datatype. |
| 94 | * |
| 95 | * **Example:** |
| 96 | * |
| 97 | * @code{.cpp} |
| 98 | * // Set an 1D range on dimension 0, assuming the domain type is int64. |
| 99 | * int64_t start = 10; |
| 100 | * int64_t end = 20; |
| 101 | * ndrect.set_range(0, start, end); |
| 102 | * @endcode |
| 103 | * |
| 104 | * @tparam T The dimension datatype. Must be an integer or a floating point |
| 105 | * number. |
| 106 | * @param dim_name The name of the dimension to add the range to. |
no test coverage detected