| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: ReadGatherStream.h |
|---|
| 5 | // Purpose: Build a stream (for reading only) out of a number of other streams. |
|---|
| 6 | // Created: 10/12/03 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef READGATHERSTREAM_H |
|---|
| 11 | #define READGATHERSTREAM_H |
|---|
| 12 | |
|---|
| 13 | #include "IOStream.h" |
|---|
| 14 | |
|---|
| 15 | #include <vector> |
|---|
| 16 | |
|---|
| 17 | // -------------------------------------------------------------------------- |
|---|
| 18 | // |
|---|
| 19 | // Class |
|---|
| 20 | // Name: ReadGatherStream |
|---|
| 21 | // Purpose: Build a stream (for reading only) out of a number of other streams. |
|---|
| 22 | // Created: 10/12/03 |
|---|
| 23 | // |
|---|
| 24 | // -------------------------------------------------------------------------- |
|---|
| 25 | class ReadGatherStream : public IOStream |
|---|
| 26 | { |
|---|
| 27 | public: |
|---|
| 28 | ReadGatherStream(bool DeleteComponentStreamsOnDestruction); |
|---|
| 29 | ~ReadGatherStream(); |
|---|
| 30 | private: |
|---|
| 31 | ReadGatherStream(const ReadGatherStream &); |
|---|
| 32 | ReadGatherStream &operator=(const ReadGatherStream &); |
|---|
| 33 | public: |
|---|
| 34 | |
|---|
| 35 | int AddComponent(IOStream *pStream); |
|---|
| 36 | void AddBlock(int Component, pos_type Length, bool Seek = false, pos_type SeekTo = 0); |
|---|
| 37 | |
|---|
| 38 | virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); |
|---|
| 39 | virtual pos_type BytesLeftToRead(); |
|---|
| 40 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 41 | virtual bool StreamDataLeft(); |
|---|
| 42 | virtual bool StreamClosed(); |
|---|
| 43 | virtual pos_type GetPosition() const; |
|---|
| 44 | |
|---|
| 45 | private: |
|---|
| 46 | bool mDeleteComponentStreamsOnDestruction; |
|---|
| 47 | std::vector<IOStream *> mComponents; |
|---|
| 48 | |
|---|
| 49 | typedef struct |
|---|
| 50 | { |
|---|
| 51 | pos_type mLength; |
|---|
| 52 | pos_type mSeekTo; |
|---|
| 53 | int mComponent; |
|---|
| 54 | bool mSeek; |
|---|
| 55 | } Block; |
|---|
| 56 | |
|---|
| 57 | std::vector<Block> mBlocks; |
|---|
| 58 | |
|---|
| 59 | pos_type mCurrentPosition; |
|---|
| 60 | pos_type mTotalSize; |
|---|
| 61 | unsigned int mCurrentBlock; |
|---|
| 62 | pos_type mPositionInCurrentBlock; |
|---|
| 63 | bool mSeekDoneForCurrent; |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | #endif // READGATHERSTREAM_H |
|---|