H5DataType.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 #ifndef _H5DataType_H
00018 #define _H5DataType_H
00019 
00020 #ifndef H5_NO_NAMESPACE
00021 namespace H5 {
00022 #endif
00023 
00024 class H5_DLLCPP DataType : public H5Object {
00025    public:
00026         // Creates a datatype given its class and size
00027         DataType( const H5T_class_t type_class, size_t size );
00028 
00029         // Copy constructor: makes a copy of the original object
00030         DataType( const DataType& original );
00031 
00032         // Creates a datatype by way of dereference.
00033         DataType(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00034         DataType(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00035         DataType(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
00036 
00037         // Closes this datatype.
00038         virtual void close();
00039 
00040         // Copies an existing datatype to this datatype object.
00041         void copy(const DataType& like_type);
00042 
00043         // Copies the datatype of dset to this datatype object.
00044         void copy(const DataSet& dset);
00045 
00046         // Returns the datatype class identifier.
00047         H5T_class_t getClass() const;
00048 
00049         // Commits a transient datatype to a file; this datatype becomes
00050         // a named datatype which can be accessed from the location.
00051         void commit( H5File& loc, const char* name);
00052         void commit( H5File& loc, const H5std_string& name);
00053         void commit( H5Object& loc, const char* name);
00054         void commit( H5Object& loc, const H5std_string& name);
00055 
00056         // Determines whether this datatype is a named datatype or
00057         // a transient datatype.
00058         bool committed() const;
00059 
00060         // Finds a conversion function that can handle the conversion
00061         // this datatype to the given datatype, dest.
00062         H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const;
00063 
00064         // Converts data from between specified datatypes.
00065         void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
00066 
00067         // Assignment operator
00068         DataType& operator=( const DataType& rhs );
00069 
00070         // Determines whether two datatypes are the same.
00071         bool operator==(const DataType& compared_type ) const;
00072 
00073         // Locks a datatype.
00074         void lock() const;
00075 
00076         // Returns the size of a datatype.
00077         size_t getSize() const;
00078 
00079         // Returns the base datatype from which a datatype is derived.
00080         // Note: not quite right for specific types yet???
00081         DataType getSuper() const;
00082 
00083         // Registers a conversion function.
00084         void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
00085         void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
00086 
00087         // Removes a conversion function from all conversion paths.
00088         void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
00089         void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
00090 
00091         // Tags an opaque datatype.
00092         void setTag( const char* tag ) const;
00093         void setTag( const H5std_string& tag ) const;
00094 
00095         // Gets the tag associated with an opaque datatype.
00096         H5std_string getTag() const;
00097 
00098         // Checks whether this datatype contains (or is) a certain type class.
00099         bool detectClass(H5T_class_t cls) const;
00100 
00101         // Checks whether this datatype is a variable-length string.
00102         bool isVariableStr() const;
00103 
00104 #ifndef H5_NO_DEPRECATED_SYMBOLS
00105         // Retrieves the type of object that an object reference points to.
00106         H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
00107 #endif /* H5_NO_DEPRECATED_SYMBOLS */
00108 
00109         // Retrieves a dataspace with the region pointed to selected.
00110         DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
00111 
00113         virtual H5std_string fromClass () const { return("DataType"); }
00114 
00115         // Creates a copy of an existing DataType using its id
00116         DataType( const hid_t type_id );
00117 
00118         // Default constructor
00119         DataType();
00120 
00121         // Gets the datatype id.
00122         virtual hid_t getId() const;
00123 
00124         // Destructor: properly terminates access to this datatype.
00125         virtual ~DataType();
00126 
00127    protected:
00128         hid_t id;       // HDF5 datatype id
00129 
00130         // Sets the datatype id.
00131         virtual void p_setId(const hid_t new_id);
00132 
00133    private:
00134         void p_commit(hid_t loc_id, const char* name);
00135 };
00136 #ifndef H5_NO_NAMESPACE
00137 }
00138 #endif
00139 #endif