| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: ReadLoggingStream.h |
|---|
| 5 | // Purpose: Wrapper around IOStreams that logs read progress |
|---|
| 6 | // Created: 2007/01/16 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef READLOGGINGSTREAM__H |
|---|
| 11 | #define READLOGGINGSTREAM__H |
|---|
| 12 | |
|---|
| 13 | #include "IOStream.h" |
|---|
| 14 | #include "BoxTime.h" |
|---|
| 15 | |
|---|
| 16 | class ReadLoggingStream : public IOStream |
|---|
| 17 | { |
|---|
| 18 | public: |
|---|
| 19 | class Logger |
|---|
| 20 | { |
|---|
| 21 | public: |
|---|
| 22 | virtual ~Logger() { } |
|---|
| 23 | virtual void Log(int64_t readSize, int64_t offset, |
|---|
| 24 | int64_t length, box_time_t elapsed, |
|---|
| 25 | box_time_t finish) = 0; |
|---|
| 26 | virtual void Log(int64_t readSize, int64_t offset, |
|---|
| 27 | int64_t length) = 0; |
|---|
| 28 | virtual void Log(int64_t readSize, int64_t offset) = 0; |
|---|
| 29 | }; |
|---|
| 30 | |
|---|
| 31 | private: |
|---|
| 32 | IOStream& mrSource; |
|---|
| 33 | IOStream::pos_type mOffset, mLength, mTotalRead; |
|---|
| 34 | box_time_t mStartTime; |
|---|
| 35 | Logger& mrLogger; |
|---|
| 36 | |
|---|
| 37 | public: |
|---|
| 38 | ReadLoggingStream(IOStream& rSource, Logger& rLogger); |
|---|
| 39 | |
|---|
| 40 | virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); |
|---|
| 41 | virtual pos_type BytesLeftToRead(); |
|---|
| 42 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 43 | virtual pos_type GetPosition() const; |
|---|
| 44 | virtual void Seek(IOStream::pos_type Offset, int SeekType); |
|---|
| 45 | virtual void Close(); |
|---|
| 46 | |
|---|
| 47 | virtual bool StreamDataLeft(); |
|---|
| 48 | virtual bool StreamClosed(); |
|---|
| 49 | |
|---|
| 50 | private: |
|---|
| 51 | ReadLoggingStream(const ReadLoggingStream &rToCopy) |
|---|
| 52 | : mrSource(rToCopy.mrSource), mrLogger(rToCopy.mrLogger) |
|---|
| 53 | { /* do not call */ } |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | #endif // READLOGGINGSTREAM__H |
|---|
| 57 | |
|---|
| 58 | |
|---|