Code clean-up.

Description:
    - Removed function prototypes left in by mistake
    - Moved H5Location::getNumObjs() to class Group because the C
      function in this wrapper only takes a group or file id.
    - Moved H5Object::getNumAttrs to H5Location because the C function
      in this wrapper can also take an attribute id.
    - Misc improvements in comments
Platforms tested:
    Linux/32 2.6 (jam)
    Linux/64 (platypus)
    Darwin (osx1010test)
This commit is contained in:
Binh-Minh Ribler
2017-04-25 14:00:17 -05:00
parent 432435b158
commit 4bc55bbf94
8 changed files with 42 additions and 49 deletions

View File

@@ -64,7 +64,8 @@ DataType CommonFG::openDataType(const char* name) const
throwException("openDataType", "H5Topen2 failed");
// No failure, create and return the DataType object
DataType data_type(type_id);
DataType data_type;
f_DataType_setId(&data_type, type_id);
return(data_type);
}

View File

@@ -21,7 +21,7 @@ namespace H5 {
\brief Class H5File represents an HDF5 file and inherits from class Group
as file is a root group.
Inheritance: Group -> H5Object -> H5Location -> IdComponent
Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent
*/
class H5_DLLCPP H5File : public Group {
public:
@@ -92,7 +92,7 @@ class H5_DLLCPP H5File : public Group {
// Throw file exception.
virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
// for CommonFG to get the file id.
// For CommonFG to get the file id.
virtual hid_t getLocId() const;
// Default constructor

View File

@@ -114,6 +114,23 @@ void Group::closeObjId(hid_t obj_id) const
}
}
//--------------------------------------------------------------------------
// Function: Group::getNumObjs
///\brief Returns the number of objects in this group.
///\return Number of objects
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - January, 2003
//--------------------------------------------------------------------------
hsize_t Group::getNumObjs() const
{
H5G_info_t ginfo; // Group information
herr_t ret_value = H5Gget_info(getId(), &ginfo);
if(ret_value < 0)
throwException("getNumObjs", "H5Gget_info failed");
return (ginfo.nlinks);
}
//--------------------------------------------------------------------------
// Function: Group::getLocId
// Purpose: Get the id of this group

View File

@@ -28,14 +28,6 @@ class VarLenType;
class H5_DLLCPP Group : public H5Object, public CommonFG {
public:
// Group constructor to create a group or file (aka root group).
Group(const char* name, size_t size_hint = 0);
Group(const H5std_string& name, size_t size_hint = 0);
// Group constructor to open a group or file (aka root group).
Group(const char* name);
Group(const H5std_string& name);
// Close this group.
virtual void close();
@@ -60,6 +52,9 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Closes an object opened by getObjId().
void closeObjId(hid_t obj_id) const;
// Returns the number of objects in this group.
hsize_t getNumObjs() const;
// default constructor
Group();

View File

@@ -1282,20 +1282,20 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o
#endif /* H5_NO_DEPRECATED_SYMBOLS */
//--------------------------------------------------------------------------
// Function: H5Location::getNumObjs
///\brief Returns the number of objects in this group.
///\return Number of objects
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - January, 2003
// Function: H5Location::getNumAttrs
///\brief Returns the number of attributes attached to this HDF5 object.
///\return Number of attributes
///\exception H5::AttributeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
hsize_t H5Location::getNumObjs() const
int H5Location::getNumAttrs() const
{
H5G_info_t ginfo; // Group information
H5O_info_t oinfo; /* Object info */
herr_t ret_value = H5Gget_info(getId(), &ginfo);
if(ret_value < 0)
throwException("getNumObjs", "H5Gget_info failed");
return (ginfo.nlinks);
if(H5Oget_info(getId(), &oinfo) < 0)
throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
else
return(static_cast<int>(oinfo.num_attrs));
}
//--------------------------------------------------------------------------

View File

@@ -30,9 +30,9 @@ namespace H5 {
Inheritance: IdComponent
*/
// Class forwarding
class H5_DLLCPP ArrayType;
class H5_DLLCPP LinkAccPropList;
class H5_DLLCPP VarLenType;
class ArrayType;
class LinkAccPropList;
class VarLenType;
class H5_DLLCPP H5Location : public IdComponent {
public:
// Checks if a link of a given name exists in a location
@@ -113,8 +113,8 @@ class H5_DLLCPP H5Location : public IdComponent {
H5std_string getLinkval(const char* link_name, size_t size=0) const;
H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const;
// Returns the number of objects in this group.
hsize_t getNumObjs() const;
// Determines the number of attributes belong to this object.
int getNumAttrs() const;
// Retrieves the name of an object in this group, given the
// object's index.

View File

@@ -287,23 +287,6 @@ unsigned H5Object::objVersion() const
return(version);
}
//--------------------------------------------------------------------------
// Function: H5Object::getNumAttrs
///\brief Returns the number of attributes attached to this HDF5 object.
///\return Number of attributes
///\exception H5::AttributeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int H5Object::getNumAttrs() const
{
H5O_info_t oinfo; /* Object info */
if(H5Oget_info(getId(), &oinfo) < 0)
throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
else
return(static_cast<int>(oinfo.num_attrs));
}
//--------------------------------------------------------------------------
// Function: H5Object::attrExists
///\brief Checks whether the named attribute exists at this location.

View File

@@ -40,8 +40,8 @@ namespace H5 {
Inheritance: H5Location -> IdComponent
*/
// Class forwarding
class H5_DLLCPP H5Object;
class H5_DLLCPP Attribute;
class H5Object;
class Attribute;
// Define the operator function pointer for H5Aiterate().
typedef void (*attr_operator_t)(H5Object& loc/*in*/,
@@ -78,9 +78,6 @@ class H5_DLLCPP H5Object : public H5Location {
// Returns the object header version of an object
unsigned objVersion() const;
// Determines the number of attributes belong to this object.
int getNumAttrs() const;
// Checks whether the named attribute exists for this object.
bool attrExists(const char* name) const;
bool attrExists(const H5std_string& name) const;