My Project  1.10.4
H5Object.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * Copyright by the Board of Trustees of the University of Illinois. *
5  * All rights reserved. *
6  * *
7  * This file is part of HDF5. The full HDF5 copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the root of the source code *
10  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
11  * If you do not have access to either file, you may request a copy from *
12  * help@hdfgroup.org. *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #ifndef __H5Object_H
16 #define __H5Object_H
17 
18 namespace H5 {
19 
40 // Inheritance: H5Location -> IdComponent
41 
42 // Define the operator function pointer for H5Aiterate().
43 typedef void (*attr_operator_t)(H5Object& loc/*in*/,
44  const H5std_string attr_name/*in*/,
45  void *operator_data/*in,out*/);
46 
47 // User data for attribute iteration
49  public:
51  void* opData;
53 };
54 
55 class H5_DLLCPP H5Object : public H5Location {
56  public:
57  // Creates an attribute for the specified object
58  // PropList is currently not used, so always be default.
59  Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
60  Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
61 
62  // Given its name, opens the attribute that belongs to an object at
63  // this location.
64  Attribute openAttribute(const char* name) const;
65  Attribute openAttribute(const H5std_string& name) const;
66 
67  // Given its index, opens the attribute that belongs to an object at
68  // this location.
69  Attribute openAttribute(const unsigned int idx) const;
70 
71  // Iterate user's function over the attributes of this object.
72  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
73 
74  // Returns the object header version of an object
75  unsigned objVersion() const;
76 
77  // Determines the number of attributes belong to this object.
78  int getNumAttrs() const;
79 
80  // Checks whether the named attribute exists for this object.
81  bool attrExists(const char* name) const;
82  bool attrExists(const H5std_string& name) const;
83 
84  // Renames the named attribute to a new name.
85  void renameAttr(const char* oldname, const char* newname) const;
86  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
87 
88  // Removes the named attribute from this object.
89  void removeAttr(const char* name) const;
90  void removeAttr(const H5std_string& name) const;
91 
92  // Returns an identifier.
93  virtual hid_t getId() const = 0;
94 
95  // Gets the name of this HDF5 object, i.e., Group, DataSet, or
96  // DataType.
97  ssize_t getObjName(char *obj_name, size_t buf_size = 0) const;
98  ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const;
99  H5std_string getObjName() const;
100 
101 #ifndef DOXYGEN_SHOULD_SKIP_THIS
102 
103  protected:
104  // Default constructor
105  H5Object();
106 
107  // Sets the identifier of this object to a new value. - this one
108  // doesn't increment reference count
109  virtual void p_setId(const hid_t new_id) = 0;
110 
111  // Noop destructor.
112  virtual ~H5Object();
113 
114 #endif // DOXYGEN_SHOULD_SKIP_THIS
115 
116 }; // end of H5Object
117 } // namespace H5
118 
119 #endif // __H5Object_H
H5::DataSpace::getId
virtual hid_t getId() const
Get the id of this dataspace.
Definition: H5DataSpace.cpp:625
H5::UserData4Aiterate::opData
void * opData
Definition: H5Object.h:51
H5::Exception
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:32
H5::DataType::getId
virtual hid_t getId() const
Get the id of this datatype.
Definition: H5DataType.cpp:898
H5::UserData4Aiterate::op
attr_operator_t op
Definition: H5Object.h:50
H5::H5Object::renameAttr
void renameAttr(const char *oldname, const char *newname) const
Renames the named attribute from this object.
Definition: H5Object.cpp:347
H5::ObjHeaderIException
Definition: H5Exception.h:123
H5::H5Object::iterateAttrs
int iterateAttrs(attr_operator_t user_op, unsigned *idx=NULL, void *op_data=NULL)
Iterates a user's function over all the attributes of an H5 object, which may be a group,...
Definition: H5Object.cpp:204
H5::H5Object::getId
virtual hid_t getId() const =0
H5::H5Object::openAttribute
Attribute openAttribute(const char *name) const
Opens an attribute given its name.
Definition: H5Object.cpp:136
H5::DataSpace
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
H5::attr_operator_t
void(* attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Object.h:43
H5::AttributeIException
Definition: H5Exception.h:144
H5::H5Object::getObjName
H5std_string getObjName() const
Returns the name of this object as an H5std_string.
Definition: H5Object.cpp:397
H5::Attribute
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
H5::H5Object::createAttribute
Attribute createAttribute(const char *name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
Creates an attribute for a group, dataset, or named datatype.
Definition: H5Object.cpp:98
H5::H5Object
class H5_DLLCPP H5Object
Definition: H5Attribute.cpp:44
H5::UserData4Aiterate
Definition: H5Object.h:48
H5::H5Object::objVersion
unsigned objVersion() const
Returns the header version of this HDF5 object.
Definition: H5Object.cpp:242
H5::H5Object::getNumAttrs
int getNumAttrs() const
Returns the number of attributes attached to this HDF5 object.
Definition: H5Object.cpp:270
H5::PropList::DEFAULT
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28
H5::H5Object::removeAttr
void removeAttr(const char *name) const
Removes the named attribute from this object.
Definition: H5Object.cpp:320
H5::UserData4Aiterate::location
H5Object * location
Definition: H5Object.h:52
H5::PropList::getId
virtual hid_t getId() const
Get the id of this property list.
Definition: H5PropList.cpp:292
H5::H5Object
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:55
H5
Definition: H5AbstractDs.cpp:34
H5::H5Object::attrExists
bool attrExists(const char *name) const
Checks whether the named attribute exists at this location.
Definition: H5Object.cpp:287
H5::DataType
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
H5::H5Location
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:31
H5::PropList
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list.
Definition: H5PropList.h:25


The HDF Group Help Desk:
  Copyright by The HDF Group
and the Board of Trustees of the University of Illinois