HDF5 C++ API  1.8.13
 All Classes Namespaces Functions Variables Typedefs 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 #ifndef H5_NO_NAMESPACE
23 namespace H5 {
24 #endif
25 
26 class H5_DLLCPP H5Location; // forward declaration for UserData4Aiterate
27 
28 // Define the operator function pointer for H5Aiterate().
29 typedef void (*attr_operator_t)( H5Location& loc/*in*/,
30  const H5std_string attr_name/*in*/,
31  void *operator_data/*in,out*/);
32 
33 class UserData4Aiterate { // user data for attribute iteration
34  public:
36  void* opData;
38 };
39 
47 // Most of these methods were in H5Object but are now moved here because
48 // a location can be a file, group, dataset, or named datatype. -BMR, 2013-10-1
49 class H5_DLLCPP H5Location : public IdComponent {
50  public:
51  // Creates an attribute for the specified object at this location
52  // PropList is currently not used, so always be default.
53  Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
54  Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
55 
56  // Given its name, opens the attribute that belongs to an object at
57  // this location.
58  Attribute openAttribute( const char* name ) const;
59  Attribute openAttribute( const H5std_string& name ) const;
60 
61  // Given its index, opens the attribute that belongs to an object at
62  // this location.
63  Attribute openAttribute( const unsigned int idx ) const;
64 
65  // Flushes all buffers associated with this location to disk.
66  void flush( H5F_scope_t scope ) const;
67 
68  // Gets the name of the file, specified by this location.
69  H5std_string getFileName() const;
70 
71  // Determines the number of attributes at this location.
72  int getNumAttrs() const;
73 
74 #ifndef H5_NO_DEPRECATED_SYMBOLS
75  // Retrieves the type of object that an object reference points to.
76  H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
77 #endif /* H5_NO_DEPRECATED_SYMBOLS */
78 
79  // Retrieves the type of object that an object reference points to.
80  H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
81  // Note: getRefObjType deprecates getObjType, but getObjType's name is
82  // misleading, so getRefObjType is used in the new function instead.
83 
84  // Iterate user's function over the attributes at this location.
85  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
86 
87  // Checks whether the named attribute exists at this location.
88  bool attrExists(const char* name) const;
89  bool attrExists(const H5std_string& name) const;
90 
91  // Renames the named attribute to a new name.
92  void renameAttr(const char* oldname, const char* newname) const;
93  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
94 
95  // Removes the named attribute from this location.
96  void removeAttr(const char* name) const;
97  void removeAttr(const H5std_string& name) const;
98 
99  // Sets the comment for an HDF5 object specified by its name.
100  void setComment(const char* name, const char* comment) const;
101  void setComment(const H5std_string& name, const H5std_string& comment) const;
102  void setComment(const char* comment) const;
103  void setComment(const H5std_string& comment) const;
104 
105  // Retrieves comment for the HDF5 object specified by its name.
106  ssize_t getComment(const char* name, size_t buf_size, char* comment) const;
107  H5std_string getComment(const char* name, size_t buf_size=0) const;
108  H5std_string getComment(const H5std_string& name, size_t buf_size=0) const;
109 
110  // Removes the comment for the HDF5 object specified by its name.
111  void removeComment(const char* name) const;
112  void removeComment(const H5std_string& name) const;
113 
114  // Creates a reference to a named object or to a dataset region
115  // in this object.
116  void reference(void* ref, const char* name,
117  H5R_type_t ref_type = H5R_OBJECT) const;
118  void reference(void* ref, const H5std_string& name,
119  H5R_type_t ref_type = H5R_OBJECT) const;
120  void reference(void* ref, const char* name, const DataSpace& dataspace,
121  H5R_type_t ref_type = H5R_DATASET_REGION) const;
122  void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
123  H5R_type_t ref_type = H5R_DATASET_REGION) const;
124 
125  // Open a referenced object whose location is specified by either
126  // a file, an HDF5 object, or an attribute.
127  void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
128  void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
129 
130  // Retrieves a dataspace with the region pointed to selected.
131  DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
132 
134  virtual hid_t getId() const = 0;
135 
136  protected:
137 #ifndef DOXYGEN_SHOULD_SKIP_THIS
138  // Default constructor,
139  H5Location();
140 
141  // Creates a copy of an existing object giving the location id.
142  H5Location(const hid_t loc_id);
143 
144  // Copy constructor.
145  H5Location(const H5Location& original);
146 
147  // Creates a reference to an HDF5 object or a dataset region.
148  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
149 
150  // Dereferences a ref into an HDF5 id.
151  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const char* from_func);
152 
153 #ifndef H5_NO_DEPRECATED_SYMBOLS
154  // Retrieves the type of object that an object reference points to.
155  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
156 #endif /* H5_NO_DEPRECATED_SYMBOLS */
157 
158  // Retrieves the type of object that an object reference points to.
159  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
160 
161 #endif // DOXYGEN_SHOULD_SKIP_THIS
162 
163  // Noop destructor.
164  virtual ~H5Location();
165 
166 }; /* end class H5Location */
167 
168 #ifndef H5_NO_NAMESPACE
169 }
170 #endif
171 #endif // __H5Location_H
Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.
Definition: H5IdComponent.h:34
Class DataSpace operates on HDF5 dataspaces.
Definition: H5DataSpace.h:25
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:32
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:34
class H5_DLLCPP H5Location
Definition: H5Location.h:26
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:49
void * opData
Definition: H5Location.h:36
void(* attr_operator_t)(H5Location &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Location.h:29
H5Location * location
Definition: H5Location.h:37
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:25
static const PropList DEFAULT
Constant for default property.
Definition: H5PropList.h:28
Definition: H5Location.h:33
attr_operator_t op
Definition: H5Location.h:35