3 This file is part of libmspio
4 Copyright © 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_IO_FILTERED_H_
9 #define MSP_IO_FILTERED_H_
14 template<typename B, typename F>
15 class Filtered: public B
22 Activator(Filtered &f_): f(f_) { f.active=true; }
23 ~Activator() { f.active=false; }
30 Filtered(): filter(*this), active(false) { }
33 Filtered(A0 a0): B(a0), filter(*this), active(false) { }
35 template<typename A0, typename A1>
36 Filtered(A0 a0, A1 a1): B(a0, a1), filter(*this), active(false) { }
38 F &get_filter() { return filter; }
40 virtual unsigned do_write(const char *b, unsigned s)
45 return filter.write(b, s);
48 return B::do_write(b, s);
51 virtual unsigned do_read(char *b, unsigned s)
56 return filter.read(b, s);
59 return B::do_read(b, s);