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


The HDF Group Help Desk:
  Copyright by The HDF Group