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