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

A wrapper class for managing HDF5 object handles (hid_t) that can be shared. More...

#include <UniqueID.h>

Inheritance diagram for Mantid::Nexus::SharedID< D >:
Mantid::Nexus::Hdf5ID< D >

Public Member Functions

SharedID< D > & operator= (hid_t const)
 
SharedID< D > & operator= (SharedID< D > &&)
 
SharedID< D > & operator= (SharedID< D > const &)
 
bool operator== (SharedID< D > const &uid) const
 ensure two SharedIDs are tracking the same object
 
void reset ()
 
void reset (hid_t const)
 Decrement the existing ID and replace with the new ID; or, set to invalid.
 
void reset (SharedID< D > &&)
 Decrement the existing ID and replace with the new ID; or, set to invalid.
 
void reset (SharedID< D > const &)
 Decrement the existing ID and replace with the new ID; or, set to invalid.
 
 SharedID ()
 
 SharedID (hid_t id)
 
 SharedID (SharedID< D > &&uid)
 
 SharedID (SharedID< D > const &uid)
 
std::size_t use_count () const
 Returns the number of SharedID objects holding the same ID.
 
 ~SharedID ()
 
- Public Member Functions inherited from Mantid::Nexus::Hdf5ID< D >
hid_t get () const
 Return the managed HDF5 handle.
 
 Hdf5ID () noexcept
 
 Hdf5ID (hid_t const id) noexcept
 
bool isValid () const
 Return whether the UniqueId corresponds to a valid HDF5 object.
 
 operator hid_t () const
 
bool operator!= (hid_t const id) const
 
bool operator< (hid_t const id) const
 
bool operator<= (hid_t const id) const
 
bool operator== (hid_t const id) const
 

Private Member Functions

void decrement_leash_counts ()
 
void increment_leash_counts ()
 

Private Attributes

std::atomic< std::size_t > * m_leash_counts
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::Nexus::Hdf5ID< D >
void close ()
 Close the held object ID.
 
void close ()
 Close a held file ID, and also call garbage collection.
 
- Protected Attributes inherited from Mantid::Nexus::Hdf5ID< D >
hid_t m_id
 

Detailed Description

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

A wrapper class for managing HDF5 object handles (hid_t) that can be shared.

The SharedID class is designed to manage the lifecycle of HDF5 object handles (hid_t), with multiple ownership, ensuring the handle is properly closed when all leashes to it are dropped. This helps prevent resource leaks and ensures proper cleanup of HDF5 resources.

Definition at line 167 of file UniqueID.h.

Constructor & Destructor Documentation

◆ SharedID() [1/4]

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

Definition at line 175 of file UniqueID.h.

◆ SharedID() [2/4]

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

Definition at line 176 of file UniqueID.h.

◆ SharedID() [3/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::SharedID< D >::SharedID ( SharedID< D > const &  uid)
inline

◆ SharedID() [4/4]

template<herr_t(*)(hid_t) D>
Mantid::Nexus::SharedID< D >::SharedID ( SharedID< D > &&  uid)
inline

Definition at line 180 of file UniqueID.h.

References Mantid::Nexus::INVALID_HID, and Mantid::Nexus::Hdf5ID< D >::m_id.

◆ ~SharedID()

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

Member Function Documentation

◆ decrement_leash_counts()

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::SharedID< D >::decrement_leash_counts ( )
inlineprivate

Definition at line 254 of file UniqueID.h.

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

◆ increment_leash_counts()

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::SharedID< D >::increment_leash_counts ( )
inlineprivate

Definition at line 244 of file UniqueID.h.

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

◆ operator=() [1/3]

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

Definition at line 270 of file UniqueID.h.

◆ operator=() [2/3]

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

Definition at line 280 of file UniqueID.h.

◆ operator=() [3/3]

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

Definition at line 275 of file UniqueID.h.

◆ operator==()

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

ensure two SharedIDs are tracking the same object

Definition at line 191 of file UniqueID.h.

References Mantid::Nexus::Hdf5ID< D >::m_id, and Mantid::Nexus::SharedID< D >::m_leash_counts.

◆ reset() [1/4]

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::SharedID< D >::reset ( )
inline

◆ reset() [2/4]

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

Decrement 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 210 of file UniqueID.h.

◆ reset() [3/4]

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::SharedID< D >::reset ( SharedID< D > &&  uid)
inline

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

Parameters
uidA SharedID whose ID will be moved to here

Definition at line 232 of file UniqueID.h.

References Mantid::Nexus::INVALID_HID.

◆ reset() [4/4]

template<herr_t(*)(hid_t) D>
void Mantid::Nexus::SharedID< D >::reset ( SharedID< D > const &  uid)
inline

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

Parameters
uidA SharedID whose ID will be shared

Definition at line 221 of file UniqueID.h.

References Mantid::Nexus::Hdf5ID< D >::m_id, and Mantid::Nexus::SharedID< D >::m_leash_counts.

◆ use_count()

template<herr_t(*)(hid_t) D>
std::size_t Mantid::Nexus::SharedID< D >::use_count ( ) const
inline

Returns the number of SharedID objects holding the same ID.

Definition at line 200 of file UniqueID.h.

References Mantid::Nexus::SharedID< D >::m_leash_counts.

Member Data Documentation

◆ m_leash_counts

template<herr_t(*)(hid_t) D>
std::atomic<std::size_t>* Mantid::Nexus::SharedID< D >::m_leash_counts
private

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