My Project  1.10.11
H5Object.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://www.hdfgroup.org/licenses. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 #ifndef H5Object_H
15 #define H5Object_H
16 
17 namespace H5 {
18 
39 // Inheritance: H5Location -> IdComponent
40 
41 // Define the operator function pointer for H5Aiterate().
42 typedef void (*attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data);
43 
44 // Define the operator function pointer for H5Ovisit2().
45 typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info_t *oinfo,
46  void *operator_data);
47 
48 // User data for attribute iteration
50  public:
52  void *opData;
53  H5Object *location; // Consider changing to H5Location
54 };
55 
56 // User data for visit iteration
58  public:
60  void *opData;
62 };
63 
64 class H5_DLLCPP H5Object : public H5Location {
65  public:
66  // Creates an attribute for the specified object
67  // PropList is currently not used, so always be default.
68  Attribute createAttribute(const char *name, const DataType &type, const DataSpace &space,
69  const PropList &create_plist = PropList::DEFAULT) const;
70  Attribute createAttribute(const H5std_string &name, const DataType &type, const DataSpace &space,
71  const PropList &create_plist = PropList::DEFAULT) const;
72 
73  // Given its name, opens the attribute that belongs to an object at
74  // this location.
75  Attribute openAttribute(const char *name) const;
76  Attribute openAttribute(const H5std_string &name) const;
77 
78  // Given its index, opens the attribute that belongs to an object at
79  // this location.
80  Attribute openAttribute(const unsigned int idx) const;
81 
82  // Iterate user's function over the attributes of this object.
83  int iterateAttrs(attr_operator_t user_op, unsigned *idx = NULL, void *op_data = NULL);
84 
85  // Recursively visit elements reachable from this object.
86  void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data,
87  unsigned int fields);
88 
89  // Returns the object header version of an object
90  unsigned objVersion() const;
91 
92  // Determines the number of attributes belong to this object.
93  int getNumAttrs() const;
94 
95  // Checks whether the named attribute exists for this object.
96  bool attrExists(const char *name) const;
97  bool attrExists(const H5std_string &name) const;
98 
99  // Renames the named attribute to a new name.
100  void renameAttr(const char *oldname, const char *newname) const;
101  void renameAttr(const H5std_string &oldname, const H5std_string &newname) const;
102 
103  // Removes the named attribute from this object.
104  void removeAttr(const char *name) const;
105  void removeAttr(const H5std_string &name) const;
106 
107  // Returns an identifier.
108  virtual hid_t getId() const H5_OVERRIDE = 0;
109 
110  // Gets the name of this HDF5 object, i.e., Group, DataSet, or
111  // DataType.
112  ssize_t getObjName(char *obj_name, size_t buf_size = 0) const;
113  ssize_t getObjName(H5std_string &obj_name, size_t len = 0) const;
114  H5std_string getObjName() const;
115 
116 #ifndef DOXYGEN_SHOULD_SKIP_THIS
117 
118  protected:
119  // Default constructor
120  H5Object();
121 
122  // Sets the identifier of this object to a new value. - this one
123  // doesn't increment reference count
124  virtual void p_setId(const hid_t new_id) H5_OVERRIDE = 0;
125 
126  // Noop destructor.
127  virtual ~H5Object() H5_OVERRIDE;
128 
129 #endif // DOXYGEN_SHOULD_SKIP_THIS
130 
131 }; // end of H5Object
132 } // namespace H5
133 
134 #endif // H5Object_H
H5::UserData4Aiterate::opData
void * opData
Definition: H5Object.h:52
H5::Exception
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:27
H5::DataType::getId
virtual hid_t getId() const
Get the id of this datatype.
Definition: H5DataType.cpp:900
H5::UserData4Aiterate::op
attr_operator_t op
Definition: H5Object.h:51
H5::H5Object::renameAttr
void renameAttr(const char *oldname, const char *newname) const
Renames the named attribute from this object.
Definition: H5Object.cpp:430
H5::ObjHeaderIException
Definition: H5Exception.h:116
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:222
H5::UserData4Visit::obj
H5Object * obj
Definition: H5Object.h:61
H5::UserData4Visit::opData
void * opData
Definition: H5Object.h:60
H5::H5Object::openAttribute
Attribute openAttribute(const char *name) const
Opens an attribute given its name.
Definition: H5Object.cpp:157
H5::DataSpace
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:24
H5::attr_operator_t
void(* attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Object.h:42
H5::DataSpace::getId
virtual hid_t getId() const H5_OVERRIDE
Get the id of this dataspace.
Definition: H5DataSpace.cpp:620
H5::AttributeIException
Definition: H5Exception.h:137
H5::H5Object::visit
void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields)
Recursively visits all HDF5 objects accessible from this object.
Definition: H5Object.cpp:285
H5::H5Object::getObjName
H5std_string getObjName() const
Returns the name of this object as an H5std_string.
Definition: H5Object.cpp:481
H5::Attribute
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:28
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:116
H5::UserData4Visit
Definition: H5Object.h:57
H5::UserData4Aiterate
Definition: H5Object.h:49
H5::H5Object::objVersion
unsigned objVersion() const
Returns the header version of this HDF5 object.
Definition: H5Object.cpp:320
H5::H5Object::getNumAttrs
int getNumAttrs() const
Returns the number of attributes attached to this HDF5 object.
Definition: H5Object.cpp:348
H5::PropList::DEFAULT
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27
H5::H5Object::removeAttr
void removeAttr(const char *name) const
Removes the named attribute from this object.
Definition: H5Object.cpp:401
H5::UserData4Aiterate::location
H5Object * location
Definition: H5Object.h:53
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:64
H5::H5Object::getId
virtual hid_t getId() const H5_OVERRIDE=0
H5
Definition: H5AbstractDs.cpp:33
H5::H5Object::attrExists
bool attrExists(const char *name) const
Checks whether the named attribute exists at this location.
Definition: H5Object.cpp:366
H5::visit_operator_t
int(* visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info_t *oinfo, void *operator_data)
Definition: H5Object.h:45
H5::UserData4Visit::op
visit_operator_t op
Definition: H5Object.h:59
H5::DataType
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:27
H5::H5Location
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:30
H5::PropList
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list.
Definition: H5PropList.h:24


The HDF Group Help Desk:
  Copyright by The HDF Group