File: ReadGatherStream.h

package info (click to toggle)
boxbackup 0.13~~git20200326.g8e8b63c-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,984 kB
  • sloc: xml: 70,723; cpp: 55,437; ansic: 24,659; perl: 4,844; sh: 4,292; makefile: 629; python: 311
file content (68 lines) | stat: -rw-r--r-- 1,812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// --------------------------------------------------------------------------
//
// File
//		Name:    ReadGatherStream.h
//		Purpose: Build a stream (for reading only) out of a number of other streams.
//		Created: 10/12/03
//
// --------------------------------------------------------------------------

#ifndef READGATHERSTREAM_H
#define READGATHERSTREAM_H

#include "IOStream.h"

#include <vector>

// --------------------------------------------------------------------------
//
// Class
//		Name:    ReadGatherStream
//		Purpose: Build a stream (for reading only) out of a number of other streams.
//		Created: 10/12/03
//
// --------------------------------------------------------------------------
class ReadGatherStream : public IOStream
{
public:
	ReadGatherStream(bool DeleteComponentStreamsOnDestruction);
	~ReadGatherStream();
private:
	ReadGatherStream(const ReadGatherStream &);
	ReadGatherStream &operator=(const ReadGatherStream &);
public:

	int AddComponent(IOStream *pStream);
	void AddBlock(int Component, pos_type Length, bool Seek = false, pos_type SeekTo = 0);

	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
	virtual pos_type BytesLeftToRead();
	virtual void Write(const void *pBuffer, int NBytes,
		int Timeout = IOStream::TimeOutInfinite);
	virtual bool StreamDataLeft();
	virtual bool StreamClosed();
	virtual pos_type GetPosition() const;

private:
	bool mDeleteComponentStreamsOnDestruction;
	std::vector<IOStream *> mComponents;
	
	typedef struct
	{
		pos_type mLength;
		pos_type mSeekTo;
		int mComponent;
		bool mSeek;
	} Block;
	
	std::vector<Block> mBlocks;
	
	pos_type mCurrentPosition;
	pos_type mTotalSize;
	unsigned int mCurrentBlock;
	pos_type mPositionInCurrentBlock;
	bool mSeekDoneForCurrent;
};


#endif // READGATHERSTREAM_H