summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/unstable/dualfilter.cpp8
-rw-r--r--src/unstable/dualfilter.h67
2 files changed, 75 insertions, 0 deletions
diff --git a/src/unstable/dualfilter.cpp b/src/unstable/dualfilter.cpp
new file mode 100644
index 0000000..8d019de
--- /dev/null
+++ b/src/unstable/dualfilter.cpp
@@ -0,0 +1,8 @@
1/*
2 * Copyright (C) 2007-2013 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#include "dualfilter.h"
diff --git a/src/unstable/dualfilter.h b/src/unstable/dualfilter.h
new file mode 100644
index 0000000..ce6a13a
--- /dev/null
+++ b/src/unstable/dualfilter.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2007-2013 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_DUAL_FILTER_H
9#define BU_DUAL_FILTER_H
10
11#include "bu/filter.h"
12
13namespace Bu
14{
15 template<typename Flt>
16 class DualFilter : public Bu::Filter
17 {
18 public:
19 DualFilter( Bu::Stream &rNext ) :
20 Bu::Filter( rNext ),
21 fRead( rNext ),
22 fWrite( rNext )
23 {
24 }
25
26 virtual ~DualFilter()
27 {
28 }
29
30 virtual void start()
31 {
32 fRead.start();
33 fWrite.start();
34 }
35
36 virtual Bu::size stop()
37 {
38 return fRead.stop() + fWrite.stop();
39 }
40
41 virtual void close()
42 {
43 Bu::Filter::close();
44 fRead.close();
45 fWrite.close();
46 }
47
48 virtual Bu::size read( void *pBuf, Bu::size iBytes )
49 {
50 return fRead.read( pBuf, iBytes );
51 }
52
53 virtual Bu::size write( void *pBuf, Bu::size iBytes )
54 {
55 return fWrite.write( pBuf, iBytes );
56 }
57
58 Flt &getReadFilter() { return fRead; }
59 Flt &getWriteFilter() { return fWrite; }
60
61 private:
62 Flt fRead;
63 Flt fWrite;
64 };
65};
66
67#endif