HDF5 C++ API  1.10.0
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5Attribute.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 __H5Attribute_H
18 #define __H5Attribute_H
19 
20 #ifndef H5_NO_NAMESPACE
21 namespace H5 {
22 #endif
23 
32 class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
33  public:
34 
35  // Copy constructor: makes a copy of an existing Attribute object.
36  Attribute( const Attribute& original );
37 
38  // Default constructor
39  Attribute();
40 
41  // Creates a copy of an existing attribute using the attribute id
42  Attribute( const hid_t attr_id );
43 
44  // Closes this attribute.
45  virtual void close();
46 
47  // Gets the name of the file, in which this attribute belongs.
48  H5std_string getFileName() const;
49 
50  // Gets the name of this attribute.
51  ssize_t getName(char* attr_name, size_t buf_size = 0) const;
52  H5std_string getName(size_t len) const;
53  H5std_string getName() const;
54  ssize_t getName(H5std_string& attr_name, size_t len = 0) const;
55  // The overloaded function below is replaced by the one above and it
56  // is kept for backward compatibility purpose.
57  ssize_t getName( size_t buf_size, H5std_string& attr_name ) const;
58 
59  // Gets a copy of the dataspace for this attribute.
60  virtual DataSpace getSpace() const;
61 
62  // Returns the amount of storage size required for this attribute.
63  virtual hsize_t getStorageSize() const;
64 
65  // Returns the in memory size of this attribute's data.
66  virtual size_t getInMemDataSize() const;
67 
68  // Reads data from this attribute.
69  void read( const DataType& mem_type, void *buf ) const;
70  void read( const DataType& mem_type, H5std_string& strg ) const;
71 
72  // Writes data to this attribute.
73  void write(const DataType& mem_type, const void *buf ) const;
74  void write(const DataType& mem_type, const H5std_string& strg ) const;
75 
76  // Flushes all buffers associated with the file specified by this
77  // attribute to disk.
78  void flush( H5F_scope_t scope ) const;
79 
81  virtual H5std_string fromClass () const { return("Attribute"); }
82 
83  // Gets the attribute id.
84  virtual hid_t getId() const;
85 
86  // Destructor: properly terminates access to this attribute.
87  virtual ~Attribute();
88 
89 #ifndef DOXYGEN_SHOULD_SKIP_THIS
90  protected:
91  // Sets the attribute id.
92  virtual void p_setId(const hid_t new_id);
93 #endif // DOXYGEN_SHOULD_SKIP_THIS
94 
95  private:
96  hid_t id; // HDF5 attribute id
97 
98  // This function contains the common code that is used by
99  // getTypeClass and various API functions getXxxType
100  // defined in AbstractDs for generic datatype and specific
101  // sub-types
102  virtual hid_t p_get_type() const;
103 
104  // Reads variable or fixed len strings from this attribute.
105  void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const;
106  void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const;
107 
108  // do not inherit H5Object::iterateAttrs
109  int iterateAttrs() { return 0; }
110 
111  // do not inherit H5Object::renameAttr
112  void renameAttr() {}
113 
114  // Friend function to set Attribute id. For library use only.
115  friend void f_Attribute_setId(Attribute* attr, hid_t new_id);
116 
117 };
118 #ifndef H5_NO_NAMESPACE
119 }
120 #endif
121 #endif // __H5Attribute_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5Attribute.h:81
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
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:40


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