diff options
Diffstat (limited to '')
-rw-r--r-- | src/unstable/teestream.cpp | 117 | ||||
-rw-r--r-- | src/unstable/teestream.h | 65 |
2 files changed, 182 insertions, 0 deletions
diff --git a/src/unstable/teestream.cpp b/src/unstable/teestream.cpp new file mode 100644 index 0000000..52802ef --- /dev/null +++ b/src/unstable/teestream.cpp | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | Bu::TeeStream::* Copyright (C) 2007-2014 Xagasoft, All rights reserved. | ||
3 | Bu::TeeStream::* | ||
4 | Bu::TeeStream::* This file is part of the libbu++ library and is released under the | ||
5 | Bu::TeeStream::* terms of the license contained in the file LICENSE. | ||
6 | Bu::TeeStream::*/ | ||
7 | |||
8 | #include "bu/teestream.h" | ||
9 | |||
10 | Bu::TeeStream::TeeStream() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::TeeStream::~TeeStream() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void Bu::TeeStream::addStream( Bu::Stream &rStream ) | ||
19 | { | ||
20 | lStream.append( StreamWrapper( rStream ) ); | ||
21 | } | ||
22 | |||
23 | #define delegate \ | ||
24 | for( StreamRefList::iterator i = lStream.begin(); i; i++ ) \ | ||
25 | (*i).rStream | ||
26 | |||
27 | void Bu::TeeStream::close() | ||
28 | { | ||
29 | delegate.close(); | ||
30 | } | ||
31 | |||
32 | Bu::size Bu::TeeStream::tell() | ||
33 | { | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | void Bu::TeeStream::seek( Bu::size ) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | void Bu::TeeStream::setPos( Bu::size ) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | void Bu::TeeStream::setPosEnd( Bu::size ) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | bool Bu::TeeStream::isEos() | ||
50 | { | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | bool Bu::TeeStream::isOpen() | ||
55 | { | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | void Bu::TeeStream::flush() | ||
60 | { | ||
61 | delegate.flush(); | ||
62 | } | ||
63 | |||
64 | bool Bu::TeeStream::canRead() | ||
65 | { | ||
66 | return false; | ||
67 | } | ||
68 | |||
69 | bool Bu::TeeStream::canWrite() | ||
70 | { | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | bool Bu::TeeStream::isReadable() | ||
75 | { | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | bool Bu::TeeStream::isWritable() | ||
80 | { | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | bool Bu::TeeStream::isSeekable() | ||
85 | { | ||
86 | return false; | ||
87 | } | ||
88 | |||
89 | bool Bu::TeeStream::isBlocking() | ||
90 | { | ||
91 | return true; | ||
92 | } | ||
93 | |||
94 | void Bu::TeeStream::setBlocking( bool bBlocking ) | ||
95 | { | ||
96 | delegate.setBlocking( bBlocking ); | ||
97 | } | ||
98 | |||
99 | void Bu::TeeStream::setSize( Bu::size ) | ||
100 | { | ||
101 | } | ||
102 | |||
103 | Bu::size Bu::TeeStream::getSize() const | ||
104 | { | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | Bu::size Bu::TeeStream::getBlockSize() const | ||
109 | { | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | Bu::String Bu::TeeStream::getLocation() const | ||
114 | { | ||
115 | return "Invalid"; | ||
116 | } | ||
117 | |||
diff --git a/src/unstable/teestream.h b/src/unstable/teestream.h new file mode 100644 index 0000000..f7287f1 --- /dev/null +++ b/src/unstable/teestream.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2014 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_TEE_STREAM_H | ||
9 | #define BU_TEE_STREAM_H | ||
10 | |||
11 | #include "bu/filter.h" | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | class TeeStream : public Bu::Stream | ||
16 | { | ||
17 | public: | ||
18 | TeeStream(); | ||
19 | virtual ~TeeStream(); | ||
20 | |||
21 | void addStream( Bu::Stream &rStream ); | ||
22 | |||
23 | virtual void close(); | ||
24 | virtual Bu::size tell(); | ||
25 | virtual void seek( Bu::size offset ); | ||
26 | virtual void setPos( Bu::size pos ); | ||
27 | virtual void setPosEnd( Bu::size pos ); | ||
28 | virtual bool isEos(); | ||
29 | virtual bool isOpen(); | ||
30 | |||
31 | virtual void flush(); | ||
32 | |||
33 | virtual bool canRead(); | ||
34 | virtual bool canWrite(); | ||
35 | |||
36 | virtual bool isReadable(); | ||
37 | virtual bool isWritable(); | ||
38 | virtual bool isSeekable(); | ||
39 | |||
40 | virtual bool isBlocking(); | ||
41 | virtual void setBlocking( bool bBlocking=true ); | ||
42 | |||
43 | /** | ||
44 | * Most filters won't re-implement this, it doesn't make a lot of sense | ||
45 | * for filters, in general. | ||
46 | */ | ||
47 | virtual void setSize( Bu::size iSize ); | ||
48 | |||
49 | virtual size getSize() const; | ||
50 | virtual size getBlockSize() const; | ||
51 | virtual Bu::String getLocation() const; | ||
52 | |||
53 | private: | ||
54 | class StreamWrapper | ||
55 | { | ||
56 | public: | ||
57 | StreamWrapper( Bu::Stream &r ) : rStream( r ) { } | ||
58 | Bu::Stream &rStream; | ||
59 | }; | ||
60 | typedef Bu::List<StreamWrapper> StreamRefList; | ||
61 | StreamRefList lStream; | ||
62 | }; | ||
63 | } | ||
64 | |||
65 | #endif | ||