HDF5 C++ API  1.10.1
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5DataSet.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 __H5DataSet_H
16 #define __H5DataSet_H
17 
18 namespace H5 {
19 
27 // Inheritance: multiple H5Object/AbstractDs -> H5Location -> IdComponent
28 class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
29  public:
30 
31  // Close this dataset.
32  virtual void close();
33 
34  // Extends the dataset with unlimited dimension.
35  void extend(const hsize_t* size) const;
36 
37  // Fills a selection in memory with a value
38  void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const;
39  //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1
40 
41  // Fills a selection in memory with zero
42  void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const;
43  //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1
44 
45  // Gets the creation property list of this dataset.
46  DSetCreatPropList getCreatePlist() const;
47 
48  // Returns the address of this dataset in the file.
49  haddr_t getOffset() const;
50 
51  // Gets the dataspace of this dataset.
52  virtual DataSpace getSpace() const;
53 
54  // Determines whether space has been allocated for a dataset.
55  void getSpaceStatus(H5D_space_status_t& status) const;
56 
57  // Returns the amount of storage size required for this dataset.
58  virtual hsize_t getStorageSize() const;
59 
60  // Returns the in memory size of this attribute's data.
61  virtual size_t getInMemDataSize() const;
62 
63  // Returns the number of bytes required to store VL data.
64  hsize_t getVlenBufSize(const DataType& type, const DataSpace& space) const;
65  //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1
66 
67  // Reclaims VL datatype memory buffers.
68  static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf);
69  static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT);
70 
71  // Reads the data of this dataset and stores it in the provided buffer.
72  // The memory and file dataspaces and the transferring property list
73  // can be defaults.
74  void read(void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const;
75  void read(H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const;
76 
77  // Writes the buffered data to this dataset.
78  // The memory and file dataspaces and the transferring property list
79  // can be defaults.
80  void write(const void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const;
81  void write(const H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const;
82 
83  // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
84  int iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL);
85 
87  virtual H5std_string fromClass () const { return("DataSet"); }
88 
89  // Creates a dataset by way of dereference.
90  DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
91  DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
92 
93  // Default constructor.
94  DataSet();
95 
96  // Copy constructor.
97  DataSet(const DataSet& original);
98 
99  // Creates a copy of an existing DataSet using its id.
100  DataSet(const hid_t existing_id);
101 
102  // Gets the dataset id.
103  virtual hid_t getId() const;
104 
105  // Destructor: properly terminates access to this dataset.
106  virtual ~DataSet();
107 
108  protected:
109 #ifndef DOXYGEN_SHOULD_SKIP_THIS
110  // Sets the dataset id.
111  virtual void p_setId(const hid_t new_id);
112 #endif // DOXYGEN_SHOULD_SKIP_THIS
113 
114  private:
115  hid_t id; // HDF5 dataset id
116 
117  // This function contains the common code that is used by
118  // getTypeClass and various API functions getXxxType
119  // defined in AbstractDs for generic datatype and specific
120  // sub-types
121  virtual hid_t p_get_type() const;
122 
123  // Reads variable or fixed len strings from this dataset.
124  void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const;
125  void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const;
126 
127  // Friend function to set DataSet id. For library use only.
128  friend void f_DataSet_setId(DataSet* dset, hid_t new_id);
129 
130 }; // end of DataSet
131 } // namespace H5
132 
133 #endif // __H5DataSet_H
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:24
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
Class DSetCreatPropList inherits from ObjCreatPropList and provides wrappers for the HDF5 dataset cre...
Definition: H5DcreatProp.h:29
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:59
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:36
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataSet.h:87
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:36
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
Class DSetCreatPropList inherits from PropList and provides wrappers for the HDF5 dataset memory and ...
Definition: H5DxferProp.h:25
static const DSetMemXferPropList & DEFAULT
Default dataset memory and transfer property list.
Definition: H5DxferProp.h:28
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list...
Definition: H5PropList.h:24
static const DataSpace & ALL
Default DataSpace objects.
Definition: H5DataSpace.h:27
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27


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