My Project  1.10.6
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,
44  const H5std_string attr_name,
45  void *operator_data);
46 
47 // Define the operator function pointer for H5Ovisit2().
48 typedef int (*visit_operator_t)(H5Object& obj,
49  const H5std_string attr_name,
50  const H5O_info_t *oinfo,
51  void *operator_data);
52 
53 // User data for attribute iteration
55  public:
57  void* opData;
58  H5Object* location; // Consider changing to H5Location
59 };
60 
61 // User data for visit iteration
63  public:
65  void* opData;
67 };
68 
69 class H5_DLLCPP H5Object : public H5Location {
70  public:
71  // Creates an attribute for the specified object
72  // PropList is currently not used, so always be default.
73  Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
74  Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
75 
76  // Given its name, opens the attribute that belongs to an object at
77  // this location.
78  Attribute openAttribute(const char* name) const;
79  Attribute openAttribute(const H5std_string& name) const;
80 
81  // Given its index, opens the attribute that belongs to an object at
82  // this location.
83  Attribute openAttribute(const unsigned int idx) const;
84 
85  // Iterate user's function over the attributes of this object.
86  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
87 
88  // Recursively visit elements reachable from this object.
89  void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields);
90 
91  // Returns the object header version of an object
92  unsigned objVersion() const;
93 
94  // Determines the number of attributes belong to this object.
95  int getNumAttrs() const;
96 
97  // Checks whether the named attribute exists for this object.
98  bool attrExists(const char* name) const;
99  bool attrExists(const H5std_string& name) const;
100 
101  // Renames the named attribute to a new name.
102  void renameAttr(const char* oldname, const char* newname) const;
103  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
104 
105  // Removes the named attribute from this object.
106  void removeAttr(const char* name) const;
107  void removeAttr(const H5std_string& name) const;
108 
109  // Returns an identifier.
110  virtual hid_t getId() const = 0;
111 
112  // Gets the name of this HDF5 object, i.e., Group, DataSet, or
113  // DataType.
114  ssize_t getObjName(char *obj_name, size_t buf_size = 0) const;
115  ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const;
116  H5std_string getObjName() const;
117 
118 
119 #ifndef DOXYGEN_SHOULD_SKIP_THIS
120 
121  protected:
122  // Default constructor
123  H5Object();
124 
125  // Sets the identifier of this object to a new value. - this one
126  // doesn't increment reference count
127  virtual void p_setId(const hid_t new_id) = 0;
128 
129  // Noop destructor.
130  virtual ~H5Object();
131 
132 #endif // DOXYGEN_SHOULD_SKIP_THIS
133 
134 }; // end of H5Object
135 } // namespace H5
136 
137 #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:57
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:56
H5::H5Object::renameAttr
void renameAttr(const char *oldname, const char *newname) const
Renames the named attribute from this object.
Definition: H5Object.cpp:410
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:212
H5::UserData4Visit::obj
H5Object * obj
Definition: H5Object.h:66
H5::H5Object::getId
virtual hid_t getId() const =0
H5::UserData4Visit::opData
void * opData
Definition: H5Object.h:65
H5::H5Object::openAttribute
Attribute openAttribute(const char *name) const
Opens an attribute given its name.
Definition: H5Object.cpp:146
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::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:273
H5::H5Object::getObjName
H5std_string getObjName() const
Returns the name of this object as an H5std_string.
Definition: H5Object.cpp:460
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:108
H5::UserData4Visit
Definition: H5Object.h:62
H5::H5Object
class H5_DLLCPP H5Object
Definition: H5Attribute.cpp:44
H5::UserData4Aiterate
Definition: H5Object.h:54
H5::H5Object::objVersion
unsigned objVersion() const
Returns the header version of this HDF5 object.
Definition: H5Object.cpp:305
H5::H5Object::getNumAttrs
int getNumAttrs() const
Returns the number of attributes attached to this HDF5 object.
Definition: H5Object.cpp:333
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:383
H5::UserData4Aiterate::location
H5Object * location
Definition: H5Object.h:58
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:69
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:350
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:48
H5::UserData4Visit::op
visit_operator_t op
Definition: H5Object.h:64
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