• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef IMAGE_IO_BASE_DATA_SEGMENT_DATA_SOURCE_H_  // NOLINT
2 #define IMAGE_IO_BASE_DATA_SEGMENT_DATA_SOURCE_H_  // NOLINT
3 
4 #include "image_io/base/data_source.h"
5 
6 namespace photos_editing_formats {
7 namespace image_io {
8 
9 /// DataSegmentDataSource is an implementation of DataSource that provides
10 /// access to requested DataSegment instances from a single (possibly large)
11 /// in-memory DataSegment.
12 class DataSegmentDataSource : public DataSource {
13  public:
DataSegmentDataSource(const std::shared_ptr<DataSegment> & shared_data_segment)14   explicit DataSegmentDataSource(
15       const std::shared_ptr<DataSegment>& shared_data_segment)
16       : shared_data_segment_(shared_data_segment) {}
17   void Reset() override;
18   std::shared_ptr<DataSegment> GetDataSegment(size_t begin,
19                                               size_t min_size) override;
20   TransferDataResult TransferData(const DataRange& data_range, size_t best_size,
21                                   DataDestination* data_destination) override;
22 
23  private:
24   std::shared_ptr<DataSegment> shared_data_segment_;
25 };
26 
27 }  // namespace image_io
28 }  // namespace photos_editing_formats
29 
30 #endif // IMAGE_IO_BASE_DATA_SEGMENT_DATA_SOURCE_H_  // NOLINT
31