H5DataSet.h

00001 // C++ informative line for the emacs editor: -*- C++ -*-
00002 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00003  * Copyright by The HDF Group.                                               *
00004  * Copyright by the Board of Trustees of the University of Illinois.         *
00005  * All rights reserved.                                                      *
00006  *                                                                           *
00007  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00008  * terms governing use, modification, and redistribution, is contained in    *
00009  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00010  * of the source code distribution tree; Copyright.html can be found at the  *
00011  * root level of an installed copy of the electronic HDF5 document set and   *
00012  * is linked from the top-level documents page.  It can also be found at     *
00013  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00014  * access to either file, you may request a copy from help@hdfgroup.org.     *
00015  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00016 
00017 // Class DataSet inherits from AbstractDs and provides accesses to a dataset.
00018 
00019 #ifndef _H5DataSet_H
00020 #define _H5DataSet_H
00021 
00022 #ifndef H5_NO_NAMESPACE
00023 namespace H5 {
00024 #endif
00025 
00026 class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
00027    public:
00028         // Close this dataset.
00029         virtual void close();
00030 
00031         // Extends the dataset with unlimited dimension.
00032         void extend( const hsize_t* size ) const;
00033 
00034         // Fills a selection in memory with a value
00035         void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space);
00036         // Fills a selection in memory with zero
00037         void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space);
00038 
00039         // Gets the creation property list of this dataset.
00040         DSetCreatPropList getCreatePlist() const;
00041 
00042         // Returns the address of this dataset in the file.
00043         haddr_t getOffset() const;
00044 
00045         // Gets the dataspace of this dataset.
00046         virtual DataSpace getSpace() const;
00047 
00048         // Determines whether space has been allocated for a dataset.
00049         void getSpaceStatus(H5D_space_status_t& status) const;
00050 
00051         // Returns the amount of storage size required for this dataset.
00052         virtual hsize_t getStorageSize() const;
00053 
00054         // Returns the in memory size of this attribute's data.
00055         virtual size_t getInMemDataSize() const;
00056 
00057         // Returns the number of bytes required to store VL data.
00058         hsize_t getVlenBufSize( DataType& type, DataSpace& space ) const;
00059 
00060         // Reclaims VL datatype memory buffers.
00061         static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf );
00062         static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT);
00063 
00064         // Reads the data of this dataset and stores it in the provided buffer.
00065         // The memory and file dataspaces and the transferring property list
00066         // can be defaults.
00067         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;
00068         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;
00069 
00070         // Writes the buffered data to this dataset.
00071         // The memory and file dataspaces and the transferring property list
00072         // can be defaults.
00073         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;
00074         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;
00075 
00076         // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
00077         int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL );
00078 
00079 #ifndef H5_NO_DEPRECATED_SYMBOLS
00080         // Retrieves the type of object that an object reference points to.
00081         H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
00082 #endif /* H5_NO_DEPRECATED_SYMBOLS */
00083 
00084         // Retrieves a dataspace with the region pointed to selected.
00085         DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
00086 
00088         virtual H5std_string fromClass () const { return("DataSet"); }
00089 
00090         // Creates a dataset by way of dereference.
00091         DataSet(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00092         DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00093         DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00094 
00095         // Default constructor.
00096         DataSet();
00097 
00098         // Copy constructor.
00099         DataSet( const DataSet& original );
00100 
00101         // Creates a copy of an existing DataSet using its id.
00102         DataSet(const hid_t existing_id);
00103 
00104         // Gets the dataset id.
00105         virtual hid_t getId() const;
00106 
00107         // Destructor: properly terminates access to this dataset.
00108         virtual ~DataSet();
00109 
00110    private:
00111         hid_t id;       // HDF5 dataset id
00112 
00113 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00114         // This function contains the common code that is used by
00115         // getTypeClass and various API functions getXxxType
00116         // defined in AbstractDs for generic datatype and specific
00117         // sub-types
00118         virtual hid_t p_get_type() const;
00119 
00120         // Reads variable or fixed len strings from this dataset.
00121         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;
00122         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;
00123 
00124    protected:
00125         // Sets the dataset id.
00126         virtual void p_setId(const hid_t new_id);
00127 #endif // DOXYGEN_SHOULD_SKIP_THIS
00128 };
00129 #ifndef H5_NO_NAMESPACE
00130 }
00131 #endif
00132 #endif