diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2017-04-25 19:00:17 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2017-04-25 19:00:17 (GMT) |
commit | 4bc55bbf94d7fce7521b2efd766f677ca45c9ecc (patch) | |
tree | 20d9c672f686e97e2390972d73e71efe4b67cf55 /c++/src | |
parent | 432435b158ea2889d971390a60fd24eae31561d0 (diff) | |
download | hdf5-4bc55bbf94d7fce7521b2efd766f677ca45c9ecc.zip hdf5-4bc55bbf94d7fce7521b2efd766f677ca45c9ecc.tar.gz hdf5-4bc55bbf94d7fce7521b2efd766f677ca45c9ecc.tar.bz2 |
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)
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/H5CommonFG.cpp | 3 | ||||
-rw-r--r-- | c++/src/H5File.h | 4 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 17 | ||||
-rw-r--r-- | c++/src/H5Group.h | 11 | ||||
-rw-r--r-- | c++/src/H5Location.cpp | 22 | ||||
-rw-r--r-- | c++/src/H5Location.h | 10 | ||||
-rw-r--r-- | c++/src/H5Object.cpp | 17 | ||||
-rw-r--r-- | c++/src/H5Object.h | 7 |
8 files changed, 42 insertions, 49 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index c9c203a..baa52a2 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -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); } diff --git a/c++/src/H5File.h b/c++/src/H5File.h index b428a40..0f921ae 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -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 diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 994d9ff..c4b3b2c 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -115,6 +115,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 // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index a7e1f7c..9430b13 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -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(); diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index e820b0d..ed2daf3 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -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)); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index a57d3ed..f551560 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -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. diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 865d04f..a711374 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -288,23 +288,6 @@ unsigned H5Object::objVersion() const } //-------------------------------------------------------------------------- -// 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. ///\param name - IN: Name of the attribute to be queried diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index fdaead2..0e2446f 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -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; |