Skip to content

Commit

Permalink
Add private DataSpace (named) ctor fromId. (#1030)
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 authored Jul 26, 2024
1 parent 8f00f1c commit 62bef2f
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;

return space;
}

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 {
inline DataSpace make_data_space(hid_t hid) {
return DataSpace::fromId(hid);
}
} // namespace detail

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

Expand Down

0 comments on commit 62bef2f

Please sign in to comment.