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
Definition: H5AbstractDs.cpp:34
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:55
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:31
void * opData
Definition: H5Object.h:51
class H5_DLLCPP H5Object
Definition: H5Attribute.cpp:44
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list...
Definition: H5PropList.h:25
void(* attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Object.h:43
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28
Definition: H5Object.h:48
attr_operator_t op
Definition: H5Object.h:50
H5Object * location
Definition: H5Object.h:52


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