1 #ifndef IMAGE_IO_JPEG_JPEG_SEGMENT_PROCESSOR_H_ // NOLINT 2 #define IMAGE_IO_JPEG_JPEG_SEGMENT_PROCESSOR_H_ // NOLINT 3 4 #include "image_io/jpeg/jpeg_segment.h" 5 6 namespace photos_editing_formats { 7 namespace image_io { 8 9 class JpegScanner; 10 11 /// JpegSegmentProcessor is the abstract base class for implementations that do 12 /// something with the JPEG segments that the JpegScanner identifies. 13 class JpegSegmentProcessor { 14 public: 15 virtual ~JpegSegmentProcessor() = default; 16 17 /// This function is called at the start of the JPegScanner::Run() function to 18 /// allow this JpegProcessor to initialize its data structures. It can also 19 /// inform the JpegScanner about preferences for the types of segments it is 20 /// interested in by calling the JpegScanner::UpdateInterestingMarkerFlags() 21 /// function. 22 /// @param scanner The scanner that is starting the JpegProcessor. 23 virtual void Start(JpegScanner* scanner) = 0; 24 25 /// This function is called repeatedly by the JpegScanner as it identifies 26 /// segments in the JPEG file. The JpegProcessor can access the data in the 27 /// segment to do interesting things, or can update the scanner's preferences 28 /// like in the Start() function. 29 /// @param scanner The scanner that is providing the segment to the processor. 30 /// @param segment The segment provided by the scanner to the processor. 31 virtual void Process(JpegScanner* scanner, const JpegSegment& segment) = 0; 32 33 /// This function is called after the JpegScanner has provided all the 34 /// segments to the JpegProcessor to allow the processor to finish its work 35 /// processing the segments. 36 /// @param scanner The scanner that is informing the processor that it is done 37 /// finding segments. 38 virtual void Finish(JpegScanner* scanner) = 0; 39 }; 40 41 } // namespace image_io 42 } // namespace photos_editing_formats 43 44 #endif // IMAGE_IO_JPEG_JPEG_SEGMENT_PROCESSOR_H_ // NOLINT 45