1 #ifndef UTOPIA_DATAIO_HDFIDENTIFIER_HH
2 #define UTOPIA_DATAIO_HDFIDENTIFIER_HH
93 return H5Iget_ref(
_id);
138 if (H5Iget_ref(
_id) > 1)
156 open(hid_t
id, std::function< herr_t(hid_t) > closing_func)
160 throw std::runtime_error(
161 "Error, HDFIdentifier cannot bind to new identifier while "
162 "still being valid. Close first.");
178 open(
id, closing_func);
195 _id(other._id), _closing_func(other._closing_func)
197 increment_refcount();
207 _id(
std::move(other._id)), _closing_func(
std::move(other._closing_func))
223 increment_refcount();
237 _id = std::move(other._id);
277 return not(lhs == rhs);
Wrapper class around an hdf5 identifier, used to manage reference counts of the object this identifie...
Definition: hdfidentifier.hh:29
auto get_refcount() const
Get the number of references currently referring to the object identified by this ID.
Definition: hdfidentifier.hh:89
HDFIdentifier(const HDFIdentifier &other)
Construct HDFIdentifier by copying another instance of HDFIdentifier, incrementing the refcount of th...
Definition: hdfidentifier.hh:194
~HDFIdentifier()
Destroy the HDFIdentifier object, decrementing its refcount.
Definition: hdfidentifier.hh:246
void close()
Close the identifier and render the C-Level id held invalid.
Definition: hdfidentifier.hh:134
hid_t get_id() const
Get the HDF5 id held by this object.
Definition: hdfidentifier.hh:53
void open(hid_t id, std::function< herr_t(hid_t) > closing_func)
Open the object and bind it to another C-Level id.
Definition: hdfidentifier.hh:156
HDFIdentifier(hid_t id, std::function< herr_t(hid_t) > closing_func)
Construct HDFIdentifier from the given arguments.
Definition: hdfidentifier.hh:176
HDFIdentifier(HDFIdentifier &&other)
Construct HDFIdentifier by moving from another instance of HDFIdentifier.
Definition: hdfidentifier.hh:206
void decrement_refcount()
Decrease the reference count of the object referred to by this ID by one.
Definition: hdfidentifier.hh:121
std::function< herr_t(hid_t) > _closing_func
Definition: hdfidentifier.hh:31
HDFIdentifier()
Construct HDFIdentifier from the given arguments.
Definition: hdfidentifier.hh:185
bool is_valid() const
Check if thi ID refers to a valid object.
Definition: hdfidentifier.hh:77
hid_t _id
Definition: hdfidentifier.hh:30
HDFIdentifier & operator=(const HDFIdentifier &other)
Assign HDFIdentifier by copying another instance of HDFIdentifier, incrementing the refcount of the h...
Definition: hdfidentifier.hh:218
void swap(HDFIdentifier &other)
Exchange states between caller and 'other'.
Definition: hdfidentifier.hh:40
void increment_refcount()
Increase the reference count of the object referred to by this ID by one.
Definition: hdfidentifier.hh:107
void set_id(hid_t id)
Set id to the given argument. Only to be used to invalidate objects upon move or similar.
Definition: hdfidentifier.hh:65
HDFIdentifier & operator=(HDFIdentifier &&other)
Assign HDFIdentifier by moving from another instance of HDFIdentifier.
Definition: hdfidentifier.hh:235
bool check_validity(htri_t valid, const std::string_view object_name)
Check for validity of a hdf5 htri_t type or similar.
Definition: hdfutilities.hh:73
bool operator!=(const HDFIdentifier &lhs, const HDFIdentifier &rhs)
Comparsion operator for inequality.
Definition: hdfidentifier.hh:275
void swap(HDFIdentifier &lhs, HDFIdentifier &rhs)
Exchange the states of lhs and rhs.
Definition: hdfidentifier.hh:287
bool operator==(const HDFIdentifier &lhs, const HDFIdentifier &rhs)
Comparsion operator for equality.
Definition: hdfidentifier.hh:262
This file provides metafunctions for automatically determining the nature of a C/C++ types at compile...
Definition: parallel.hh:235