Skip to content

Commit

Permalink
SWIG bindings need the shared_ptr overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith authored and Dan Smith committed Apr 19, 2023
1 parent 2c3cc23 commit a3c86f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion six/modules/c++/cphd/include/cphd/DataWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct DataWriter
* \param stream The seekable output stream to be written
* \param numThreads Number of threads for parallel processing
*/
DataWriter(io::OutputStream& stream, size_t numThreads);
DataWriter(io::OutputStream&, size_t numThreads);

DataWriter() = delete;
DataWriter(const DataWriter&) = delete;
Expand Down Expand Up @@ -96,6 +96,7 @@ struct DataWriterLittleEndian final : public DataWriter
* \param scratchSize Size of buffer to be used for scratch space
*/
DataWriterLittleEndian(io::OutputStream&, size_t numThreads, size_t scratchSize);
DataWriterLittleEndian(std::shared_ptr<io::SeekableOutputStream>&, size_t numThreads, size_t scratchSize); // for SWIG
DataWriterLittleEndian() = delete;
DataWriterLittleEndian(const DataWriterLittleEndian&) = delete;
DataWriterLittleEndian& operator=(const DataWriterLittleEndian&) = delete;
Expand Down Expand Up @@ -135,6 +136,7 @@ struct DataWriterBigEndian final : public DataWriter
* \param numThreads Number of threads for parallel processing
*/
DataWriterBigEndian(io::OutputStream&, size_t numThreads);
DataWriterBigEndian(std::shared_ptr<io::SeekableOutputStream>&, size_t numThreads); // for SWIG
DataWriterBigEndian() = delete;
DataWriterBigEndian(const DataWriterBigEndian&) = delete;
DataWriterBigEndian& operator=(const DataWriterBigEndian&) = delete;
Expand Down
11 changes: 11 additions & 0 deletions six/modules/c++/cphd/source/DataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ DataWriterLittleEndian::DataWriterLittleEndian(
mScratch(scratchSize)
{
}
DataWriterLittleEndian::DataWriterLittleEndian(
std::shared_ptr<io::SeekableOutputStream>& stream,
size_t numThreads,
size_t scratchSize) : DataWriterLittleEndian(*stream, numThreads, scratchSize)
{
}
void DataWriterLittleEndian::operator()(const void* pData, size_t numElements, size_t elementSize)
{
const auto data = static_cast<const sys::ubyte*>(pData);
Expand Down Expand Up @@ -75,6 +81,11 @@ DataWriterBigEndian::DataWriterBigEndian(io::OutputStream& stream, size_t numThr
DataWriter(stream, numThreads)
{
}
DataWriterBigEndian::DataWriterBigEndian(
std::shared_ptr<io::SeekableOutputStream>& stream,
size_t numThreads) : DataWriterBigEndian(*stream, numThreads)
{
}
void DataWriterBigEndian::operator()(const void* data, size_t numElements, size_t elementSize)
{
mStream.write(data, numElements * elementSize);
Expand Down

0 comments on commit a3c86f1

Please sign in to comment.