diff --git a/src/abstractreader.h b/src/abstractreader.h --- a/src/abstractreader.h +++ b/src/abstractreader.h @@ -1,5 +1,5 @@ /* - Copyright © 2018 Hasan Yavuz Özderya + Copyright © 2019 Hasan Yavuz Özderya This file is part of serialplot. @@ -63,12 +63,25 @@ public slots: void pause(bool enabled); protected: + /// Reader should read from this device in `readData()` function. QIODevice* _device; + + /// Reader should check this variable to determine if reading is + /// paused in `readData()` bool paused; -protected slots: - /// all derived readers has to override this function - virtual void onDataReady() = 0; + /** + * Called when `readyRead` is signaled by the device. This is + * where the implementors should read the data and return the + * exact number of bytes read from the device. + */ + virtual unsigned readData() = 0; + +private: + unsigned numBytesRead; + +private slots: + void onDataReady(); }; #endif // ABSTRACTREADER_H