TRIQS/h5 1.3.0
C++ interface to HDF5
Loading...
Searching...
No Matches
h5::object

#include <h5/object.hpp>

Detailed Description

A generic handle for HDF5 objects.

It simply stores the h5::hid_t of the corresponding HDF5 object.

More specific HDF5 objects, like h5::file or h5::group, inherit from this class. Since it lacks a virtual destructor, the derived classes should not be deleted through a pointer to this class. It is recommended to use the derived classes whenever possible.

HDF5's reference counting system is similar to Python's. This class handles the proper reference counting using a RAII pattern (hence exception safe). Depending on how the object is constructed, it either increases the reference count associated with the HDF5 object or steals it.

Definition at line 49 of file object.hpp.

Inheritance diagram for h5::object:
h5::file h5::group

Public Member Functions

 object (hid_t id=0)
 Construct a new h5::object for a given HDF5 ID by taking ownership, i.e. without increasing the reference count.
 
 object (object &&x) noexcept
 Move constructor steals the underlying HDF5 ID without increasing its reference count.
 
 object (object const &x)
 Copy constructor copies the underlying HDF5 ID and increases its reference count.
 
 ~object ()
 Destructor decreases the reference count and sets the object's ID to zero.
 
void close ()
 Release the HDF5 handle by decreasing the reference count and by setting the object's ID to zero.
 
int get_ref_count () const
 Get the current reference count.
 
bool is_valid () const
 Ensure that the wrapped HDF5 ID is valid (by calling H5Iis_valid).
 
 operator hid_t () const
 User-defined conversion to h5::hid_t.
 
objectoperator= (object &&x) noexcept
 Move assignment operator steals the underlying HDF5 ID without increasing its reference count.
 
objectoperator= (object const &x)
 Copy assignment operator copies the underlying HDF5 ID and increases its reference count.
 

Static Public Member Functions

static object from_borrowed (hid_t id)
 Create an h5::object for a given HDF5 ID and increase its reference count.
 

Constructor & Destructor Documentation

◆ object() [1/3]

h5::object::object ( hid_t id = 0)
inline

Construct a new h5::object for a given HDF5 ID by taking ownership, i.e. without increasing the reference count.

If no ID is given, it is set to zero (default).

Parameters
idHDF5 ID.

Definition at line 71 of file object.hpp.

◆ object() [2/3]

h5::object::object ( object const & x)

Copy constructor copies the underlying HDF5 ID and increases its reference count.

Parameters
xObject to copy.

Definition at line 100 of file object.cpp.

◆ object() [3/3]

h5::object::object ( object && x)
inlinenoexcept

Move constructor steals the underlying HDF5 ID without increasing its reference count.

Parameters
xObject to move.

Definition at line 83 of file object.hpp.

Member Function Documentation

◆ from_borrowed()

object h5::object::from_borrowed ( hid_t id)
staticnodiscard

Create an h5::object for a given HDF5 ID and increase its reference count.

Parameters
idHDF5 ID.
Returns
h5::object.

Definition at line 95 of file object.cpp.

◆ operator=() [1/2]

object & h5::object::operator= ( object && x)
noexcept

Move assignment operator steals the underlying HDF5 ID without increasing its reference count.

Parameters
xObject to move.

Definition at line 102 of file object.cpp.

◆ operator=() [2/2]

object & h5::object::operator= ( object const & x)
inline

Copy assignment operator copies the underlying HDF5 ID and increases its reference count.

Parameters
xObject to copy.

Definition at line 89 of file object.hpp.


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