HDF5 C++ API  1.10.1
 All Classes Namespaces Functions Variables Typedefs Friends Pages
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 
24 /*
25  Modification:
26  Sept 18, 2012: Added class H5Location in between IdComponent and
27  H5Object. An H5File now inherits from H5Location. All HDF5
28  wrappers in H5Object are moved up to H5Location. H5Object
29  is left mostly empty for future wrappers that are only for
30  group, dataset, and named datatype. Note that the reason for
31  adding H5Location instead of simply moving H5File to be under
32  H5Object is H5File is not an HDF5 object, and renaming H5Object
33  to H5Location will risk breaking user applications.
34  -BMR
35  Apr 2, 2014: Added wrapper getObjName for H5Iget_name
36  Sep 21, 2016: Rearranging classes (HDFFV-9920) moved H5A wrappers back
37  into H5Object. This way, C functions that takes attribute id
38  can be in H5Location and those that cannot take attribute id
39  can be in H5Object.
40 */
41 // Class forwarding
42 class H5Object;
43 class Attribute;
44 
45 // Define the operator function pointer for H5Aiterate().
46 typedef void (*attr_operator_t)(H5Object& loc/*in*/,
47  const H5std_string attr_name/*in*/,
48  void *operator_data/*in,out*/);
49 
50 // User data for attribute iteration
52  public:
54  void* opData;
56 };
57 
58 // Inheritance: H5Location -> IdComponent
59 class H5_DLLCPP H5Object : public H5Location {
60  public:
61  // Creates an attribute for the specified object
62  // PropList is currently not used, so always be default.
63  Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
64  Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
65 
66  // Given its name, opens the attribute that belongs to an object at
67  // this location.
68  Attribute openAttribute(const char* name) const;
69  Attribute openAttribute(const H5std_string& name) const;
70 
71  // Given its index, opens the attribute that belongs to an object at
72  // this location.
73  Attribute openAttribute(const unsigned int idx) const;
74 
75  // Iterate user's function over the attributes of this object.
76  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
77 
78  // Returns the object header version of an object
79  unsigned objVersion() const;
80 
81  // Checks whether the named attribute exists for this object.
82  bool attrExists(const char* name) const;
83  bool attrExists(const H5std_string& name) const;
84 
85  // Renames the named attribute to a new name.
86  void renameAttr(const char* oldname, const char* newname) const;
87  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
88 
89  // Removes the named attribute from this object.
90  void removeAttr(const char* name) const;
91  void removeAttr(const H5std_string& name) const;
92 
93  // Returns an identifier.
94  virtual hid_t getId() const = 0;
95 
96 #ifndef DOXYGEN_SHOULD_SKIP_THIS
97  // Gets the name of this HDF5 object, i.e., Group, DataSet, or
98  // DataType. These should have const but are retiring anyway.
99  ssize_t getObjName(char *obj_name, size_t buf_size = 0) const;
100  ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const;
101  H5std_string getObjName() const;
102 
103  protected:
104  // Default constructor
105  H5Object();
106 
107  // *** Deprecation warning ***
108  // The following two constructors are no longer appropriate after the
109  // data member "id" had been moved to the sub-classes.
110  // The copy constructor is a noop and is removed in 1.8.15 and the
111  // other will be removed from 1.10 release, and then from 1.8 if its
112  // removal does not raise any problems in two 1.10 releases.
113 
114  // Creates a copy of an existing object giving the object id
115  H5Object(const hid_t object_id);
116 
117  // Copy constructor: makes copy of an H5Object object.
118  // H5Object(const H5Object& original);
119 
120  // Sets the identifier of this object to a new value. - this one
121  // doesn't increment reference count
122  virtual void p_setId(const hid_t new_id) = 0;
123 
124  // Noop destructor.
125  virtual ~H5Object();
126 
127 #endif // DOXYGEN_SHOULD_SKIP_THIS
128 
129 }; // end of H5Object
130 } // namespace H5
131 
132 #endif // __H5Object_H
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:24
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:59
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:36
void * opData
Definition: H5Object.h:54
void(* attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Object.h:46
class H5_DLLCPP H5Object
Definition: H5Attribute.cpp:42
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list...
Definition: H5PropList.h:24
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27
Definition: H5Object.h:51
attr_operator_t op
Definition: H5Object.h:53
H5Object * location
Definition: H5Object.h:55


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