10#ifndef H5REFERENCE_MISC_HPP
11#define H5REFERENCE_MISC_HPP
21 : parent_id(location.getId(false)) {
22 obj_name = details::get_name([&](
char *buffer, hsize_t length) {
23 return H5Iget_name(
object.getId(
false), buffer, length); });
27 if (H5Rcreate(refptr, parent_id, obj_name.c_str(), H5R_OBJECT, -1) < 0) {
28 HDF5ErrMapper::ToException<ReferenceException>(
29 std::string(
"Unable to create the reference for \"") + obj_name +
"\":");
39 static_assert(std::is_same<DataSet, T>::value || std::is_same<Group, T>::value,
40 "We can only (de)reference h5gt::Group or h5gt:DataSet");
41 auto obj = get_ref(location) ;
42 if (obj.getObjectType() != T::type) {
43 HDF5ErrMapper::ToException<ReferenceException>(
44 "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(
false), H5P_DEFAULT, H5R_OBJECT, &href)) < 0) {
57 HDF5ErrMapper::ToException<ReferenceException>(
"Unable to dereference.");
60 if ((res = H5Rdereference(location.
getId(
false), H5R_OBJECT, &href)) < 0) {
61 HDF5ErrMapper::ToException<ReferenceException>(
"Unable to dereference.");
Definition H5Object.hpp:55
ObjectType getObjectType() const
Gets the fundamental type of the object (dataset, group, etc)
Definition H5Object_misc.hpp:195
hid_t getId(const bool &increaseRefCount=false) const noexcept
getId
Definition H5Object_misc.hpp:172
void create_ref(hobj_ref_t *refptr) const
Create the low-level reference and store it at refptr.
Definition H5Reference_misc.hpp:26
ObjectType getType(const Object &location) const
Get only the type of the referenced Object.
Definition H5Reference_misc.hpp:33
T dereference(const Object &location) const
Retrieve the Object being referenced by the Reference.
Definition H5Reference_misc.hpp:38
Reference()=default
Create an empty Reference to be initialized later.