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


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