HDF5 C++ API  1.8.18
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5Location.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 files COPYING and Copyright.html. COPYING can be found at the root *
10  * of the source code distribution tree; Copyright.html can be found at the *
11  * root level of an installed copy of the electronic HDF5 document set and *
12  * is linked from the top-level documents page. It can also be found at *
13  * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
14  * access to either file, you may request a copy from help@hdfgroup.org. *
15  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 
17 #ifndef __H5Location_H
18 #define __H5Location_H
19 
20 #include "H5Classes.h" // constains forward class declarations
21 
22 namespace H5 {
23 
24 class H5_DLLCPP H5Location; // forward declaration for UserData4Aiterate
25 
26 // Define the operator function pointer for H5Aiterate().
27 typedef void (*attr_operator_t)( H5Location& loc/*in*/,
28  const H5std_string attr_name/*in*/,
29  void *operator_data/*in,out*/);
30 
31 class UserData4Aiterate { // user data for attribute iteration
32  public:
34  void* opData;
36 };
37 
45 // Most of these methods were in H5Object but are now moved here because
46 // a location can be a file, group, dataset, or named datatype. -BMR, 2013-10-1
47 class H5_DLLCPP H5Location : public IdComponent {
48  public:
49  // Creates an attribute for the specified object at this location
50  // PropList is currently not used, so always be default.
51  Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
52  Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
53 
54  // Given its name, opens the attribute that belongs to an object at
55  // this location.
56  Attribute openAttribute( const char* name ) const;
57  Attribute openAttribute( const H5std_string& name ) const;
58 
59  // Given its index, opens the attribute that belongs to an object at
60  // this location.
61  Attribute openAttribute( const unsigned int idx ) const;
62 
63  // Flushes all buffers associated with this location to disk.
64  void flush( H5F_scope_t scope ) const;
65 
66  // Gets the name of the file, specified by this location.
67  H5std_string getFileName() const;
68 
69  // Determines the number of attributes at this location.
70  int getNumAttrs() const;
71 
72 #ifndef H5_NO_DEPRECATED_SYMBOLS
73  // Retrieves the type of object that an object reference points to.
74  H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
75 #endif /* H5_NO_DEPRECATED_SYMBOLS */
76 
77  // Retrieves the type of object that an object reference points to.
78  H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
79  // Note: getRefObjType deprecates getObjType, but getObjType's name is
80  // misleading, so getRefObjType is used in the new function instead.
81 
82  // Iterate user's function over the attributes at this location.
83  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
84 
85  // Checks whether the named attribute exists at this location.
86  bool attrExists(const char* name) const;
87  bool attrExists(const H5std_string& name) const;
88 
89  // Renames the named attribute to a new name.
90  void renameAttr(const char* oldname, const char* newname) const;
91  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
92 
93  // Removes the named attribute from this location.
94  void removeAttr(const char* name) const;
95  void removeAttr(const H5std_string& name) const;
96 
97  // Sets the comment for an HDF5 object specified by its name.
98  void setComment(const char* name, const char* comment) const;
99  void setComment(const H5std_string& name, const H5std_string& comment) const;
100  void setComment(const char* comment) const;
101  void setComment(const H5std_string& comment) const;
102 
103  // Retrieves comment for the HDF5 object specified by its name.
104  ssize_t getComment(const char* name, size_t buf_size, char* comment) const;
105  H5std_string getComment(const char* name, size_t buf_size=0) const;
106  H5std_string getComment(const H5std_string& name, size_t buf_size=0) const;
107 
108  // Removes the comment for the HDF5 object specified by its name.
109  void removeComment(const char* name) const;
110  void removeComment(const H5std_string& name) const;
111 
112  // Creates a reference to a named object or to a dataset region
113  // in this object.
114  void reference(void* ref, const char* name,
115  H5R_type_t ref_type = H5R_OBJECT) const;
116  void reference(void* ref, const H5std_string& name,
117  H5R_type_t ref_type = H5R_OBJECT) const;
118  void reference(void* ref, const char* name, const DataSpace& dataspace,
119  H5R_type_t ref_type = H5R_DATASET_REGION) const;
120  void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
121  H5R_type_t ref_type = H5R_DATASET_REGION) const;
122 
123  // Open a referenced object whose location is specified by either
124  // a file, an HDF5 object, or an attribute.
125  void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
126  void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
127 
128  // Retrieves a dataspace with the region pointed to selected.
129  DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
130 
132  virtual hid_t getId() const = 0;
133 
134  protected:
135 #ifndef DOXYGEN_SHOULD_SKIP_THIS
136  // Default constructor,
137  H5Location();
138 
139  // *** Deprecation warning ***
140  // The following two constructors are no longer appropriate after the
141  // data member "id" had been moved to the sub-classes.
142  // The copy constructor is a noop and is removed in 1.8.15 and the
143  // other will be removed from 1.10 release, and then from 1.8 if its
144  // removal does not raise any problems in two 1.10 releases.
145 
146  // Creates a copy of an existing object giving the location id.
147  H5Location(const hid_t loc_id);
148 
149  // Creates a reference to an HDF5 object or a dataset region.
150  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
151 
152  // Dereferences a ref into an HDF5 id.
153  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const char* from_func);
154 
155 #ifndef H5_NO_DEPRECATED_SYMBOLS
156  // Retrieves the type of object that an object reference points to.
157  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
158 #endif /* H5_NO_DEPRECATED_SYMBOLS */
159 
160  // Retrieves the type of object that an object reference points to.
161  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
162 
163  // Sets the identifier of this object to a new value. - this one
164  // doesn't increment reference count
165  virtual void p_setId(const hid_t new_id) = 0;
166 
167 #endif // DOXYGEN_SHOULD_SKIP_THIS
168 
169  // Noop destructor.
170  virtual ~H5Location();
171 
172 }; /* end class H5Location */
173 
174 }
175 #endif // __H5Location_H
Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.
Definition: H5IdComponent.h:32
Class DataSpace operates on HDF5 dataspaces.
Definition: H5DataSpace.h:23
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:30
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:32
class H5_DLLCPP H5Location
Definition: H5Location.h:24
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:47
void * opData
Definition: H5Location.h:34
void(* attr_operator_t)(H5Location &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Location.h:27
H5Location * location
Definition: H5Location.h:35
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:23
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:26
Definition: H5Location.h:31
attr_operator_t op
Definition: H5Location.h:33


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