CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cms::h5::Attribute Class Reference

#include <h5_Attribute.h>

Public Member Functions

 Attribute (hid_t, std::string const &)
 
 Attribute (const Attribute &)=delete
 
 Attribute (Attribute &&)=delete
 
Attributeoperator= (const Attribute &)=delete
 
Attributeoperator= (Attribute &&)=delete
 
std::string readString () const
 
uint32_t readUInt32 () const
 
 ~Attribute ()
 

Private Attributes

hid_t id_
 

Detailed Description

Definition at line 31 of file h5_Attribute.h.

Constructor & Destructor Documentation

◆ Attribute() [1/3]

Attribute::Attribute ( hid_t  iParentID,
std::string const &  iName 
)

Definition at line 31 of file h5_Attribute.cc.

References Exception, and id_.

32  : id_(H5Aopen(iParentID, iName.c_str(), H5P_DEFAULT)) {
33  if (id_ < 1) {
34  throw cms::Exception("UnknownH5Attribute") << "unknown attribute " << iName;
35  }
36  }

◆ ~Attribute()

Attribute::~Attribute ( )

Definition at line 43 of file h5_Attribute.cc.

References id_.

43 { H5Aclose(id_); }

◆ Attribute() [2/3]

cms::h5::Attribute::Attribute ( const Attribute )
delete

◆ Attribute() [3/3]

cms::h5::Attribute::Attribute ( Attribute &&  )
delete

Member Function Documentation

◆ operator=() [1/2]

Attribute& cms::h5::Attribute::operator= ( const Attribute )
delete

◆ operator=() [2/2]

Attribute& cms::h5::Attribute::operator= ( Attribute &&  )
delete

◆ readString()

std::string Attribute::readString ( ) const

Definition at line 64 of file h5_Attribute.cc.

References Exception, free(), id_, AlCaHLTBitMon_QueryRunRegistry::string, and funct::void.

64  {
65  // Prepare and call C API to read attribute.
66  char* strg_C;
67 
68  hid_t attr_type = H5Tcopy(H5T_C_S1);
69  (void)H5Tset_size(attr_type, H5T_VARIABLE);
70 
71  // Read attribute, no allocation for variable-len string; C library will
72  herr_t ret_value = H5Aread(id_, attr_type, &strg_C);
73  H5Tclose(attr_type);
74 
75  if (ret_value < 0) {
76  throw cms::Exception("H5AttributeReadStrinFailed") << " failed to read string from attribute";
77  }
78 
79  // Get string from the C char* and release resource allocated by C API
80  std::string strg = strg_C;
81  free(strg_C);
82 
83  return strg;
84  }
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
void free(void *ptr) noexcept

◆ readUInt32()

uint32_t Attribute::readUInt32 ( ) const

Definition at line 86 of file h5_Attribute.cc.

References Exception, id_, and runTheMatrix::ret.

86  {
87  unsigned int ret;
88  // Read attribute, no allocation for variable-len string; C library will
89  herr_t ret_value = H5Aread(id_, H5T_NATIVE_UINT, &ret);
90 
91  if (ret_value < 0) {
92  throw cms::Exception("H5AttributeReadStrinFailed") << " failed to read unsigned int from attribute";
93  }
94  return ret;
95  }
ret
prodAgent to be discontinued

Member Data Documentation

◆ id_

hid_t cms::h5::Attribute::id_
private

Definition at line 51 of file h5_Attribute.h.

Referenced by Attribute(), readString(), readUInt32(), and ~Attribute().