diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-07-24 03:36:41 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-07-24 03:36:41 (GMT) |
commit | fe594c5dd8b811f4c843c1816cd584603706c2b2 (patch) | |
tree | c050fa833121f5fac5c79576a892e222a3baab19 | |
parent | 89f283e2e47814419e7e6861bfa76f56e27124d2 (diff) | |
download | hdf5-fe594c5dd8b811f4c843c1816cd584603706c2b2.zip hdf5-fe594c5dd8b811f4c843c1816cd584603706c2b2.tar.gz hdf5-fe594c5dd8b811f4c843c1816cd584603706c2b2.tar.bz2 |
[svn-r11147] Purpose: Fix bugzilla #406
Description:
Added these missing member functions:
AbstractDs::getArrayType
AbstractDs::getVarLenType
CommonFG::openArrayType
CommonFG::openVarLenType
CompType::getMemberArrayType
CompType::getMemberVarLenType
Platforms tested:
Linux 2.4 (heping)
AIX 5.1 (copper)
SunOS 5.8 64-bit (sol)
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 52 | ||||
-rw-r--r-- | c++/src/H5AbstractDs.h | 13 | ||||
-rw-r--r-- | c++/src/H5ArrayType.h | 6 | ||||
-rw-r--r-- | c++/src/H5CommonFG.cpp | 76 | ||||
-rw-r--r-- | c++/src/H5CommonFG.h | 16 | ||||
-rw-r--r-- | c++/src/H5CompType.cpp | 52 | ||||
-rw-r--r-- | c++/src/H5CompType.h | 14 | ||||
-rw-r--r-- | c++/src/H5EnumType.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5VarLenType.h | 5 |
9 files changed, 187 insertions, 49 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 33fadc5..5c0fa6b 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -96,17 +96,17 @@ DataType AbstractDs::getDataType() const } //-------------------------------------------------------------------------- -// Function: AbstractDs::getEnumType -///\brief Returns the enumeration datatype of this abstract dataset which +// Function: AbstractDs::getArrayType +///\brief Returns the compound datatype of this abstract dataset which /// can be a dataset or an attribute. -///\return EnumType instance +///\return ArrayType instance ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType AbstractDs::getEnumType() const +ArrayType AbstractDs::getArrayType() const { - EnumType enumtype(p_get_type()); - return(enumtype); + ArrayType arraytype(p_get_type()); + return(arraytype); } //-------------------------------------------------------------------------- @@ -124,17 +124,17 @@ CompType AbstractDs::getCompType() const } //-------------------------------------------------------------------------- -// Function: AbstractDs::getIntType -///\brief Returns the integer datatype of this abstract dataset which +// Function: AbstractDs::getEnumType +///\brief Returns the enumeration datatype of this abstract dataset which /// can be a dataset or an attribute. -///\return IntType instance +///\return EnumType instance ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType AbstractDs::getIntType() const +EnumType AbstractDs::getEnumType() const { - IntType inttype(p_get_type()); - return(inttype); + EnumType enumtype(p_get_type()); + return(enumtype); } //-------------------------------------------------------------------------- @@ -152,6 +152,20 @@ FloatType AbstractDs::getFloatType() const } //-------------------------------------------------------------------------- +// Function: AbstractDs::getIntType +///\brief Returns the integer datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return IntType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +IntType AbstractDs::getIntType() const +{ + IntType inttype(p_get_type()); + return(inttype); +} + +//-------------------------------------------------------------------------- // Function: AbstractDs::getStrType ///\brief Returns the string datatype of this abstract dataset which /// can be a dataset or an attribute. @@ -166,6 +180,20 @@ StrType AbstractDs::getStrType() const } //-------------------------------------------------------------------------- +// Function: AbstractDs::getVarLenType +///\brief Returns the floating-point datatype of this abstract dataset, +/// which can be a dataset or an attribute. +///\return VarLenType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +VarLenType AbstractDs::getVarLenType() const +{ + VarLenType varlentype(p_get_type()); + return(varlentype); +} + +//-------------------------------------------------------------------------- // Function: AbstractDs destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 764993c..b1b422c 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -24,6 +24,13 @@ #ifndef H5_NO_NAMESPACE namespace H5 { #endif +class ArrayType; +class CompType; +class EnumType; +class FloatType; +class IntType; +class StrType; +class VarLenType; class H5_DLLCPP AbstractDs : public H5Object { public: // Gets a copy the datatype of that this abstract dataset uses. @@ -34,11 +41,13 @@ class H5_DLLCPP AbstractDs : public H5Object { DataType getDataType() const; // Gets a copy of the specific datatype of this abstract dataset - EnumType getEnumType() const; + ArrayType getArrayType() const; CompType getCompType() const; - IntType getIntType() const; + EnumType getEnumType() const; FloatType getFloatType() const; + IntType getIntType() const; StrType getStrType() const; + VarLenType getVarLenType() const; // Gets the dataspace of this abstract dataset - pure virtual virtual DataSpace getSpace() const = 0; diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index fb5eb2e..3f1ddc5 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -37,6 +37,9 @@ class H5_DLLCPP ArrayType : public DataType { // Copy constructor: makes copy of the original object. ArrayType( const ArrayType& original ); + // Constructor that takes an existing id + ArrayType( const hid_t existing_id ); + // Noop destructor virtual ~ArrayType(); @@ -44,9 +47,6 @@ class H5_DLLCPP ArrayType : public DataType { // Default constructor ArrayType(); - // Constructor that takes an existing id - ArrayType( const hid_t existing_id ); - private: int rank; // Rank of the array hsize_t* dimensions; // Sizes of the array dimensions diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 0b839ba..bd82795 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -639,30 +639,30 @@ DataType CommonFG::openDataType( const string& name ) const } //-------------------------------------------------------------------------- -// Function: CommonFG::openEnumType -///\brief Opens the named enumeration datatype at this location. -///\param name - IN: Name of the enumeration datatype to open -///\return EnumType instance +// Function: CommonFG::openArrayType +///\brief Opens the named array datatype at this location. +///\param name - IN: Name of the array datatype to open +///\return ArrayType instance ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType( const char* name ) const +ArrayType CommonFG::openArrayType( const char* name ) const { - EnumType enum_type(p_open_data_type(name)); - return(enum_type); -} + ArrayType array_type(p_open_data_type(name)); + return(array_type); +} //-------------------------------------------------------------------------- -// Function: CommonFG::openEnumType +// Function: CommonFG::openArrayType ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function in that it takes an /// \c std::string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType( const string& name ) const +ArrayType CommonFG::openArrayType( const string& name ) const { - return( openEnumType( name.c_str()) ); -} + return( openArrayType( name.c_str()) ); +} //-------------------------------------------------------------------------- // Function: CommonFG::openCompType @@ -691,6 +691,32 @@ CompType CommonFG::openCompType( const string& name ) const } //-------------------------------------------------------------------------- +// Function: CommonFG::openEnumType +///\brief Opens the named enumeration datatype at this location. +///\param name - IN: Name of the enumeration datatype to open +///\return EnumType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +EnumType CommonFG::openEnumType( const char* name ) const +{ + EnumType enum_type(p_open_data_type(name)); + return(enum_type); +} + +//-------------------------------------------------------------------------- +// Function: CommonFG::openEnumType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c std::string for \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +EnumType CommonFG::openEnumType( const string& name ) const +{ + return( openEnumType( name.c_str()) ); +} + +//-------------------------------------------------------------------------- // Function: CommonFG::openIntType ///\brief Opens the named integer datatype at this location. ///\param name - IN: Name of the integer datatype to open @@ -769,6 +795,32 @@ StrType CommonFG::openStrType( const string& name ) const } //-------------------------------------------------------------------------- +// Function: CommonFG::openVarLenType +///\brief Opens the named variable length datatype at this location. +///\param name - IN: Name of the variable length datatype to open +///\return VarLenType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +VarLenType CommonFG::openVarLenType( const char* name ) const +{ + VarLenType varlen_type(p_open_data_type(name)); + return(varlen_type); +} + +//-------------------------------------------------------------------------- +// Function: CommonFG::openVarLenType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c std::string for \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +VarLenType CommonFG::openVarLenType( const string& name ) const +{ + return( openVarLenType( name.c_str()) ); +} + +//-------------------------------------------------------------------------- // Function: CommonFG::iterateElems ///\brief Iterates a user's function over the entries of a group. ///\param name - IN : Name of group to iterate over diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 7541627..1ad18f2 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -26,6 +26,8 @@ namespace H5 { class Group; class H5File; +class ArrayType; +class VarLenType; class H5_DLLCPP CommonFG { public: // Creates a new group at this location which can be a file @@ -111,14 +113,18 @@ class H5_DLLCPP CommonFG { DataType openDataType(const char* name) const; DataType openDataType(const string& name) const; - // Opens a named enumeration datatype in this location. - EnumType openEnumType(const char* name) const; - EnumType openEnumType(const string& name) const; + // Opens a named array datatype in this location. + ArrayType openArrayType(const char* name) const; + ArrayType openArrayType(const string& name) const; // Opens a named compound datatype in this location. CompType openCompType(const char* name) const; CompType openCompType(const string& name) const; + // Opens a named enumeration datatype in this location. + EnumType openEnumType(const char* name) const; + EnumType openEnumType(const string& name) const; + // Opens a named integer datatype in this location. IntType openIntType(const char* name) const; IntType openIntType(const string& name) const; @@ -131,6 +137,10 @@ class H5_DLLCPP CommonFG { StrType openStrType(const char* name) const; StrType openStrType(const string& name) const; + // Opens a named variable length datatype in this location. + VarLenType openVarLenType(const char* name) const; + VarLenType openVarLenType(const string& name) const; + /// For subclasses, H5File and Group, to return the correct /// object id, i.e. file or group id. virtual hid_t getLocId() const = 0; diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 00421b9..2759479 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -245,22 +245,22 @@ DataType CompType::getMemberDataType( int member_num ) const } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType -///\brief Returns the enumeration datatype of the specified member in -/// this compound datatype. +// Function: CompType::getMemberArrayType +///\brief Returns the array datatype of the specified member in this +/// compound datatype. ///\param member_num - IN: Zero-based index of the member -///\return EnumType instance +///\return ArrayType instance ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CompType::getMemberEnumType( int member_num ) const +ArrayType CompType::getMemberArrayType( int member_num ) const { - EnumType enumtype(p_get_member_type(member_num)); - return(enumtype); + ArrayType arraytype(p_get_member_type(member_num)); + return(arraytype); } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType +// Function: CompType::getMemberCompType ///\brief Returns the compound datatype of the specified member in this /// compound datatype. ///\param member_num - IN: Zero-based index of the member @@ -275,7 +275,22 @@ CompType CompType::getMemberCompType( int member_num ) const } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType +// Function: CompType::getMemberEnumType +///\brief Returns the enumeration datatype of the specified member in +/// this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return EnumType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +EnumType CompType::getMemberEnumType( int member_num ) const +{ + EnumType enumtype(p_get_member_type(member_num)); + return(enumtype); +} + +//-------------------------------------------------------------------------- +// Function: CompType::getMemberIntType ///\brief Returns the integer datatype of the specified member in this /// compound datatype. ///\param member_num - IN: Zero-based index of the member @@ -290,7 +305,7 @@ IntType CompType::getMemberIntType( int member_num ) const } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType +// Function: CompType::getMemberFloatType ///\brief Returns the floating-point datatype of the specified member /// in this compound datatype. ///\param member_num - IN: Zero-based index of the member @@ -305,7 +320,7 @@ FloatType CompType::getMemberFloatType( int member_num ) const } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType +// Function: CompType::getMemberStrType ///\brief Returns the string datatype of the specified member in this /// compound datatype. ///\param member_num - IN: Zero-based index of the member @@ -319,6 +334,21 @@ StrType CompType::getMemberStrType( int member_num ) const return(strtype); } +//-------------------------------------------------------------------------- +// Function: CompType::getMemberVarLenType +///\brief Returns the variable length datatype of the specified member +/// in this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return VarLenType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +VarLenType CompType::getMemberVarLenType( int member_num ) const +{ + VarLenType varlentype(p_get_member_type(member_num)); + return(varlentype); +} + /* old style of getMemberType - using overloads; new style above returns the appropriate datatypes but has different named functions. In the old style, a datatype must be passed into the function. diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index bc96969..1a04279 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -49,13 +49,17 @@ class H5_DLLCPP CompType : public DataType { // Returns the name of a member of this compound datatype. string getMemberName( unsigned member_num ) const; + // Returns the generic datatype of the specified member in + // this compound datatype. + DataType getMemberDataType( int member_num ) const; + // Returns the compound datatype of the specified member in // this compound datatype. - CompType getMemberCompType( int member_num ) const; + ArrayType getMemberArrayType( int member_num ) const; - // Returns the generic datatype of the specified member in + // Returns the compound datatype of the specified member in // this compound datatype. - DataType getMemberDataType( int member_num ) const; + CompType getMemberCompType( int member_num ) const; // Returns the enumeration datatype of the specified member in // this compound datatype. @@ -73,6 +77,10 @@ class H5_DLLCPP CompType : public DataType { // this compound datatype. StrType getMemberStrType( int member_num ) const; + // Returns the compound datatype of the specified member in + // this compound datatype. + VarLenType getMemberVarLenType( int member_num ) const; + // Returns the number of members in this compound datatype. int getNmembers() const; diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 47673b4..d72cab5 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -240,7 +240,7 @@ int EnumType::getNmembers() const int num_members = H5Tget_nmembers( id ); if( num_members < 0 ) { - throw DataTypeIException("CompType::getNmembers", + throw DataTypeIException("EnumType::getNmembers", "H5Tget_nmembers returns negative number of members"); } return( num_members ); diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index c31946a..21e23c6 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -31,6 +31,9 @@ class H5_DLLCPP VarLenType : public DataType { // Copy constructor: makes copy of the original object. VarLenType( const VarLenType& original ); + // Constructor that takes an existing id + VarLenType( const hid_t existing_id ); + // Noop destructor virtual ~VarLenType(); @@ -38,8 +41,6 @@ class H5_DLLCPP VarLenType : public DataType { // Default constructor VarLenType(); - // Constructor that takes an existing id - VarLenType( const hid_t existing_id ); }; #ifndef H5_NO_NAMESPACE } |