Skip to content

Commit

Permalink
Add private DataSpace (named) ctor fromId.
Browse files Browse the repository at this point in the history
Certain HDF5 API creates data spaces, in order to use this API, we need
to be able to create `HighFive::DataSpace` from an HID.
  • Loading branch information
1uc committed Jul 25, 2024
1 parent 8bb1ed8 commit 484aad7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions include/highfive/H5DataSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@

namespace HighFive {

namespace detail {
/// @brief Create a HighFive::DataSpace from an HID, without incrementing the id.
///
/// @note This is internal API and subject to change.
/// @internal
DataSpace make_data_space(hid_t hid);
} // namespace detail

/// \brief Class representing the space (dimensions) of a DataSet
///
/// \code{.cpp}
Expand Down Expand Up @@ -254,9 +262,18 @@ class DataSpace: public Object {
protected:
DataSpace() = default;

static DataSpace fromId(hid_t hid) {
DataSpace space;
space._hid = hid;

Check warning on line 267 in include/highfive/H5DataSpace.hpp

View check run for this annotation

Codecov / codecov/patch

include/highfive/H5DataSpace.hpp#L265-L267

Added lines #L265 - L267 were not covered by tests

return space;

Check warning on line 269 in include/highfive/H5DataSpace.hpp

View check run for this annotation

Codecov / codecov/patch

include/highfive/H5DataSpace.hpp#L269

Added line #L269 was not covered by tests
}

friend class Attribute;
friend class File;
friend class DataSet;

friend DataSpace detail::make_data_space(hid_t hid);
};

} // namespace HighFive
Expand Down
6 changes: 6 additions & 0 deletions include/highfive/bits/H5Dataspace_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@

namespace HighFive {

namespace detail {
DataSpace make_data_space(hid_t hid) {
return DataSpace::fromId(hid);

Check warning on line 26 in include/highfive/bits/H5Dataspace_misc.hpp

View check run for this annotation

Codecov / codecov/patch

include/highfive/bits/H5Dataspace_misc.hpp#L25-L26

Added lines #L25 - L26 were not covered by tests
}
} // namespace detail

inline DataSpace::DataSpace(const std::vector<size_t>& dims)
: DataSpace(dims.begin(), dims.end()) {}

Expand Down

0 comments on commit 484aad7

Please sign in to comment.