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


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