HDF5 C++ API  1.10.0
 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 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 
34  // Close this dataset.
35  virtual void close();
36 
37  // Extends the dataset with unlimited dimension.
38  void extend( const hsize_t* size ) const;
39 
40  // Fills a selection in memory with a value
41  void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const;
42  void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // kept for backward compatibility
43 
44  // Fills a selection in memory with zero
45  void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const;
46  void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // kept for backward compatibility
47 
48  // Gets the creation property list of this dataset.
49  DSetCreatPropList getCreatePlist() 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; // kept for backward compatibility
69 
70  // Reclaims VL datatype memory buffers.
71  static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf );
72  static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT);
73 
74  // Reads the data of this dataset and stores it in the provided buffer.
75  // The memory and file dataspaces and the transferring property list
76  // can be defaults.
77  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;
78  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;
79 
80  // Writes the buffered data to this dataset.
81  // The memory and file dataspaces and the transferring property list
82  // can be defaults.
83  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;
84  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;
85 
86  // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
87  int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL );
88 
90  virtual H5std_string fromClass () const { return("DataSet"); }
91 
92  // Creates a dataset by way of dereference.
93  DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
94  DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
95 
96  // Default constructor.
97  DataSet();
98 
99  // Copy constructor.
100  DataSet( const DataSet& original );
101 
102  // Creates a copy of an existing DataSet using its id.
103  DataSet(const hid_t existing_id);
104 
105  // Gets the dataset id.
106  virtual hid_t getId() const;
107 
108  // Destructor: properly terminates access to this dataset.
109  virtual ~DataSet();
110 
111  protected:
112 #ifndef DOXYGEN_SHOULD_SKIP_THIS
113  // Sets the dataset id.
114  virtual void p_setId(const hid_t new_id);
115 #endif // DOXYGEN_SHOULD_SKIP_THIS
116 
117  private:
118  hid_t id; // HDF5 dataset id
119 
120  // This function contains the common code that is used by
121  // getTypeClass and various API functions getXxxType
122  // defined in AbstractDs for generic datatype and specific
123  // sub-types
124  virtual hid_t p_get_type() const;
125 
126  // Reads variable or fixed len strings from this dataset.
127  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;
128  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;
129 
130  // Friend function to set DataSet id. For library use only.
131  friend void f_DataSet_setId(DataSet* dset, hid_t new_id);
132 
133 };
134 #ifndef H5_NO_NAMESPACE
135 }
136 #endif
137 #endif // __H5DataSet_H
Class DataSpace operates on HDF5 dataspaces.
Definition: H5DataSpace.h:25
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:50
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataSet.h:90
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:40
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
Default dataset memory and transfer property list.
Definition: H5DxferProp.h:34
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:25
static const DataSpace & ALL
Default DataSpace objects.
Definition: H5DataSpace.h:28
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28


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