My Project  1.10.11
H5DataSet.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 H5DataSet_H
15 #define H5DataSet_H
16 
17 namespace H5 {
18 
26 // Inheritance: multiple H5Object/AbstractDs -> H5Location -> IdComponent
27 class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
28  public:
29  // Close this dataset.
30  virtual void close();
31 
32  // Extends the dataset with unlimited dimension.
33  void extend(const hsize_t *size) const;
34 
35  // Fills a selection in memory with a value
36  void fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type,
37  const DataSpace &space) const;
38  // void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace&
39  // 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  // Gets the access property list of this dataset.
49  DSetAccPropList getAccessPlist() const;
50 
51  // Returns the address of this dataset in the file.
52  haddr_t getOffset() const;
53 
54  // Gets the dataspace of this dataset.
55  virtual DataSpace getSpace() const;
56 
57  // Determines whether space has been allocated for a dataset.
58  void getSpaceStatus(H5D_space_status_t &status) const;
59 
60  // Returns the amount of storage size required for this dataset.
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  // Returns the number of bytes required to store VL data.
67  hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const;
68  // hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1
69 
70  // Reclaims VL datatype memory buffers.
71  static void vlenReclaim(const DataType &type, const DataSpace &space,
72  const DSetMemXferPropList &xfer_plist, void *buf);
73  static void vlenReclaim(void *buf, const DataType &type, const DataSpace &space = DataSpace::ALL,
75 
76  // Reads the data of this dataset and stores it in the provided buffer.
77  // The memory and file dataspaces and the transferring property list
78  // can be defaults.
79  void read(void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL,
80  const DataSpace &file_space = DataSpace::ALL,
81  const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const;
82  void read(H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL,
83  const DataSpace &file_space = DataSpace::ALL,
84  const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const;
85 
86  // Writes the buffered data to this dataset.
87  // The memory and file dataspaces and the transferring property list
88  // can be defaults.
89  void write(const void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL,
90  const DataSpace &file_space = DataSpace::ALL,
91  const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const;
92  void write(const H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL,
93  const DataSpace &file_space = DataSpace::ALL,
94  const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const;
95 
96  // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
97  int iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op,
98  void *op_data = NULL);
99 
101  virtual H5std_string
102  fromClass() const
103  {
104  return ("DataSet");
105  }
106 
107  // Creates a dataset by way of dereference.
108  DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
109  const PropList &plist = PropList::DEFAULT);
110  DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
111  const PropList &plist = PropList::DEFAULT);
112 
113  // Default constructor.
114  DataSet();
115 
116  // Copy constructor - same as the original DataSet.
117  DataSet(const DataSet &original);
118 
119  // Assignment operator
120  DataSet &operator=(const DataSet &original);
121 
122  // Creates a copy of an existing DataSet using its id.
123  DataSet(const hid_t existing_id);
124 
125  // Gets the dataset id.
126  virtual hid_t getId() const;
127 
128  // Destructor: properly terminates access to this dataset.
129  virtual ~DataSet();
130 
131  protected:
132 #ifndef DOXYGEN_SHOULD_SKIP_THIS
133  // Sets the dataset id.
134  virtual void p_setId(const hid_t new_id);
135 #endif // DOXYGEN_SHOULD_SKIP_THIS
136 
137  private:
138  hid_t id; // HDF5 dataset id
139 
140  // This function contains the common code that is used by
141  // getTypeClass and various API functions getXxxType
142  // defined in AbstractDs for generic datatype and specific
143  // sub-types
144  virtual hid_t p_get_type() const;
145 
146  // Reads variable or fixed len strings from this dataset.
147  void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id,
148  const hid_t xfer_plist_id, H5std_string &strg) const;
149  void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id,
150  const hid_t xfer_plist_id, H5std_string &strg) const;
151 
152  // Friend function to set DataSet id. For library use only.
153  friend void f_DataSet_setId(DataSet *dset, hid_t new_id);
154 
155 }; // end of DataSet
156 } // namespace H5
157 
158 #endif // H5DataSet_H
H5::DataSet::getSpaceStatus
void getSpaceStatus(H5D_space_status_t &status) const
Determines whether space has been allocated for a dataset.
Definition: H5DataSet.cpp:299
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::DataSet::vlenReclaim
static void vlenReclaim(const DataType &type, const DataSpace &space, const DSetMemXferPropList &xfer_plist, void *buf)
Reclaims VL datatype memory buffers.
Definition: H5DataSet.cpp:359
H5::DataSet::f_DataSet_setId
friend void f_DataSet_setId(DataSet *dset, hid_t new_id)
H5::DSetCreatPropList
Class DSetCreatPropList inherits from ObjCreatPropList and provides wrappers for the HDF5 dataset cre...
Definition: H5DcreatProp.h:28
H5::DataSet::write
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
Writes raw data from an application buffer to a dataset.
Definition: H5DataSet.cpp:491
H5::DataSet::DataSet
DataSet()
Default constructor: creates a stub DataSet.
Definition: H5DataSet.cpp:45
H5::IdComponent::incRefCount
void incRefCount() const
Increment reference counter for the id of this object.
Definition: H5IdComponent.cpp:54
H5::DataSet::read
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
Reads raw data from the specified dataset.
Definition: H5DataSet.cpp:416
H5::DataSet::getInMemDataSize
virtual size_t getInMemDataSize() const
Gets the size in memory of the dataset's data.
Definition: H5DataSet.cpp:224
H5::DataSet
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:27
H5::DataSpace
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:24
H5::DataSet::getCreatePlist
DSetCreatPropList getCreatePlist() const
Gets the dataset creation property list.
Definition: H5DataSet.cpp:168
H5::DataSpace::getId
virtual hid_t getId() const H5_OVERRIDE
Get the id of this dataspace.
Definition: H5DataSpace.cpp:620
H5::DataSet::getStorageSize
virtual hsize_t getStorageSize() const
Returns the amount of storage required for a dataset.
Definition: H5DataSet.cpp:211
H5::DataSet::~DataSet
virtual ~DataSet()
Properly terminates access to this dataset.
Definition: H5DataSet.cpp:835
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::DataSet::extend
void extend(const hsize_t *size) const
Extends a dataset with unlimited dimension.
Definition: H5DataSet.cpp:592
H5::DataSet::fromClass
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataSet.h:102
H5::DataSet::getOffset
haddr_t getOffset() const
Returns the address of this dataset in the file.
Definition: H5DataSet.cpp:281
H5::DataSet::getId
virtual hid_t getId() const
Get the id of this dataset.
Definition: H5DataSet.cpp:693
H5::Exception::getDetailMsg
H5std_string getDetailMsg() const
Returns the detailed message set at the time the exception is thrown.
Definition: H5Exception.cpp:264
H5::DSetMemXferPropList
Class DSetCreatPropList inherits from PropList and provides wrappers for the HDF5 dataset memory and ...
Definition: H5DxferProp.h:24
H5::AbstractDs
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:35
H5::DataSet::operator=
DataSet & operator=(const DataSet &original)
Assignment operator: same HDF5 object as original.
Definition: H5DataSet.cpp:81
H5::PropList::DEFAULT
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27
H5::DSetMemXferPropList::DEFAULT
static const DSetMemXferPropList & DEFAULT
Default dataset memory and transfer property list.
Definition: H5DxferProp.h:27
H5::f_DataSpace_setId
void f_DataSpace_setId(DataSpace *dspace, hid_t new_id)
Definition: H5Location.cpp:2302
H5::DataSet::iterateElems
int iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, void *op_data=NULL)
Iterates over all selected elements in a dataspace.
Definition: H5DataSet.cpp:567
H5::PropList::getId
virtual hid_t getId() const
Get the id of this property list.
Definition: H5PropList.cpp:292
H5::H5Object
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:64
H5::DataSpace::ALL
static const DataSpace & ALL
Default DataSpace objects.
Definition: H5DataSpace.h:27
H5::IdComponent::setId
void setId(const hid_t new_id)
Sets the identifier of this object to a new value.
Definition: H5IdComponent.cpp:315
H5
Definition: H5AbstractDs.cpp:33
H5::DSetAccPropList
Class DSetAccPropList inherits from LinkAccPropList and provides wrappers for the HDF5 dataset access...
Definition: H5DaccProp.h:24
H5::DataSet::getSpace
virtual DataSpace getSpace() const
Gets a copy of the dataspace of this dataset.
Definition: H5DataSet.cpp:132
H5::DataType
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:27
H5::DataSet::getAccessPlist
DSetAccPropList getAccessPlist() const
Gets the dataset access property list.
Definition: H5DataSet.cpp:189
H5::H5Location
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:30
H5::DataSet::fillMemBuf
void fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, const DataSpace &space) const
Fills a selection in memory with a value.
Definition: H5DataSet.cpp:610
H5::DataSet::close
virtual void close()
Closes this dataset.
Definition: H5DataSet.cpp:814
H5::PropList
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list.
Definition: H5PropList.h:24
H5::DataSet::getVlenBufSize
hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const
Returns the number of bytes required to store VL data.
Definition: H5DataSet.cpp:316
H5::DataSetIException
Definition: H5Exception.h:130


The HDF Group Help Desk:
  Copyright by The HDF Group