Skip to content

Commit

Permalink
Added C++11 override keyword where appropriate
Browse files Browse the repository at this point in the history
Added H5_OVERRIDE macro for compatibility with both C++11 and older.
  • Loading branch information
seanm committed Mar 8, 2021
1 parent 5f376cc commit 5ccde4a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 32 deletions.
8 changes: 4 additions & 4 deletions c++/src/H5DataSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class H5_DLLCPP DataSpace : public IdComponent {
DataSpace &operator=(const DataSpace &rhs);

// Closes this dataspace.
virtual void close();
virtual void close() H5_OVERRIDE;

// Makes copy of an existing dataspace.
void copy(const DataSpace &like_space);
Expand Down Expand Up @@ -115,13 +115,13 @@ class H5_DLLCPP DataSpace : public IdComponent {

///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("DataSpace");
}

// Gets the dataspace id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;

// Deletes the global constant
static void deleteConstants();
Expand All @@ -133,7 +133,7 @@ class H5_DLLCPP DataSpace : public IdComponent {

protected:
// Sets the dataspace id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;

#endif // DOXYGEN_SHOULD_SKIP_THIS

Expand Down
24 changes: 12 additions & 12 deletions c++/src/H5Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,84 +94,84 @@ class H5_DLLCPP FileIException : public Exception {
public:
FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
FileIException();
virtual ~FileIException() throw();
virtual ~FileIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP GroupIException : public Exception {
public:
GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
GroupIException();
virtual ~GroupIException() throw();
virtual ~GroupIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP DataSpaceIException : public Exception {
public:
DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataSpaceIException();
virtual ~DataSpaceIException() throw();
virtual ~DataSpaceIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP DataTypeIException : public Exception {
public:
DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataTypeIException();
virtual ~DataTypeIException() throw();
virtual ~DataTypeIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP ObjHeaderIException : public Exception {
public:
ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
ObjHeaderIException();
virtual ~ObjHeaderIException() throw();
virtual ~ObjHeaderIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP PropListIException : public Exception {
public:
PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
PropListIException();
virtual ~PropListIException() throw();
virtual ~PropListIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP DataSetIException : public Exception {
public:
DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataSetIException();
virtual ~DataSetIException() throw();
virtual ~DataSetIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP AttributeIException : public Exception {
public:
AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
AttributeIException();
virtual ~AttributeIException() throw();
virtual ~AttributeIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP ReferenceException : public Exception {
public:
ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
ReferenceException();
virtual ~ReferenceException() throw();
virtual ~ReferenceException() throw() H5_OVERRIDE;
};

class H5_DLLCPP LibraryIException : public Exception {
public:
LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
LibraryIException();
virtual ~LibraryIException() throw();
virtual ~LibraryIException() throw() H5_OVERRIDE;
};

class H5_DLLCPP LocationException : public Exception {
public:
LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
LocationException();
virtual ~LocationException() throw();
virtual ~LocationException() throw() H5_OVERRIDE;
};

class H5_DLLCPP IdComponentException : public Exception {
public:
IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
IdComponentException();
virtual ~IdComponentException() throw();
virtual ~IdComponentException() throw() H5_OVERRIDE;

}; // end of IdComponentException
} // namespace H5
Expand Down
12 changes: 6 additions & 6 deletions c++/src/H5File.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class H5_DLLCPP H5File : public Group {
const FileAccPropList &access_plist = FileAccPropList::DEFAULT);

// Close this file.
virtual void close();
virtual void close() H5_OVERRIDE;

// Gets a copy of the access property list of this file.
FileAccPropList getAccessPlist() const;
Expand Down Expand Up @@ -96,16 +96,16 @@ class H5_DLLCPP H5File : public Group {

///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("H5File");
}

// Throw file exception.
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;

// For CommonFG to get the file id.
virtual hid_t getLocId() const;
virtual hid_t getLocId() const H5_OVERRIDE;

// Default constructor
H5File();
Expand All @@ -114,15 +114,15 @@ class H5_DLLCPP H5File : public Group {
H5File(const H5File &original);

// Gets the HDF5 file id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;

// H5File destructor.
virtual ~H5File();

protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the HDF5 file id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS

private:
Expand Down
14 changes: 7 additions & 7 deletions c++/src/H5Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ namespace H5 {
class H5_DLLCPP Group : public H5Object, public CommonFG {
public:
// Close this group.
virtual void close();
virtual void close() H5_OVERRIDE;

///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("Group");
}

// Throw group exception.
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;

// for CommonFG to get the file id.
virtual hid_t getLocId() const;
virtual hid_t getLocId() const H5_OVERRIDE;

// Creates a group by way of dereference.
Group(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
Expand All @@ -63,18 +63,18 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
Group(const Group &original);

// Gets the group id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;

// Destructor
virtual ~Group();
virtual ~Group() H5_OVERRIDE;

// Creates a copy of an existing group using its id.
Group(const hid_t group_id);

protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the group id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS

private:
Expand Down
7 changes: 7 additions & 0 deletions c++/src/H5Include.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ const bool true = 1;
* magic number as prefix and checksum as suffix for all chunks.
*/
#define H5O_VERSION_2 2

// Define H5_OVERRIDE to override for C++11.
#if defined(__cplusplus) && (201103L <= __cplusplus)
#define H5_OVERRIDE override
#else
#define H5_OVERRIDE
#endif
6 changes: 3 additions & 3 deletions c++/src/H5Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class H5_DLLCPP H5Object : public H5Location {
void removeAttr(const H5std_string &name) const;

// Returns an identifier.
virtual hid_t getId() const = 0;
virtual hid_t getId() const H5_OVERRIDE = 0;

// Gets the name of this HDF5 object, i.e., Group, DataSet, or
// DataType.
Expand All @@ -122,10 +122,10 @@ class H5_DLLCPP H5Object : public H5Location {

// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
virtual void p_setId(const hid_t new_id) = 0;
virtual void p_setId(const hid_t new_id) H5_OVERRIDE = 0;

// Noop destructor.
virtual ~H5Object();
virtual ~H5Object() H5_OVERRIDE;

#endif // DOXYGEN_SHOULD_SKIP_THIS

Expand Down

0 comments on commit 5ccde4a

Please sign in to comment.