diff options
Diffstat (limited to 'src/streamstack.h')
-rw-r--r-- | src/streamstack.h | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/src/streamstack.h b/src/streamstack.h index 03d8d8f..89e683d 100644 --- a/src/streamstack.h +++ b/src/streamstack.h | |||
@@ -3,14 +3,99 @@ | |||
3 | 3 | ||
4 | #include "bu/stream.h" | 4 | #include "bu/stream.h" |
5 | 5 | ||
6 | #include <typeinfo> | ||
7 | |||
6 | namespace Bu | 8 | namespace Bu |
7 | { | 9 | { |
8 | class StreamStack : public Bu::Stream | 10 | class StreamStack : public Bu::Stream |
9 | { | 11 | { |
12 | private: | ||
13 | typedef Bu::List<Bu::Stream *> FilterList; | ||
14 | |||
10 | public: | 15 | public: |
11 | StreamStack(); | 16 | StreamStack(); |
17 | StreamStack( Bu::Stream *pStream ); | ||
12 | virtual ~StreamStack(); | 18 | virtual ~StreamStack(); |
13 | 19 | ||
20 | bool isEmpty(); | ||
21 | bool hasStream(); | ||
22 | void setStream( Bu::Stream *pStream ); | ||
23 | |||
24 | void clearStack(); | ||
25 | void popFilter(); | ||
26 | Bu::Stream *getTop(); | ||
27 | |||
28 | Bu::Stream *getStream(); | ||
29 | |||
30 | template<typename filter> | ||
31 | Bu::Stream *findFilter() | ||
32 | { | ||
33 | for( FilterList::iterator i = lFilts.begin(); i; i++ ) | ||
34 | { | ||
35 | if( typeid(**i) == typeid( filter ) ) | ||
36 | { | ||
37 | return *i; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | throw Bu::ExceptionBase("Filter not found."); | ||
42 | } | ||
43 | |||
44 | template<typename filter> | ||
45 | void pushFilter() | ||
46 | { | ||
47 | checkStack(); | ||
48 | |||
49 | filter *pFlt = new filter( *lFilts.first() ); | ||
50 | lFilts.prepend( pFlt ); | ||
51 | } | ||
52 | |||
53 | template<typename filter, typename p1t> | ||
54 | void pushFilter( p1t p1 ) | ||
55 | { | ||
56 | checkStack(); | ||
57 | |||
58 | filter *pFlt = new filter( *lFilts.first(), p1 ); | ||
59 | lFilts.prepend( pFlt ); | ||
60 | } | ||
61 | |||
62 | template<typename filter, typename p1t, typename p2t> | ||
63 | void pushFilter( p1t p1, p2t p2 ) | ||
64 | { | ||
65 | checkStack(); | ||
66 | |||
67 | filter *pFlt = new filter( *lFilts.first(), p1, p2 ); | ||
68 | lFilts.prepend( pFlt ); | ||
69 | } | ||
70 | |||
71 | template<typename filter, typename p1t, typename p2t, typename p3t> | ||
72 | void pushFilter( p1t p1, p2t p2, p3t p3 ) | ||
73 | { | ||
74 | checkStack(); | ||
75 | |||
76 | filter *pFlt = new filter( *lFilts.first(), p1, p2, p3 ); | ||
77 | lFilts.prepend( pFlt ); | ||
78 | } | ||
79 | |||
80 | template<typename filter, typename p1t, typename p2t, typename p3t, | ||
81 | typename p4t> | ||
82 | void pushFilter( p1t p1, p2t p2, p3t p3, p4t p4 ) | ||
83 | { | ||
84 | checkStack(); | ||
85 | |||
86 | filter *pFlt = new filter( *lFilts.first(), p1, p2, p3, p4 ); | ||
87 | lFilts.prepend( pFlt ); | ||
88 | } | ||
89 | |||
90 | template<typename filter, typename p1t, typename p2t, typename p3t, | ||
91 | typename p4t, typename p5t> | ||
92 | void pushFilter( p1t p1, p2t p2, p3t p3, p4t p4, p5t p5 ) | ||
93 | { | ||
94 | checkStack(); | ||
95 | |||
96 | filter *pFlt = new filter( *lFilts.first(), p1, p2, p3, p4, p5 ); | ||
97 | lFilts.prepend( pFlt ); | ||
98 | } | ||
14 | 99 | ||
15 | // | 100 | // |
16 | // Everything below here merely passes on the call to the top of the | 101 | // Everything below here merely passes on the call to the top of the |
@@ -39,7 +124,9 @@ namespace Bu | |||
39 | virtual void setSize( long iSize ); | 124 | virtual void setSize( long iSize ); |
40 | 125 | ||
41 | private: | 126 | private: |
42 | typedef Bu::List<Bu::Stream *> FilterList; | 127 | void checkStack(); |
128 | |||
129 | private: | ||
43 | FilterList lFilts; | 130 | FilterList lFilts; |
44 | }; | 131 | }; |
45 | }; | 132 | }; |