Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | List of all members
Mantid::Nexus::UniqueID< D > Class Template Reference

A wrapper class for managing HDF5 object handles (hid_t). More...

#include <UniqueID.h>

Public Member Functions

hid_t get () const
 Return the managed HDF5 handle.
 
bool isValid () const
 Return whether the UniqueId corresponds to a valid HDF5 object.
 
 operator hid_t () const
 
bool operator< (int const id) const
 
bool operator<= (int const id) const
 
UniqueID< D > & operator= (hid_t const id)
 Assign a HDF5 object ID to be managed.
 
UniqueID< D > & operator= (UniqueID< D > &&uid)
 Pass the HDF5 object ID from an existing UniqueID to another UniqueID.
 
bool operator== (int const id) const
 
hid_t release ()
 Release hold on the managed ID; it will not be closed by this UniqueID.
 
void reset (hid_t const id=INVALID_ID)
 Close the existing ID and replace with the new ID; or, set to invalid.
 
 UniqueID ()
 
 UniqueID (hid_t const id)
 
 UniqueID (UniqueID< D > &&uid) noexcept
 
 ~UniqueID ()
 

Static Public Attributes

static hid_t constexpr INVALID_ID {-1}
 represents an invalid ID value
 

Protected Attributes

hid_t m_id
 

Private Member Functions

void close ()
 Close the held ID by calling its deleter function.
 
void close ()
 Close a ID corresponding to a file; and call garbage collection.
 
UniqueIDoperator= (UniqueID< D > const &)=delete
 
 UniqueID (UniqueID< D > const &uid)=delete
 

Detailed Description

template<herr_t(*)(hid_t) D>
class Mantid::Nexus::UniqueID< D >

A wrapper class for managing HDF5 object handles (hid_t).

The UniqueID class is designed to manage the lifecycle of HDF5 object handles (hid_t), ensuring that the handle is properly closed when the UniqueID object is destroyed. This helps prevent resource leaks and ensures proper cleanup of HDF5 resources.

Definition at line 29 of file UniqueID.h.

Constructor & Destructor Documentation

◆ UniqueID() [1/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::UniqueID ( UniqueID< D > const &  uid)
privatedelete

◆ UniqueID() [2/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::UniqueID ( )
inline

Definition at line 40 of file UniqueID.h.

◆ UniqueID() [3/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::UniqueID ( hid_t const  id)
inline

Definition at line 41 of file UniqueID.h.

◆ ~UniqueID()

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::~UniqueID ( )
inline

Definition at line 42 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::close().

◆ UniqueID() [4/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::UniqueID ( UniqueID< D > &&  uid)
inlinenoexcept

Definition at line 43 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::INVALID_ID.

Member Function Documentation

◆ close() [1/2]

template<herr_t(*)(hid_t) deleter>
void Mantid::Nexus::UniqueID< deleter >::close ( )
inlineprivate

Close the held ID by calling its deleter function.

Template Parameters
deleter

Definition at line 82 of file UniqueID.h.

Referenced by Mantid::Nexus::UniqueID< D >::~UniqueID().

◆ close() [2/2]

void Mantid::Nexus::UniqueID<&H5Fclose >::close ( )
inlineprivate

Close a ID corresponding to a file; and call garbage collection.

Definition at line 90 of file UniqueID.h.

References H5Fclose(), and H5garbage_collect().

◆ get()

template<herr_t(*)(hid_t) D>
hid_t Mantid::Nexus::UniqueID< D >::get ( ) const
inline

Return the managed HDF5 handle.

Returns
the managed HDF5 handle

Definition at line 59 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::m_id.

◆ isValid()

template<herr_t(*)(hid_t) D>
bool Mantid::Nexus::UniqueID< D >::isValid ( ) const
inline

Return whether the UniqueId corresponds to a valid HDF5 object.

Returns
true if it is valid; otherwise false; on error, false

Definition at line 71 of file UniqueID.h.

References H5Iis_valid().

◆ operator hid_t()

template<herr_t(*)(hid_t) D>
Mantid::Nexus::UniqueID< D >::operator hid_t ( ) const
inline

Definition at line 55 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::m_id.

◆ operator<()

template<herr_t(*)(hid_t) D>
bool Mantid::Nexus::UniqueID< D >::operator< ( int const  id) const
inline

Definition at line 52 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::m_id.

◆ operator<=()

template<herr_t(*)(hid_t) D>
bool Mantid::Nexus::UniqueID< D >::operator<= ( int const  id) const
inline

Definition at line 51 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::m_id.

◆ operator=() [1/3]

template<herr_t(*)(hid_t) D>
UniqueID< D > & Mantid::Nexus::UniqueID< D >::operator= ( hid_t const  id)
inline

Assign a HDF5 object ID to be managed.

Parameters
id: the ID to be managed

Definition at line 118 of file UniqueID.h.

◆ operator=() [2/3]

template<herr_t(*)(hid_t) D>
UniqueID< D > & Mantid::Nexus::UniqueID< D >::operator= ( UniqueID< D > &&  uid)
inline

Pass the HDF5 object ID from an existing UniqueID to another UniqueID.

Parameters
uid: the UniqueID previously managing the ID; it will lose ownership of the ID.

Definition at line 125 of file UniqueID.h.

◆ operator=() [3/3]

template<herr_t(*)(hid_t) D>
UniqueID & Mantid::Nexus::UniqueID< D >::operator= ( UniqueID< D > const &  )
privatedelete

◆ operator==()

template<herr_t(*)(hid_t) D>
bool Mantid::Nexus::UniqueID< D >::operator== ( int const  id) const
inline

Definition at line 50 of file UniqueID.h.

References Mantid::Nexus::UniqueID< D >::m_id.

◆ release()

template<herr_t(*)(hid_t) D>
hid_t Mantid::Nexus::UniqueID< D >::release ( )
inline

Release hold on the managed ID; it will not be closed by this UniqueID.

Returns
the managed ID

Definition at line 101 of file UniqueID.h.

References tmp.

◆ reset()

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::UniqueID< D >::reset ( hid_t const  id = INVALID_ID)
inline

Close the existing ID and replace with the new ID; or, set to invalid.

Parameters
idThe new ID to be held; defaults to invalid

Definition at line 109 of file UniqueID.h.

Referenced by Mantid::Nexus::H5Util::copyGroup(), and Mantid::Nexus::H5Util::isHdf5().

Member Data Documentation

◆ INVALID_ID

template<herr_t(*)(hid_t) D>
hid_t constexpr Mantid::Nexus::UniqueID< D >::INVALID_ID {-1}
staticconstexpr

represents an invalid ID value

Definition at line 66 of file UniqueID.h.

Referenced by Mantid::Nexus::UniqueID< D >::UniqueID().

◆ m_id

template<herr_t(*)(hid_t) D>
hid_t Mantid::Nexus::UniqueID< D >::m_id
protected

The documentation for this class was generated from the following file: