Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-07-28 The HDF5 Field Guide

Loading...
Searching...
No Matches
IdComponent Class Referenceabstract

`#include <c++/src/H5IdComponent.h>`

## Detailed Description

Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.

In most cases, the C library handles these operations and an application rarely needs them.

Inheritance diagram for IdComponent:

## Public Member Functions
virtual void | close ()=0
void | decRefCount () const
| Decrement reference counter for the id of this object.
void | decRefCount (const hid_t obj_id) const
| Decrement reference counter for a given id.
virtual std::string | fromClass () const
| Returns this class name.
int | getCounter () const
| Returns the reference counter for the id of this object.
int | getCounter (const hid_t obj_id) const
| Returns the reference counter for a given id.
H5I_type_t | getHDFObjType () const
| Returns the type of the object. It is an overloaded function of the above function.
virtual hid_t | getId () const =0
void | incRefCount () const
| Increment reference counter for the id of this object.
void | incRefCount (const hid_t obj_id) const
| Increment reference counter for a given id.
std::string | inMemFunc (const char *func_name) const
| Makes and returns string "<class-name>::<func_name>".
IdComponent & | operator= (const IdComponent &rhs)
| Assignment operator.
void | setId (const hid_t new_id)
| Sets the identifier of this object to a new value.
virtual | ~IdComponent ()=default

## Static Public Member Functions
static H5I_type_t | getHDFObjType (const hid_t obj_id)
| Given an id, returns the type of the object.
static hsize_t | getNumMembers (H5I_type_t type)
| Returns the number of members of the given type.
static bool | isValid (hid_t an_id)
| Checks if the given ID is valid.
static bool | typeExists (H5I_type_t type)
| Queries if a given type is currently registered with the library.

## Protected Member Functions
| IdComponent ()
| Default constructor.
std::string | p_get_file_name () const
virtual void | p_setId (const hid_t new_id)=0

## Static Protected Member Functions
static bool | p_valid_id (const hid_t obj_id)

## Static Protected Attributes
static bool | H5dontAtexit_called = false

## Constructor & Destructor Documentation

## ◆ ~IdComponent()

virtual ~IdComponent | ( |  | ) |
| virtual default

## ◆ IdComponent()

IdComponent | ( |  | ) |
| protected

Default constructor.

## Member Function Documentation

## ◆ close()

virtual void close | ( |  | ) |
| pure virtual

Implemented in Attribute, DataSet, DataSpace, DataType, Group, H5File, and PropList.

## ◆ decRefCount() [1/2]

void decRefCount | ( |  | ) | const

Decrement reference counter for the id of this object.

## ◆ decRefCount() [2/2]

void decRefCount | ( | const hid_t | obj_id | ) | const

Decrement reference counter for a given id.

## ◆ fromClass()

virtual std::string fromClass | ( |  | ) | const
| virtual

Returns this class name.

Reimplemented in ArrayType, AtomType, Attribute, CompType, DataSet, DataSpace, DataType, DSetAccPropList, DSetCreatPropList, DSetMemXferPropList, EnumType, FileAccPropList, FileCreatPropList, FloatType, Group, H5File, IntType, LinkAccPropList, LinkCreatPropList, ObjCreatPropList, PredType, PropList, StrType, and VarLenType.

## ◆ getCounter() [1/2]

int getCounter | ( |  | ) | const

Returns the reference counter for the id of this object.

Returns
  Reference count

## ◆ getCounter() [2/2]

int getCounter | ( | const hid_t | obj_id | ) | const

Returns the reference counter for a given id.

Returns
  Reference count

## ◆ getHDFObjType() [1/2]

H5I_type_t getHDFObjType | ( |  | ) | const

Returns the type of the object. It is an overloaded function of the above function.

Returns
  a valid HDF object type, which may be one of the following:
  - `H5I_FILE`
  - `H5I_GROUP`
  - `H5I_DATATYPE`
  - `H5I_DATASPACE`
  - `H5I_DATASET`
  - `H5I_ATTR`
  - or `H5I_BADID`, if no valid type can be determined or the input object id is invalid.

## ◆ getHDFObjType() [2/2]

H5I_type_t getHDFObjType | ( | const hid_t | obj_id | ) |
| static

Given an id, returns the type of the object.

Returns
  a valid HDF object type, which may be one of the following:
  - `H5I_FILE`
  - `H5I_GROUP`
  - `H5I_DATATYPE`
  - `H5I_DATASPACE`
  - `H5I_DATASET`
  - `H5I_ATTR`
  - or `H5I_BADID`, if no valid type can be determined or the input object id is invalid.

## ◆ getId()

virtual hid_t getId | ( |  | ) | const
| pure virtual

Implemented in Attribute, DataSet, DataSpace, DataType, Group, H5File, H5Object, and PropList.

## ◆ getNumMembers()

hsize_t getNumMembers | ( | H5I_type_t | type | ) |
| static

Returns the number of members of the given type.

Returns
  Number of members

Description
  If there is no member of the given type, getNumMembers will return 0. Valid types are:
  - `H5I_FILE` (= 1)
  - `H5I_GROUP`
  - `H5I_DATATYPE`
  - `H5I_DATASPACE`
  - `H5I_DATASET`
  - `H5I_ATTR`
  - `H5I_VFL`
  - `H5I_VOL`
  - `H5I_GENPROP_CLS`
  - `H5I_GENPROP_LST`
  - `H5I_ERROR_CLASS`
  - `H5I_ERROR_MSG`
  - `H5I_ERROR_STACK`

## ◆ incRefCount() [1/2]

void incRefCount | ( |  | ) | const

Increment reference counter for the id of this object.

## ◆ incRefCount() [2/2]

void incRefCount | ( | const hid_t | obj_id | ) | const

Increment reference counter for a given id.

## ◆ inMemFunc()

std::string inMemFunc | ( | const char * | func_name | ) | const

Makes and returns string "<class-name>::<func_name>".

Parameters

  func_name | - Name of the function where failure occurs Concatenates the class name of this object with the passed-in function name to create a string that indicates where the failure occurs. The class-name is provided by fromClass(). This string will be used by a base class when an exception is thrown.

## ◆ isValid()

bool isValid | ( | hid_t | an_id | ) |
| static

Checks if the given ID is valid.

Returns
  true if the given identifier is valid, and false, otherwise.

Description
  A valid ID is one that is in use and has an application reference count of at least 1.

## ◆ operator=()

IdComponent & operator= | ( | const IdComponent & | rhs | ) |

Assignment operator.

Parameters

  rhs | - IN: Reference to the existing object

Returns
  Reference to IdComponent instance

Exceptions

  H5::IdComponentException | when attempt to close the HDF5 object fails

## ◆ p_get_file_name()

std::string p_get_file_name | ( |  | ) | const
| protected

## ◆ p_setId()

virtual void p_setId | ( | const hid_t | new_id | ) |
| protected pure virtual

Implemented in Attribute, DataSet, DataSpace, DataType, Group, H5File, H5Object, and PropList.

## ◆ p_valid_id()

bool p_valid_id | ( | const hid_t | obj_id | ) |
| static protected

## ◆ setId()

void setId | ( | const hid_t | new_id | ) |

Sets the identifier of this object to a new value.

Parameters

  new_id | - IN: New identifier to be set to

Exceptions

  H5::IdComponentException | when the attempt to close the HDF5 object fails

## ◆ typeExists()

bool typeExists | ( | H5I_type_t | type | ) |
| static

Queries if a given type is currently registered with the library.

Returns
  true if the given type exists, and false, otherwise.

Description
  Valid types are:
  - `H5I_FILE` (= 1)
  - `H5I_GROUP`
  - `H5I_DATATYPE`
  - `H5I_DATASPACE`
  - `H5I_DATASET`
  - `H5I_ATTR`
  - `H5I_VFL`
  - `H5I_VOL`
  - `H5I_GENPROP_CLS`
  - `H5I_GENPROP_LST`
  - `H5I_ERROR_CLASS`
  - `H5I_ERROR_MSG`
  - `H5I_ERROR_STACK`

## Field Documentation

## ◆ H5dontAtexit_called

bool H5dontAtexit_called = false
| static protected

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

- c++/src/H5IdComponent.h
- c++/src/H5IdComponent.cpp