summaryrefslogtreecommitdiffstats
path: root/c++/src/H5CommonFG.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2006-01-03 14:09:40 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2006-01-03 14:09:40 (GMT)
commited2764c29b48f0fd8f82d4936da1403c6fa48efa (patch)
treeaf4fb921e95050378d1b4dce45e8fe92e815ec0f /c++/src/H5CommonFG.cpp
parent5aa7685ae3efefa3bbc71fccf473598580af3ede (diff)
downloadhdf5-ed2764c29b48f0fd8f82d4936da1403c6fa48efa.zip
hdf5-ed2764c29b48f0fd8f82d4936da1403c6fa48efa.tar.gz
hdf5-ed2764c29b48f0fd8f82d4936da1403c6fa48efa.tar.bz2
[svn-r11855] Purpose: Adding more wrappers
Description: Added member function H5File::openFile and overloaded for convenience. Added overloaded getObjinfo to skip the middle parameter. Changed StrType(const size_t& size); to StrType(const int dummy, const size_t& size); because the first one clashed with StrType(const hid_t existing_id); Platforms tested: Linux 2.4 (heping) SunOS 5.8 64-bit (sol) AIX 5.1 (copper)
Diffstat (limited to 'c++/src/H5CommonFG.cpp')
-rw-r--r--c++/src/H5CommonFG.cpp175
1 files changed, 130 insertions, 45 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index ebf6c8b..5e34c46 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -288,6 +288,11 @@ void CommonFG::unlink( const string& name ) const
///\param src - IN: Object's original name
///\param dst - IN: Object's new name
///\exception H5::FileIException or H5::GroupIException
+///\note
+/// Exercise care in moving groups as it is possible to render
+/// data in a file inaccessible with Group::move. Please refer
+/// to the Group Interface in the HDF5 User's Guide at:
+/// http://hdf.ncsa.uiuc.edu/HDF5/doc/Groups.html
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::move( const char* src, const char* dst ) const
@@ -318,6 +323,10 @@ void CommonFG::move( const string& src, const string& dst ) const
///\param follow_link - IN: Link flag
///\param statbuf - OUT: Buffer to return information about the object
///\exception H5::FileIException or H5::GroupIException
+///\par Description
+/// For more information, please refer to the C layer Reference
+/// Manual at:
+/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5G.html#Group-GetObjinfo
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& statbuf ) const
@@ -342,6 +351,34 @@ void CommonFG::getObjinfo( const string& name, hbool_t follow_link, H5G_stat_t&
}
//--------------------------------------------------------------------------
+// Function: CommonFG::getObjinfo
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above functions in that it doesn't have
+/// the paramemter \a follow_link.
+// Programmer Binh-Minh Ribler - Nov, 2005
+//--------------------------------------------------------------------------
+void CommonFG::getObjinfo( const char* name, H5G_stat_t& statbuf ) const
+{
+ herr_t ret_value = H5Gget_objinfo( getLocId(), name, 0, &statbuf );
+ if( ret_value < 0 )
+ {
+ throwException("getObjinfo", "H5Gget_objinfo failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: CommonFG::getObjinfo
+///\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 - Nov, 2005
+//--------------------------------------------------------------------------
+void CommonFG::getObjinfo( const string& name, H5G_stat_t& statbuf ) const
+{
+ getObjinfo( name.c_str(), statbuf );
+}
+
+//--------------------------------------------------------------------------
// Function: CommonFG::getLinkval
///\brief Returns the name of the object that the symbolic link points to.
///\param name - IN: Symbolic link to the object
@@ -586,38 +623,6 @@ void CommonFG::unmount( const string& name ) const
}
//--------------------------------------------------------------------------
-// Function: CommonFG::p_open_data_type (private)
-// Purpose Opens the named datatype and returns the datatype's identifier.
-// Return Id of the datatype
-// Exception H5::FileIException or H5::GroupIException
-// Description
-// This private function is used by the member functions
-// CommonFG::openXxxType, where Xxx indicates the specific
-// datatypes.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-hid_t CommonFG::p_open_data_type( const char* name ) const
-{
- // Call C function H5Topen to open the named datatype in this group,
- // giving either the file or group id
- hid_t datatype_id = H5Topen( getLocId(), name );
-
- // If the datatype's opening failed, throw an exception
- if( datatype_id < 0 )
- {
- throwException("openDataType", "H5Topen failed");
- }
-
- // No failure, return the datatype id
- return( datatype_id );
-}
-
-//
-// The following member functions use the private function
-// p_open_data_type to open a named datatype in this location
-//
-
-//--------------------------------------------------------------------------
// Function: CommonFG::openDataType
///\brief Opens the named generic datatype at this location.
///\param name - IN: Name of the datatype to open
@@ -627,8 +632,18 @@ hid_t CommonFG::p_open_data_type( const char* name ) const
//--------------------------------------------------------------------------
DataType CommonFG::openDataType( const char* name ) const
{
- DataType data_type(p_open_data_type(name));
- return( data_type );
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openDataType", "H5Topen failed");
+ }
+ // No failure, create and return the DataType object
+ DataType data_type(type_id);
+ return(data_type);
}
//--------------------------------------------------------------------------
@@ -649,11 +664,21 @@ DataType CommonFG::openDataType( const string& name ) const
///\param name - IN: Name of the array datatype to open
///\return ArrayType instance
///\exception H5::FileIException or H5::GroupIException
-// Programmer Binh-Minh Ribler - 2000
+// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
ArrayType CommonFG::openArrayType( const char* name ) const
{
- ArrayType array_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openArrayType", "H5Topen failed");
+ }
+ // No failure, create and return the ArrayType object
+ ArrayType array_type (type_id);
return(array_type);
}
@@ -662,7 +687,7 @@ ArrayType CommonFG::openArrayType( const char* name ) const
///\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
+// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
ArrayType CommonFG::openArrayType( const string& name ) const
{
@@ -679,7 +704,17 @@ ArrayType CommonFG::openArrayType( const string& name ) const
//--------------------------------------------------------------------------
CompType CommonFG::openCompType( const char* name ) const
{
- CompType comp_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openCompType", "H5Topen failed");
+ }
+ // No failure, create and return the CompType object
+ CompType comp_type(type_id);
return(comp_type);
}
@@ -705,7 +740,17 @@ CompType CommonFG::openCompType( const string& name ) const
//--------------------------------------------------------------------------
EnumType CommonFG::openEnumType( const char* name ) const
{
- EnumType enum_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openEnumType", "H5Topen failed");
+ }
+ // No failure, create and return the EnumType object
+ EnumType enum_type(type_id);
return(enum_type);
}
@@ -731,7 +776,17 @@ EnumType CommonFG::openEnumType( const string& name ) const
//--------------------------------------------------------------------------
IntType CommonFG::openIntType( const char* name ) const
{
- IntType int_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openIntType", "H5Topen failed");
+ }
+ // No failure, create and return the IntType object
+ IntType int_type(type_id);
return(int_type);
}
@@ -757,7 +812,17 @@ IntType CommonFG::openIntType( const string& name ) const
//--------------------------------------------------------------------------
FloatType CommonFG::openFloatType( const char* name ) const
{
- FloatType float_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openFloatType", "H5Topen failed");
+ }
+ // No failure, create and return the FloatType object
+ FloatType float_type(type_id);
return(float_type);
}
@@ -783,7 +848,17 @@ FloatType CommonFG::openFloatType( const string& name ) const
//--------------------------------------------------------------------------
StrType CommonFG::openStrType( const char* name ) const
{
- StrType str_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openStrType", "H5Topen failed");
+ }
+ // No failure, create and return the StrType object
+ StrType str_type(type_id);
return(str_type);
}
@@ -805,11 +880,21 @@ StrType CommonFG::openStrType( const string& name ) const
///\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
+// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
VarLenType CommonFG::openVarLenType( const char* name ) const
{
- VarLenType varlen_type(p_open_data_type(name));
+ // Call C function H5Topen to open the named datatype in this group,
+ // given either the file or group id
+ hid_t type_id = H5Topen(getLocId(), name);
+
+ // If the datatype's opening failed, throw an exception
+ if( type_id < 0 )
+ {
+ throwException("openVarLenType", "H5Topen failed");
+ }
+ // No failure, create and return the VarLenType object
+ VarLenType varlen_type(type_id);
return(varlen_type);
}
@@ -818,7 +903,7 @@ VarLenType CommonFG::openVarLenType( const char* name ) const
///\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
+// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
VarLenType CommonFG::openVarLenType( const string& name ) const
{