From b3017997a8044daf273bf2e8084cc172e666830e Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 9 Aug 2016 00:29:50 -0500 Subject: [svn-r30272] Purpose: Code improvement Description: - Added "const" to arguments that should be const - Added "const" to const functions, i.e., function that don't change the objects they operate on. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5DcreatProp.cpp | 12 ++++++------ c++/src/H5DcreatProp.h | 12 ++++++------ c++/src/H5DxferProp.cpp | 17 ++++++++--------- c++/src/H5DxferProp.h | 12 ++++++------ c++/src/H5FaccProp.cpp | 43 ++----------------------------------------- c++/src/H5FaccProp.h | 11 ++--------- c++/src/H5Location.cpp | 7 ++++--- c++/src/H5Object.cpp | 3 ++- c++/src/H5Object.h | 2 +- 9 files changed, 37 insertions(+), 82 deletions(-) diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index b2a3e96..d362d65 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -333,7 +333,7 @@ void DSetCreatPropList::getFillValue( const DataType& fvalue_type, void* value ) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_value_t DSetCreatPropList::isFillValueDefined() +H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const { H5D_fill_value_t status; herr_t ret_value = H5Pfill_value_defined(id, &status); @@ -517,7 +517,7 @@ void DSetCreatPropList::modifyFilter( H5Z_filter_t filter_id, unsigned int ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetCreatPropList::allFiltersAvail() +bool DSetCreatPropList::allFiltersAvail() const { htri_t ret_value = H5Pall_filters_avail(id); if( ret_value > 0 ) @@ -565,7 +565,7 @@ void DSetCreatPropList::setShuffle() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_alloc_time_t DSetCreatPropList::getAllocTime() +H5D_alloc_time_t DSetCreatPropList::getAllocTime() const { H5D_alloc_time_t alloc_time; herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); @@ -589,7 +589,7 @@ H5D_alloc_time_t DSetCreatPropList::getAllocTime() /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_time_t DSetCreatPropList::getFillTime() +H5D_fill_time_t DSetCreatPropList::getFillTime() const { H5D_fill_time_t fill_time; herr_t ret_value = H5Pget_fill_time(id, &fill_time); @@ -615,7 +615,7 @@ H5D_fill_time_t DSetCreatPropList::getFillTime() /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) +void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const { herr_t ret_value = H5Pset_alloc_time(id, alloc_time); if( ret_value < 0 ) @@ -636,7 +636,7 @@ void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) +void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const { herr_t ret_value = H5Pset_fill_time(id, fill_time); if( ret_value < 0 ) diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 51347e8..fed41b4 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -38,13 +38,13 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { // Queries whether all the filters set in this property list are // available currently. - bool allFiltersAvail(); + bool allFiltersAvail() const; // Get space allocation time for this property. - H5D_alloc_time_t getAllocTime(); + H5D_alloc_time_t getAllocTime() const; // Set space allocation time for dataset during creation. - void setAllocTime(H5D_alloc_time_t alloc_time); + void setAllocTime(H5D_alloc_time_t alloc_time) const; // Retrieves the size of the chunks used to store a chunked layout dataset. int getChunk( int max_ndims, hsize_t* dim ) const; @@ -59,10 +59,10 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { int getExternalCount() const; // Gets fill value writing time. - H5D_fill_time_t getFillTime(); + H5D_fill_time_t getFillTime() const; // Sets fill value writing time for dataset. - void setFillTime(H5D_fill_time_t fill_time); + void setFillTime(H5D_fill_time_t fill_time) const; // Retrieves a dataset fill value. void getFillValue( const DataType& fvalue_type, void* value ) const; @@ -88,7 +88,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { int getNfilters() const; // Checks if fill value has been defined for this property. - H5D_fill_value_t isFillValueDefined(); + H5D_fill_value_t isFillValueDefined() const; // Modifies the specified filter. void modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const; diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 49bbfe6..c228b44 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -145,13 +145,12 @@ void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::getBuffer ///\brief Reads buffer settings. -///\param tconv - IN: Pointer to application-allocated type conversion buffer -///\param bkg - IN: Pointer to application-allocated background buffer +///\param tconv - OUT: Pointer to application-allocated type conversion buf +///\param bkg - OUT: Pointer to application-allocated background buffer ///\return Buffer size, in bytes ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- - size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const { size_t buffer_size = H5Pget_buffer( id, tconv, bkg ); @@ -443,7 +442,7 @@ void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void** /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSmallData // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) +void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const { herr_t ret_value = H5Pset_small_data_block_size(id, size); if (ret_value < 0) @@ -460,7 +459,7 @@ void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t DSetMemXferPropList::getSmallDataBlockSize() +hsize_t DSetMemXferPropList::getSmallDataBlockSize() const { hsize_t size; herr_t ret_value = H5Pget_small_data_block_size(id, &size); @@ -483,7 +482,7 @@ hsize_t DSetMemXferPropList::getSmallDataBlockSize() /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetHyperVectorSize // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) +void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const { herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); if (ret_value < 0) @@ -501,7 +500,7 @@ void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getHyperVectorSize() +size_t DSetMemXferPropList::getHyperVectorSize() const { size_t vector_size; herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); @@ -531,7 +530,7 @@ size_t DSetMemXferPropList::getHyperVectorSize() /// \li \c H5Z_DISABLE_EDC // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) +void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const { herr_t ret_value = H5Pset_edc_check(id, check); if (ret_value < 0) @@ -548,7 +547,7 @@ void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5Z_EDC_t DSetMemXferPropList::getEDCCheck() +H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const { H5Z_EDC_t check = H5Pget_edc_check(id); if (check < 0) diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 52a9a48..31fc372 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -86,24 +86,24 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { H5MM_free_t& free, void** free_info ) const; // Sets the size of a contiguous block reserved for small data. - void setSmallDataBlockSize(hsize_t size); + void setSmallDataBlockSize(hsize_t size) const; // Returns the current small data block size setting. - hsize_t getSmallDataBlockSize(); + hsize_t getSmallDataBlockSize() const; // Sets number of I/O vectors to be read/written in hyperslab I/O. - void setHyperVectorSize(size_t vector_size); + void setHyperVectorSize(size_t vector_size) const; // Returns the number of I/O vectors to be read/written in // hyperslab I/O. - size_t getHyperVectorSize(); + size_t getHyperVectorSize() const; // Enables or disables error-detecting for a dataset reading // process. - void setEDCCheck(H5Z_EDC_t check); + void setEDCCheck(H5Z_EDC_t check) const; // Determines whether error-detection is enabled for dataset reads. - H5Z_EDC_t getEDCCheck(); + H5Z_EDC_t getEDCCheck() const; ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index c284500..972f915 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -330,26 +330,6 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP //-------------------------------------------------------------------------- // Function: FileAccPropList::setSplit -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param meta_plist - IN: File access plist for the metadata file -// Param raw_plist - IN: File access plist for the raw data file -// Param meta_ext - IN: Metadata filename extension as \c char* -// Param raw_ext - IN: Raw data filename extension as \c char* -// Exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 -// Modification -// Planned for removal. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 -//-------------------------------------------------------------------------- -void FileAccPropList::setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext ) const -{ - setSplit(meta_plist, raw_plist, meta_ext, raw_ext); -} - -//-------------------------------------------------------------------------- -// Function: FileAccPropList::setSplit ///\brief This is an overloaded member function, provided for convenience. /// It takes character arguments as \c H5std_string. ///\param meta_plist - IN: File access plist for the metadata file @@ -364,25 +344,6 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP setSplit( meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() ); } -//-------------------------------------------------------------------------- -// Function: FileAccPropList::setSplit -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param meta_plist - IN: File access plist for the metadata file -// Param raw_plist - IN: File access plist for the raw data file -// Param meta_ext - IN: Metadata filename extension as \c char* -// Param raw_ext - IN: Raw data filename extension as \c char* -// Exception H5::PropListIException -// Modification -// Planned for removal. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 -//-------------------------------------------------------------------------- -void FileAccPropList::setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext ) const -{ - setSplit(meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() ); -} - // Stream Virtual File Driver had been removed from the main library. // FileAccPropList::[s,g]etStream are now removed from the C++ API. // -BMR, March, 2012 @@ -652,7 +613,7 @@ void FileAccPropList::getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rd ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) +void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const { herr_t ret_value = H5Pset_fclose_degree(id, degree); if( ret_value < 0 ) @@ -668,7 +629,7 @@ void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5F_close_degree_t FileAccPropList::getFcloseDegree() +H5F_close_degree_t FileAccPropList::getFcloseDegree() const { H5F_close_degree_t degree; herr_t ret_value = H5Pget_fclose_degree(id, °ree); diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index b214447..831488c 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -74,13 +74,6 @@ class H5_DLLCPP FileAccPropList : public PropList { const FileAccPropList& raw_plist, const H5std_string& meta_ext = ".meta", const H5std_string& raw_ext = ".raw") const; - // These two overloaded functions are kept for backward compatibility - // only; they missed the const's and will be removed in future release. - void setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, - const char* meta_ext=".meta", const char* raw_ext=".raw") const; - void setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, - const H5std_string& meta_ext=".meta", - const H5std_string& raw_ext=".raw") const; // Sets the maximum size of the data sieve buffer. void setSieveBufSize(size_t bufsize) const; @@ -119,10 +112,10 @@ class H5_DLLCPP FileAccPropList : public PropList { void getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const; // Sets the degree for the file close behavior. - void setFcloseDegree(H5F_close_degree_t degree); + void setFcloseDegree(H5F_close_degree_t degree) const; // Returns the degree for the file close behavior. - H5F_close_degree_t getFcloseDegree(); + H5F_close_degree_t getFcloseDegree() const; // Sets garbage collecting references flag. void setGcReferences( unsigned gc_ref = 0 ) const; diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index c4debba..2c6da80 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -74,8 +74,9 @@ H5Location::H5Location() : IdComponent() {} // been moved to the sub-classes. It will be removed in 1.10 release. If its // removal does not raise any problems in 1.10, it will be removed from 1.8 in // subsequent releases. +// Removed in 1.10.1 - Aug 2016 //-------------------------------------------------------------------------- -H5Location::H5Location(const hid_t object_id) : IdComponent() {} +// H5Location::H5Location(const hid_t object_id) : IdComponent() {} //-------------------------------------------------------------------------- // Function: H5Location copy constructor @@ -563,8 +564,8 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const HDmemset(comment_C, 0, tmp_len+1); // clear buffer // Used overloaded function - ssize_t comment_len = getComment(name, tmp_len+1, comment_C); - if (comment_len < 0) + ssize_t temp_len = getComment(name, tmp_len+1, comment_C); + if (temp_len < 0) { delete []comment_C; throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 3cce9fe..f9d5abf 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -56,8 +56,9 @@ H5Object::H5Object() : H5Location() {} // been moved to the sub-classes. It will be removed in 1.10 release. If its // removal does not raise any problems in 1.10, it will be removed from 1.8 in // subsequent releases. +// Removed in 1.10.1 - Aug 2016 //-------------------------------------------------------------------------- -H5Object::H5Object(const hid_t object_id) : H5Location() {} +//H5Object::H5Object(const hid_t object_id) : H5Location() {} //-------------------------------------------------------------------------- // Function: H5Object copy constructor diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index f8ac792..193e5d1 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -48,7 +48,7 @@ class H5_DLLCPP H5Object : public H5Location { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS // Gets the name of this HDF5 object, i.e., Group, DataSet, or - // DataType. + // DataType. These should have const but are retiring anyway. ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; H5std_string getObjName() const; -- cgit v0.12