summaryrefslogtreecommitdiffstats
path: root/includes/image_io/base/istream_data_source.h
diff options
context:
space:
mode:
Diffstat (limited to 'includes/image_io/base/istream_data_source.h')
-rw-r--r--includes/image_io/base/istream_data_source.h30
1 files changed, 6 insertions, 24 deletions
diff --git a/includes/image_io/base/istream_data_source.h b/includes/image_io/base/istream_data_source.h
index 4564e14..9b87542 100644
--- a/includes/image_io/base/istream_data_source.h
+++ b/includes/image_io/base/istream_data_source.h
@@ -1,46 +1,28 @@
#ifndef IMAGE_IO_BASE_ISTREAM_DATA_SOURCE_H_ // NOLINT
#define IMAGE_IO_BASE_ISTREAM_DATA_SOURCE_H_ // NOLINT
-#include <iostream>
#include <memory>
#include <utility>
-#include "image_io/base/data_source.h"
+#include "image_io/base/istream_ref_data_source.h"
namespace photos_editing_formats {
namespace image_io {
-/// A DataSource that obtains data from an istream.
-class IStreamDataSource : public DataSource {
+/// A DataSource that obtains data from an istream that it owns.
+class IStreamDataSource : public IStreamRefDataSource {
public:
/// Constructs an IStreamDataSource using the given istream.
/// @param istram_ptr The istream from which to read.
explicit IStreamDataSource(std::unique_ptr<std::istream> istream_ptr)
- : istream_(std::move(istream_ptr)) {}
-
- void Reset() override;
- std::shared_ptr<DataSegment> GetDataSegment(size_t begin,
- size_t min_size) override;
- TransferDataResult TransferData(const DataRange& data_range, size_t best_size,
- DataDestination* data_destination) override;
-
- private:
- /// The worker function to create a DataSegment and fill it with the given
- /// number of bytes read from the istream, starting at the given location.
- /// @param begin The location in the istream at which to start reading.
- /// @param count The number of bytes to read.
- /// @return A DataSegment pointer, or nullptr if the read failed.
- std::shared_ptr<DataSegment> Read(size_t begin, size_t count);
+ : IStreamRefDataSource(*istream_ptr), istream_(std::move(istream_ptr)) {}
private:
- /// The istream from which to read.
+ /// The istream that is owned by this data source.
std::unique_ptr<std::istream> istream_;
-
- /// The current data segment that was read in the GetDataSegment() function.
- std::shared_ptr<DataSegment> current_data_segment_;
};
} // namespace image_io
} // namespace photos_editing_formats
-#endif // IMAGE_IO_BASE_ISTREAM_DATA_SOURCE_H_ // NOLINT
+#endif // IMAGE_IO_BASE_ISTREAM_DATA_SOURCE_H_ // NOLINT