Skip to content

Commit 0fd046b

Browse files
Fix HDF5 implicit copy (#920)
Delete copy constructors in HDF5 parsing classes. Fixed DatasetIO move constructor. fixes #916
1 parent b6e72ed commit 0fd046b

File tree

15 files changed

+87
-1
lines changed

15 files changed

+87
-1
lines changed

src/simplnx/Utilities/Parsing/HDF5/IO/AttributeIO.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class SIMPLNX_EXPORT AttributeIO
3737
*/
3838
AttributeIO(IdType objectId, const std::string& attrName);
3939

40+
AttributeIO(const AttributeIO& other) = delete;
41+
AttributeIO(AttributeIO&& other) noexcept = default;
42+
4043
/**
4144
* @brief Releases the wrapped HDF5 attribute.
4245
*/
@@ -164,6 +167,9 @@ class SIMPLNX_EXPORT AttributeIO
164167
template <typename T>
165168
Result<> writeVector(const DimsVector& dims, const std::vector<T>& vector);
166169

170+
AttributeIO& operator=(const AttributeIO& other) = delete;
171+
AttributeIO& operator=(AttributeIO&& other) noexcept = default;
172+
167173
protected:
168174
/**
169175
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/IO/DatasetIO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DatasetIO::DatasetIO(IdType parentId, const std::string& datasetName)
2424
}
2525

2626
DatasetIO::DatasetIO(DatasetIO&& other) noexcept
27-
: ObjectIO(other)
27+
: ObjectIO(std::move(other))
2828
, m_DatasetName(std::move(other.m_DatasetName))
2929
{
3030
}

src/simplnx/Utilities/Parsing/HDF5/IO/FileIO.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class SIMPLNX_EXPORT FileIO : public GroupIO
6161
*/
6262
FileIO(IdType fileId);
6363

64+
FileIO(const FileIO& rhs) = delete;
65+
6466
/**
6567
* @brief Move constructor.
6668
* @param rhs
@@ -79,6 +81,9 @@ class SIMPLNX_EXPORT FileIO : public GroupIO
7981
*/
8082
std::string getName() const override;
8183

84+
FileIO& operator=(const FileIO& rhs) = delete;
85+
FileIO& operator=(FileIO&& rhs) noexcept = default;
86+
8287
protected:
8388
/**
8489
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/IO/GroupIO.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class SIMPLNX_EXPORT GroupIO : public ObjectIO
2121
*/
2222
GroupIO(IdType parentId, const std::string& groupName);
2323

24+
GroupIO(const GroupIO& other) = delete;
25+
GroupIO(GroupIO&& other) noexcept = default;
26+
2427
/**
2528
* @brief Releases the wrapped HDF5 group.
2629
*/
@@ -135,6 +138,9 @@ class SIMPLNX_EXPORT GroupIO : public ObjectIO
135138
*/
136139
bool isDataset(const std::string& childName) const;
137140

141+
GroupIO& operator=(const GroupIO& other) = delete;
142+
GroupIO& operator=(GroupIO&& other) noexcept = default;
143+
138144
protected:
139145
/**
140146
* @brief Constructs a GroupWriter for use in derived classes. This

src/simplnx/Utilities/Parsing/HDF5/IO/ObjectIO.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class SIMPLNX_EXPORT ObjectIO
2626
*/
2727
ObjectIO(IdType parentId, const std::string& targetName);
2828

29+
ObjectIO(const ObjectIO& other) = delete;
30+
ObjectIO(ObjectIO&& other) noexcept = default;
31+
2932
/**
3033
* @brief Releases the wrapped HDF5 object.
3134
*/
@@ -128,6 +131,9 @@ class SIMPLNX_EXPORT ObjectIO
128131
*/
129132
AttributeIO createAttribute(const std::string& name);
130133

134+
ObjectIO& operator=(const ObjectIO& other) = delete;
135+
ObjectIO& operator=(ObjectIO&& other) noexcept = default;
136+
131137
protected:
132138
/**
133139
* @brief Constructs an ObjectIO for use in derived classes. This

src/simplnx/Utilities/Parsing/HDF5/Readers/AttributeReader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class SIMPLNX_EXPORT AttributeReader
3636
*/
3737
AttributeReader(IdType objectId, const std::string& attrName);
3838

39+
AttributeReader(const AttributeReader& other) = delete;
40+
AttributeReader(AttributeReader&& other) noexcept = default;
41+
3942
/**
4043
* @brief Releases the wrapped HDF5 attribute.
4144
*/
@@ -146,6 +149,9 @@ class SIMPLNX_EXPORT AttributeReader
146149
*/
147150
std::string readAsString() const;
148151

152+
AttributeReader& operator=(const AttributeReader& other) = delete;
153+
AttributeReader& operator=(AttributeReader&& other) noexcept = default;
154+
149155
protected:
150156
/**
151157
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/Readers/DatasetReader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class SIMPLNX_EXPORT DatasetReader : public ObjectReader
2727
*/
2828
DatasetReader(IdType parentId, const std::string& dataName);
2929

30+
DatasetReader(const DatasetReader& other) = delete;
31+
DatasetReader(DatasetReader&& other) noexcept = default;
32+
3033
/**
3134
* @brief Releases the HDF5 dataset.
3235
*/
@@ -122,6 +125,9 @@ class SIMPLNX_EXPORT DatasetReader : public ObjectReader
122125

123126
std::string getFilterName() const;
124127

128+
DatasetReader& operator=(const DatasetReader& other) = delete;
129+
DatasetReader& operator=(DatasetReader&& other) noexcept = default;
130+
125131
protected:
126132
/**
127133
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/Readers/FileReader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class SIMPLNX_EXPORT FileReader : public GroupReader
2626
*/
2727
FileReader(IdType fileId);
2828

29+
FileReader(const FileReader& other) = delete;
30+
FileReader(FileReader&& other) noexcept = default;
31+
2932
/**
3033
* @brief Releases the HDF5 file ID.
3134
*/
@@ -38,6 +41,9 @@ class SIMPLNX_EXPORT FileReader : public GroupReader
3841
*/
3942
std::string getName() const override;
4043

44+
FileReader& operator=(const FileReader& other) = delete;
45+
FileReader& operator=(FileReader&& other) noexcept = default;
46+
4147
protected:
4248
/**
4349
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/Readers/GroupReader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class SIMPLNX_EXPORT GroupReader : public ObjectReader
1919
*/
2020
GroupReader(IdType parentId, const std::string& groupName);
2121

22+
GroupReader(const GroupReader& other) = delete;
23+
GroupReader(GroupReader&& other) noexcept = default;
24+
2225
/**
2326
* @brief Releases the wrapped HDF5 group.
2427
*/
@@ -87,6 +90,9 @@ class SIMPLNX_EXPORT GroupReader : public ObjectReader
8790
*/
8891
bool isDataset(const std::string& childName) const;
8992

93+
GroupReader& operator=(const GroupReader& other) = delete;
94+
GroupReader& operator=(GroupReader&& other) noexcept = default;
95+
9096
protected:
9197
/**
9298
* @brief Closes the HDF5 ID and resets it to 0.

src/simplnx/Utilities/Parsing/HDF5/Readers/ObjectReader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class SIMPLNX_EXPORT ObjectReader
2424
*/
2525
ObjectReader(IdType parentId, const std::string& targetName);
2626

27+
ObjectReader(const ObjectReader& other) = delete;
28+
ObjectReader(ObjectReader&& other) noexcept = default;
29+
2730
/**
2831
* @brief Releases the wrapped HDF5 object.
2932
*/
@@ -96,6 +99,9 @@ class SIMPLNX_EXPORT ObjectReader
9699
*/
97100
AttributeReader getAttributeByIdx(size_t idx) const;
98101

102+
ObjectReader& operator=(const ObjectReader& other) = delete;
103+
ObjectReader& operator=(ObjectReader&& other) noexcept = default;
104+
99105
protected:
100106
/**
101107
* @brief Constructs an ObjectReader for use in derived classes. This

0 commit comments

Comments
 (0)