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