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