H5CompType.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 CompType inherits from DataType and provides accesses to a compound
00018 // datatype.
00019 
00020 #ifndef _H5CompType_H
00021 #define _H5CompType_H
00022 
00023 #ifndef H5_NO_NAMESPACE
00024 namespace H5 {
00025 #endif
00026 
00027 class H5_DLLCPP CompType : public DataType {
00028    public:
00029         // Creates a new compound datatype, given the type's size
00030         CompType( size_t size ); // H5Tcreate
00031 
00032         // Gets the compound datatype of the specified dataset
00033         CompType( const DataSet& dataset );  // H5Dget_type
00034 
00035         // Returns the type class of the specified member of this compound
00036         // datatype.  It provides to the user a way of knowing what type
00037         // to create another datatype of the same class
00038         H5T_class_t getMemberClass( unsigned member_num ) const;
00039 
00040         // Returns the index of a member in this compound data type.
00041         int getMemberIndex(const char* name) const;
00042         int getMemberIndex(const H5std_string& name) const;
00043 
00044         // Returns the offset of a member of this compound datatype.
00045         size_t getMemberOffset( unsigned memb_no ) const;
00046 
00047         // Returns the name of a member of this compound datatype.
00048         H5std_string getMemberName( unsigned member_num ) const;
00049 
00050         // Returns the generic datatype of the specified member in
00051         // this compound datatype.
00052         DataType getMemberDataType( unsigned member_num ) const;
00053 
00054         // Returns the array datatype of the specified member in
00055         // this compound datatype.
00056         ArrayType getMemberArrayType( unsigned member_num ) const;
00057 
00058         // Returns the compound datatype of the specified member in
00059         // this compound datatype.
00060         CompType getMemberCompType( unsigned member_num ) const;
00061 
00062         // Returns the enumeration datatype of the specified member in
00063         // this compound datatype.
00064         EnumType getMemberEnumType( unsigned member_num ) const;
00065 
00066         // Returns the integer datatype of the specified member in
00067         // this compound datatype.
00068         IntType getMemberIntType( unsigned member_num ) const;
00069 
00070         // Returns the floating-point datatype of the specified member in
00071         // this compound datatype.
00072         FloatType getMemberFloatType( unsigned member_num ) const;
00073 
00074         // Returns the string datatype of the specified member in
00075         // this compound datatype.
00076         StrType getMemberStrType( unsigned member_num ) const;
00077 
00078         // Returns the variable length datatype of the specified member in
00079         // this compound datatype.
00080         VarLenType getMemberVarLenType( unsigned member_num ) const;
00081 
00082         // Returns the number of members in this compound datatype.
00083         int getNmembers() const;
00084 
00085         // Adds a new member to this compound datatype.
00086         void insertMember( const H5std_string& name, size_t offset, const DataType& new_member ) const;
00087 
00088         // Recursively removes padding from within this compound datatype.
00089         void pack() const;
00090 
00092         virtual H5std_string fromClass () const { return("CompType"); }
00093 
00094         // Default constructor
00095         CompType();
00096 
00097         // Creates a compound datatype using an existing id
00098         CompType( const hid_t existing_id );
00099 
00100         // Copy constructor - makes a copy of original object
00101         CompType( const CompType& original );
00102 
00103         // Noop destructor.
00104         virtual ~CompType();
00105 
00106    private:
00107         // Contains common code that is used by the member functions
00108         // getMemberXxxType
00109         hid_t p_get_member_type(unsigned member_num) const;
00110 };
00111 #ifndef H5_NO_NAMESPACE
00112 }
00113 #endif
00114 #endif