17#include "../H5Object.hpp"
22 : parent_id(location.getId()) {
23 obj_name = details::get_name(
24 [&](
char* buffer,
size_t length) {
return H5Iget_name(
object.getId(), buffer, length); });
28 if (H5Rcreate(refptr, parent_id, obj_name.c_str(), H5R_OBJECT, -1) < 0) {
29 HDF5ErrMapper::ToException<ReferenceException>(
30 std::string(
"Unable to create the reference for \"") + obj_name +
"\":");
35 return get_ref(location).
getType();
40 static_assert(std::is_same<DataSet, T>::value || std::is_same<Group, T>::value,
41 "We can only (de)reference HighFive::Group or HighFive:DataSet");
42 auto obj = get_ref(location);
43 if (obj.getType() != T::type) {
44 HDF5ErrMapper::ToException<ReferenceException>(
"Trying to dereference the wrong type");
46#if defined __GNUC__ && __GNUC__ < 9
47 return std::move(obj);
53inline Object Reference::get_ref(
const Object& location)
const {
55#if (H5Rdereference_vers == 2)
56 if ((res = H5Rdereference(location.
getId(), H5P_DEFAULT, H5R_OBJECT, &href)) < 0) {
57 HDF5ErrMapper::ToException<ReferenceException>(
"Unable to dereference.");
60 if ((res = H5Rdereference(location.
getId(), H5R_OBJECT, &href)) < 0) {
61 HDF5ErrMapper::ToException<ReferenceException>(
"Unable to dereference.");
Definition H5Object.hpp:54
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:65
ObjectType getType() const
Gets the fundamental type of the object (dataset, group, etc)
Definition H5Object_misc.hpp:88
T dereference(const Object &location) const
Retrieve the Object being referenced by the Reference.
Definition H5Reference_misc.hpp:39
Reference()=default
Create an empty Reference to be initialized later.
ObjectType getType(const Object &location) const
Get only the type of the referenced Object.
Definition H5Reference_misc.hpp:34
void create_ref(hobj_ref_t *refptr) const
Create the low-level reference and store it at refptr.
Definition H5Reference_misc.hpp:27
Definition H5_definitions.hpp:15
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:24