diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-04-28 17:30:58 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-04-28 17:30:58 +0000 |
commit | 69c959cea39474dc66a1de128ce89af983882f67 (patch) | |
tree | 836070e732b804ee6709106d102c0bcd22fe26c7 /lib/common/ReadLoggingStream.h | |
parent | 9362fdfa7b8f2639a2ec5290b38e2e9c9ea8483b (diff) |
Add a stream which logs progress of reading data from another (child)
stream, and estimated time of completion, useful for upload progress
monitoring. (refs #3)
Diffstat (limited to 'lib/common/ReadLoggingStream.h')
-rw-r--r-- | lib/common/ReadLoggingStream.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/common/ReadLoggingStream.h b/lib/common/ReadLoggingStream.h new file mode 100644 index 00000000..15c3ef48 --- /dev/null +++ b/lib/common/ReadLoggingStream.h @@ -0,0 +1,43 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: ReadLoggingStream.h +// Purpose: Wrapper around IOStreams that logs read progress +// Created: 2007/01/16 +// +// -------------------------------------------------------------------------- + +#ifndef READLOGGINGSTREAM__H +#define READLOGGINGSTREAM__H + +#include "IOStream.h" +#include "BoxTime.h" + +class ReadLoggingStream : public IOStream +{ +private: + IOStream& mrSource; + IOStream::pos_type mOffset, mLength, mTotalRead; + box_time_t mStartTime; + +public: + ReadLoggingStream(IOStream& rSource); + + virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); + virtual pos_type BytesLeftToRead(); + virtual void Write(const void *pBuffer, int NBytes); + virtual pos_type GetPosition() const; + virtual void Seek(IOStream::pos_type Offset, int SeekType); + virtual void Close(); + + virtual bool StreamDataLeft(); + virtual bool StreamClosed(); + +private: + ReadLoggingStream(const ReadLoggingStream &rToCopy) + : mrSource(rToCopy.mrSource) { /* do not call */ } +}; + +#endif // READLOGGINGSTREAM__H + + |