My Project  1.10.4
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 COPYING file, which can be found at the root of the source code *
10  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
11  * If you do not have access to either file, you may request a copy from *
12  * help@hdfgroup.org. *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #ifndef __H5Attribute_H
16 #define __H5Attribute_H
17 
18 namespace H5 {
19 
28 // Inheritance: multiple H5Location/AbstractDs -> IdComponent
29 class H5_DLLCPP Attribute : public AbstractDs, public H5Location {
30  public:
31 
32  // Copy constructor: same as the original Attribute.
33  Attribute(const Attribute& original);
34 
35  // Default constructor
36  Attribute();
37 
38  // Creates a copy of an existing attribute using the attribute id
39  Attribute(const hid_t attr_id);
40 
41  // Closes this attribute.
42  virtual void close();
43 
44  // Gets the name of this attribute.
45  ssize_t getName(char* attr_name, size_t buf_size = 0) const;
46  H5std_string getName(size_t len) const;
47  H5std_string getName() const;
48  ssize_t getName(H5std_string& attr_name, size_t len = 0) const;
49  // The overloaded function below is replaced by the one above and it
50  // is kept for backward compatibility purpose.
51  ssize_t getName(size_t buf_size, H5std_string& attr_name) const;
52 
53  // Gets a copy of the dataspace for this attribute.
54  virtual DataSpace getSpace() const;
55 
56  // Returns the amount of storage size required for this attribute.
57  virtual hsize_t getStorageSize() const;
58 
59  // Returns the in memory size of this attribute's data.
60  virtual size_t getInMemDataSize() const;
61 
62  // Reads data from this attribute.
63  void read(const DataType& mem_type, void *buf) const;
64  void read(const DataType& mem_type, H5std_string& strg) const;
65 
66  // Writes data to this attribute.
67  void write(const DataType& mem_type, const void *buf) const;
68  void write(const DataType& mem_type, const H5std_string& strg) const;
69 
71  virtual H5std_string fromClass () const { return("Attribute"); }
72 
73  // Gets the attribute id.
74  virtual hid_t getId() const;
75 
76  // Destructor: properly terminates access to this attribute.
77  virtual ~Attribute();
78 
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80  protected:
81  // Sets the attribute id.
82  virtual void p_setId(const hid_t new_id);
83 #endif // DOXYGEN_SHOULD_SKIP_THIS
84 
85  private:
86  hid_t id; // HDF5 attribute id
87 
88  // This function contains the common code that is used by
89  // getTypeClass and various API functions getXxxType
90  // defined in AbstractDs for generic datatype and specific
91  // sub-types
92  virtual hid_t p_get_type() const;
93 
94  // Reads variable or fixed len strings from this attribute.
95  void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const;
96  void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const;
97 
98  // Friend function to set Attribute id. For library use only.
99  friend void f_Attribute_setId(Attribute* attr, hid_t new_id);
100 
101 }; // end of Attribute
102 } // namespace H5
103 
104 #endif // __H5Attribute_H
H5::Attribute::getName
ssize_t getName(size_t buf_size, H5std_string &attr_name) const
H5::Exception
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:32
H5::DataType::getId
virtual hid_t getId() const
Get the id of this datatype.
Definition: H5DataType.cpp:898
H5::Attribute::read
void read(const DataType &mem_type, void *buf) const
Reads data from this attribute.
Definition: H5Attribute.cpp:141
H5::Attribute::fromClass
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5Attribute.h:71
H5::IdComponent::incRefCount
void incRefCount() const
Increment reference counter for the id of this object.
Definition: H5IdComponent.cpp:53
H5::Attribute::~Attribute
virtual ~Attribute()
Properly terminates access to this attribute.
Definition: H5Attribute.cpp:632
H5::DataSpace
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
H5::AttributeIException
Definition: H5Exception.h:144
H5::Attribute::getInMemDataSize
virtual size_t getInMemDataSize() const
Gets the size in memory of the attribute's data.
Definition: H5Attribute.cpp:197
H5::Attribute::getStorageSize
virtual hsize_t getStorageSize() const
Returns the amount of storage size required for this attribute.
Definition: H5Attribute.cpp:461
H5::Attribute
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
H5::Attribute::getId
virtual hid_t getId() const
Get the id of this attribute.
Definition: H5Attribute.cpp:483
H5::Attribute::getName
H5std_string getName() const
Returns the name of this attribute as an H5std_string.
Definition: H5Attribute.cpp:325
H5::Exception::getDetailMsg
H5std_string getDetailMsg() const
Returns the detailed message set at the time the exception is thrown.
Definition: H5Exception.cpp:256
H5::Attribute::write
void write(const DataType &mem_type, const void *buf) const
Writes data to this attribute.
Definition: H5Attribute.cpp:85
H5::Attribute::f_Attribute_setId
friend void f_Attribute_setId(Attribute *attr, hid_t new_id)
H5::AbstractDs
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:36
H5::Attribute::getSpace
virtual DataSpace getSpace() const
Gets a copy of the dataspace for this attribute.
Definition: H5Attribute.cpp:262
H5::H5Object
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:55
H5
Definition: H5AbstractDs.cpp:34
H5::Attribute::Attribute
Attribute()
Default constructor: Creates a stub attribute.
Definition: H5Attribute.cpp:51
H5::DataType
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
H5::Attribute::close
virtual void close()
Closes this attribute.
Definition: H5Attribute.cpp:608
H5::H5Location
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:31
H5::DataSetIException
Definition: H5Exception.h:137


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