HDF5 C++ API  1.10.0
 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 #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 
35  public:
37  void* opData;
39 };
40 
48 // Most of these methods were in H5Object but are now moved here because
49 // a location can be a file, group, dataset, or named datatype. -BMR, 2013-10-1
50 class H5_DLLCPP H5Location : public IdComponent {
51  public:
52  // Creates an attribute for the specified object at this location
53  // PropList is currently not used, so always be default.
54  Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
55  Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
56 
57  // Given its name, opens the attribute that belongs to an object at
58  // this location.
59  Attribute openAttribute( const char* name ) const;
60  Attribute openAttribute( const H5std_string& name ) const;
61 
62  // Given its index, opens the attribute that belongs to an object at
63  // this location.
64  Attribute openAttribute( const unsigned int idx ) const;
65 
66  // Flushes all buffers associated with this location to disk.
67  void flush( H5F_scope_t scope ) const;
68 
69  // Gets the name of the file, specified by this location.
70  H5std_string getFileName() const;
71 
72  // Determines the number of attributes at this location.
73  int getNumAttrs() const;
74 
75 #ifndef H5_NO_DEPRECATED_SYMBOLS
76  // Retrieves the type of object that an object reference points to.
77  H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
78 #endif /* H5_NO_DEPRECATED_SYMBOLS */
79 
80  // Retrieves the type of object that an object reference points to.
81  H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
82  // Note: getRefObjType deprecates getObjType, but getObjType's name is
83  // misleading, so getRefObjType is used in the new function instead.
84 
85  // Iterate user's function over the attributes at this location.
86  int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
87 
88  // Checks whether the named attribute exists at this location.
89  bool attrExists(const char* name) const;
90  bool attrExists(const H5std_string& name) const;
91 
92  // Renames the named attribute to a new name.
93  void renameAttr(const char* oldname, const char* newname) const;
94  void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
95 
96  // Removes the named attribute from this location.
97  void removeAttr(const char* name) const;
98  void removeAttr(const H5std_string& name) const;
99 
100  // Sets the comment for an HDF5 object specified by its name.
101  void setComment(const char* name, const char* comment) const;
102  void setComment(const H5std_string& name, const H5std_string& comment) const;
103  void setComment(const char* comment) const;
104  void setComment(const H5std_string& comment) const;
105 
106  // Retrieves comment for the HDF5 object specified by its name.
107  ssize_t getComment(const char* name, size_t buf_size, char* comment) const;
108  H5std_string getComment(const char* name, size_t buf_size=0) const;
109  H5std_string getComment(const H5std_string& name, size_t buf_size=0) const;
110 
111  // Removes the comment for the HDF5 object specified by its name.
112  void removeComment(const char* name) const;
113  void removeComment(const H5std_string& name) const;
114 
115  // Creates a reference to a named object or to a dataset region
116  // in this object.
117  void reference(void* ref, const char* name,
118  H5R_type_t ref_type = H5R_OBJECT) const;
119  void reference(void* ref, const H5std_string& name,
120  H5R_type_t ref_type = H5R_OBJECT) const;
121  void reference(void* ref, const char* name, const DataSpace& dataspace,
122  H5R_type_t ref_type = H5R_DATASET_REGION) const;
123  void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
124  H5R_type_t ref_type = H5R_DATASET_REGION) const;
125 
126  // Open a referenced object whose location is specified by either
127  // a file, an HDF5 object, or an attribute.
128  void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
129  void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
130 
131  // Retrieves a dataspace with the region pointed to selected.
132  DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
133 
135  virtual hid_t getId() const = 0;
136 
137  protected:
138  // Default constructor
139  H5Location();
140 
141 #ifndef DOXYGEN_SHOULD_SKIP_THIS
142 
143  // *** Deprecation warning ***
144  // The following two constructors are no longer appropriate after the
145  // data member "id" had been moved to the sub-classes.
146  // The copy constructor is a noop and is removed in 1.8.15 and the
147  // other will be removed from 1.10 release, and then from 1.8 if its
148  // removal does not raise any problems in two 1.10 releases.
149 
150  // Creates a copy of an existing object giving the location id.
151  H5Location(const hid_t loc_id);
152 
153  // Creates a reference to an HDF5 object or a dataset region.
154  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
155 
156  // Dereferences a ref into an HDF5 id.
157  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func);
158 
159 #ifndef H5_NO_DEPRECATED_SYMBOLS
160  // Retrieves the type of object that an object reference points to.
161  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
162 #endif /* H5_NO_DEPRECATED_SYMBOLS */
163 
164  // Retrieves the type of object that an object reference points to.
165  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
166 
167  // Sets the identifier of this object to a new value. - this one
168  // doesn't increment reference count
169  virtual void p_setId(const hid_t new_id) = 0;
170 
171 #endif // DOXYGEN_SHOULD_SKIP_THIS
172 
173  // Noop destructor.
174  virtual ~H5Location();
175 
176 }; /* end class H5Location */
177 
178 #ifndef H5_NO_NAMESPACE
179 }
180 #endif
181 #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:50
void * opData
Definition: H5Location.h:37
void(* attr_operator_t)(H5Location &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Location.h:29
H5Location * location
Definition: H5Location.h:38
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:25
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28
User data for attribute iteration.
Definition: H5Location.h:34
attr_operator_t op
Definition: H5Location.h:36


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