TRIQS/h5 1.3.0
C++ interface to HDF5
|
#include <h5/object.hpp>
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.
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. | |
object & | operator= (object &&x) noexcept |
Move assignment operator steals the underlying HDF5 ID without increasing its reference count. | |
object & | operator= (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. | |
|
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).
id | HDF5 ID. |
Definition at line 71 of file object.hpp.
h5::object::object | ( | object const & | x | ) |
Copy constructor copies the underlying HDF5 ID and increases its reference count.
x | Object to copy. |
Definition at line 100 of file object.cpp.
|
inlinenoexcept |
Move constructor steals the underlying HDF5 ID without increasing its reference count.
x | Object to move. |
Definition at line 83 of file object.hpp.
Create an h5::object for a given HDF5 ID and increase its reference count.
id | HDF5 ID. |
Definition at line 95 of file object.cpp.
Move assignment operator steals the underlying HDF5 ID without increasing its reference count.
x | Object to move. |
Definition at line 102 of file object.cpp.
Copy assignment operator copies the underlying HDF5 ID and increases its reference count.
x | Object to copy. |
Definition at line 89 of file object.hpp.