3#include "MantidNexus/DllConfig.h"
11#define MYH5DLL __declspec(dllimport)
30template <herr_t (*const D)(h
id_t)>
class Hdf5ID {
65 if (this->isValid()) {
73 if (this->isValid()) {
127 if (this->m_id !=
id) {
152 reset(std::move(uid));
182 uid.m_leash_counts =
nullptr;
211 if (this->m_id !=
id) {
212 decrement_leash_counts();
214 m_leash_counts =
nullptr;
215 increment_leash_counts();
222 if (&uid !=
this && uid.
m_id != this->m_id) {
223 decrement_leash_counts();
224 this->m_id = uid.
m_id;
226 increment_leash_counts();
233 if (&uid !=
this && uid.m_id != this->m_id) {
234 decrement_leash_counts();
235 this->m_id = uid.m_id;
236 m_leash_counts = uid.m_leash_counts;
239 uid.m_leash_counts =
nullptr;
245 if (this->isValid()) {
246 if (!m_leash_counts) {
247 m_leash_counts =
new std::atomic<std::size_t>(1);
255 if (m_leash_counts) {
257 std::size_t prev_counts = (*m_leash_counts).fetch_sub(1);
258 if (prev_counts == 1) {
260 delete m_leash_counts;
261 m_leash_counts =
nullptr;
262 }
else if (prev_counts == 0) {
263 m_leash_counts->store(0);
264 delete m_leash_counts;
265 m_leash_counts =
nullptr;
281 reset(std::move(uid));
int64_t hid_t
This class defines data types which are used as part of the Nexus API.
MYH5DLL herr_t H5Fclose(hid_t)
MYH5DLL herr_t H5Iis_valid(hid_t)
MYH5DLL herr_t H5garbage_collect()
A very simple wrapper that holds an HDF5 object through its hid_t.
bool operator<=(hid_t const id) const
bool isValid() const
Return whether the UniqueId corresponds to a valid HDF5 object.
hid_t get() const
Return the managed HDF5 handle.
Hdf5ID(hid_t const id) noexcept
bool operator==(hid_t const id) const
bool operator!=(hid_t const id) const
bool operator<(hid_t const id) const
void close()
Close the held object ID.
A wrapper class for managing HDF5 object handles (hid_t) that can be shared.
void increment_leash_counts()
void decrement_leash_counts()
SharedID< D > & operator=(hid_t const)
SharedID(SharedID< D > const &uid)
bool operator==(SharedID< D > const &uid) const
ensure two SharedIDs are tracking the same object
std::atomic< std::size_t > * m_leash_counts
std::size_t use_count() const
Returns the number of SharedID objects holding the same ID.
SharedID(SharedID< D > &&uid)
A wrapper class for managing HDF5 object handles (hid_t).
void reset(UniqueID< D > &&)
Close the existing ID and replace with the new ID; or, set to invalid.
hid_t release()
Release hold on the managed ID; it will not be closed by this UniqueID.
UniqueID(UniqueID< D > const &)=delete
void reset(UniqueID< D > const &)=delete
UniqueID(UniqueID< D > &&uid) noexcept
void reset(hid_t const)
Close the existing ID and replace with the new ID; or, set to invalid.
UniqueID< D > & operator=(hid_t const)
Assign a HDF5 object ID to be managed.
UniqueID< D > & operator=(UniqueID< D > &&)
Pass the HDF5 object ID from an existing UniqueID to another UniqueID.
UniqueID & operator=(UniqueID< D > const &)=delete
Header for a base Nexus::Exception.
constexpr hid_t INVALID_HID
an ID that HDF5 will always consider invalid