Skip to content

Commit

Permalink
Fix HDF5 implicit copy
Browse files Browse the repository at this point in the history
* Delete copy constructors in HDF5 parsing classes.
* Fixed DatasetIO move constructor.

#fixes 916
  • Loading branch information
mmarineBlueQuartz committed Apr 19, 2024
1 parent 448ffa6 commit 7d14d4e
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/IO/AttributeIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class SIMPLNX_EXPORT AttributeIO
*/
AttributeIO(IdType objectId, const std::string& attrName);

AttributeIO(const AttributeIO& other) = delete;
AttributeIO(AttributeIO&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 attribute.
*/
Expand Down Expand Up @@ -164,6 +167,9 @@ class SIMPLNX_EXPORT AttributeIO
template <typename T>
Result<> writeVector(const DimsVector& dims, const std::vector<T>& vector);

AttributeIO& operator=(const AttributeIO& other) = delete;
AttributeIO& operator=(AttributeIO&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Utilities/Parsing/HDF5/IO/DatasetIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DatasetIO::DatasetIO(IdType parentId, const std::string& datasetName)
}

DatasetIO::DatasetIO(DatasetIO&& other) noexcept
: ObjectIO(other)
: ObjectIO(std::move(other))
, m_DatasetName(std::move(other.m_DatasetName))
{
}
Expand Down
5 changes: 5 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/IO/FileIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class SIMPLNX_EXPORT FileIO : public GroupIO
*/
FileIO(IdType fileId);

FileIO(const FileIO& rhs) = delete;

/**
* @brief Move constructor.
* @param rhs
Expand All @@ -79,6 +81,9 @@ class SIMPLNX_EXPORT FileIO : public GroupIO
*/
std::string getName() const override;

FileIO& operator=(const FileIO& rhs) = delete;
FileIO& operator=(FileIO&& rhs) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/IO/GroupIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class SIMPLNX_EXPORT GroupIO : public ObjectIO
*/
GroupIO(IdType parentId, const std::string& groupName);

GroupIO(const GroupIO& other) = delete;
GroupIO(GroupIO&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 group.
*/
Expand Down Expand Up @@ -135,6 +138,9 @@ class SIMPLNX_EXPORT GroupIO : public ObjectIO
*/
bool isDataset(const std::string& childName) const;

GroupIO& operator=(const GroupIO& other) = delete;
GroupIO& operator=(GroupIO&& other) noexcept = default;

protected:
/**
* @brief Constructs a GroupWriter for use in derived classes. This
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/IO/ObjectIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SIMPLNX_EXPORT ObjectIO
*/
ObjectIO(IdType parentId, const std::string& targetName);

ObjectIO(const ObjectIO& other) = delete;
ObjectIO(ObjectIO&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 object.
*/
Expand Down Expand Up @@ -128,6 +131,9 @@ class SIMPLNX_EXPORT ObjectIO
*/
AttributeIO createAttribute(const std::string& name);

ObjectIO& operator=(const ObjectIO& other) = delete;
ObjectIO& operator=(ObjectIO&& other) noexcept = default;

protected:
/**
* @brief Constructs an ObjectIO for use in derived classes. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class SIMPLNX_EXPORT AttributeReader
*/
AttributeReader(IdType objectId, const std::string& attrName);

AttributeReader(const AttributeReader& other) = delete;
AttributeReader(AttributeReader&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 attribute.
*/
Expand Down Expand Up @@ -146,6 +149,9 @@ class SIMPLNX_EXPORT AttributeReader
*/
std::string readAsString() const;

AttributeReader& operator=(const AttributeReader& other) = delete;
AttributeReader& operator=(AttributeReader&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Readers/DatasetReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class SIMPLNX_EXPORT DatasetReader : public ObjectReader
*/
DatasetReader(IdType parentId, const std::string& dataName);

DatasetReader(const DatasetReader& other) = delete;
DatasetReader(DatasetReader&& other) noexcept = default;

/**
* @brief Releases the HDF5 dataset.
*/
Expand Down Expand Up @@ -122,6 +125,9 @@ class SIMPLNX_EXPORT DatasetReader : public ObjectReader

std::string getFilterName() const;

DatasetReader& operator=(const DatasetReader& other) = delete;
DatasetReader& operator=(DatasetReader&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Readers/FileReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SIMPLNX_EXPORT FileReader : public GroupReader
*/
FileReader(IdType fileId);

FileReader(const FileReader& other) = delete;
FileReader(FileReader&& other) noexcept = default;

/**
* @brief Releases the HDF5 file ID.
*/
Expand All @@ -38,6 +41,9 @@ class SIMPLNX_EXPORT FileReader : public GroupReader
*/
std::string getName() const override;

FileReader& operator=(const FileReader& other) = delete;
FileReader& operator=(FileReader&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Readers/GroupReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class SIMPLNX_EXPORT GroupReader : public ObjectReader
*/
GroupReader(IdType parentId, const std::string& groupName);

GroupReader(const GroupReader& other) = delete;
GroupReader(GroupReader&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 group.
*/
Expand Down Expand Up @@ -87,6 +90,9 @@ class SIMPLNX_EXPORT GroupReader : public ObjectReader
*/
bool isDataset(const std::string& childName) const;

GroupReader& operator=(const GroupReader& other) = delete;
GroupReader& operator=(GroupReader&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Readers/ObjectReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class SIMPLNX_EXPORT ObjectReader
*/
ObjectReader(IdType parentId, const std::string& targetName);

ObjectReader(const ObjectReader& other) = delete;
ObjectReader(ObjectReader&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 object.
*/
Expand Down Expand Up @@ -96,6 +99,9 @@ class SIMPLNX_EXPORT ObjectReader
*/
AttributeReader getAttributeByIdx(size_t idx) const;

ObjectReader& operator=(const ObjectReader& other) = delete;
ObjectReader& operator=(ObjectReader&& other) noexcept = default;

protected:
/**
* @brief Constructs an ObjectReader for use in derived classes. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class SIMPLNX_EXPORT AttributeWriter
*/
AttributeWriter(IdType objectId, const std::string& attributeName);

AttributeWriter(const AttributeWriter& other) = delete;
AttributeWriter(AttributeWriter&& other) noexcept = default;

/**
* @brief Default destructor
*/
Expand Down Expand Up @@ -204,6 +207,9 @@ class SIMPLNX_EXPORT AttributeWriter
return returnError;
}

AttributeWriter& operator=(const AttributeWriter& other) = delete;
AttributeWriter& operator=(AttributeWriter&& other) noexcept = default;

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 211 in src/simplnx/Utilities/Parsing/HDF5/Writers/AttributeWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

protected:
/**
* @brief Finds and deletes any existing attribute with the current name.
Expand Down
2 changes: 2 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ DatasetWriter::DatasetWriter(IdType parentId, const std::string& datasetName)
#endif
}

DatasetWriter::DatasetWriter(DatasetWriter&& other) noexcept = default;

Check failure on line 30 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, g++-9)

function ‘nx::core::HDF5::DatasetWriter::DatasetWriter(nx::core::HDF5::DatasetWriter&&)’ defaulted on its redeclaration with an exception-specification that differs from the implicit exception-specification ‘’

DatasetWriter::~DatasetWriter()
{
closeHdf5();
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SIMPLNX_EXPORT DatasetWriter : public ObjectWriter
*/
DatasetWriter(IdType parentId, const std::string& datasetName);

DatasetWriter(const DatasetWriter& other) = delete;
DatasetWriter(DatasetWriter&& other) noexcept;

/**
* @brief Default destructor
*/
Expand Down Expand Up @@ -203,6 +206,9 @@ class SIMPLNX_EXPORT DatasetWriter : public ObjectWriter
*/
IdType getPListId() const;

DatasetWriter& operator=(const DatasetWriter& other) = delete;
DatasetWriter& operator=(DatasetWriter&& other) noexcept = default;

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (macos-14)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

Check warning on line 210 in src/simplnx/Utilities/Parsing/HDF5/Writers/DatasetWriter.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]

protected:
/**
* @brief Finds and deletes any existing attribute with the current name.
Expand Down
9 changes: 9 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Writers/FileWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class SIMPLNX_EXPORT FileWriter : public GroupWriter
*/
FileWriter();

/**
* @brief Copy constructor.
* @param rhs
*/
FileWriter(const FileWriter& rhs) = delete;

/**
* @brief Move constructor.
* @param rhs
Expand All @@ -54,6 +60,9 @@ class SIMPLNX_EXPORT FileWriter : public GroupWriter
*/
std::string getName() const override;

FileWriter& operator=(const FileWriter& rhs) = delete;
FileWriter& operator=(FileWriter&& rhs) noexcept = default;

protected:
/**
* @brief Constructs a FileWriter that creates and wraps an HDF5 file at the
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Writers/GroupWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class SIMPLNX_EXPORT GroupWriter : public ObjectWriter
*/
GroupWriter(IdType parentId, const std::string& objectName);

GroupWriter(const GroupWriter& other) = delete;
GroupWriter(GroupWriter&& other) noexcept = default;

/**
* @brief Closes the HDF5 group.
*/
Expand Down Expand Up @@ -62,6 +65,9 @@ class SIMPLNX_EXPORT GroupWriter : public ObjectWriter
*/
Result<> createLink(const std::string& objectPath);

GroupWriter& operator=(const GroupWriter& other) = delete;
GroupWriter& operator=(GroupWriter&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down
6 changes: 6 additions & 0 deletions src/simplnx/Utilities/Parsing/HDF5/Writers/ObjectWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class SIMPLNX_EXPORT ObjectWriter
*/
ObjectWriter(IdType parentId, IdType objectId = 0);

ObjectWriter(const ObjectWriter& other) = delete;
ObjectWriter(ObjectWriter&& other) noexcept = default;

/**
* @brief Releases the wrapped HDF5 object.
*/
Expand Down Expand Up @@ -90,6 +93,9 @@ class SIMPLNX_EXPORT ObjectWriter
*/
AttributeWriter createAttribute(const std::string& name);

ObjectWriter& operator=(const ObjectWriter& other) = delete;
ObjectWriter& operator=(ObjectWriter&& other) noexcept = default;

protected:
/**
* @brief Closes the HDF5 ID and resets it to 0.
Expand Down

0 comments on commit 7d14d4e

Please sign in to comment.