X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FForwardSwitch.cci;h=9447bab19ca0ff640c37e9304bbc946deaa0842c;hb=ee01b9007d97c64d0a34b91a3dc87ad5c5697df5;hp=c292dcc1f3e7b7c774b127a10969ba05c800b9c6;hpb=0738966edad9188ad34d23b59bb284749e52150b;p=senf.git diff --git a/PPI/ForwardSwitch.cci b/PPI/ForwardSwitch.cci index c292dcc..9447bab 100644 --- a/PPI/ForwardSwitch.cci +++ b/PPI/ForwardSwitch.cci @@ -20,31 +20,40 @@ #include "ForwardSwitch.hh" -#define prefix_ +#define prefix_ inline -prefix_ ForwardSwitch::ForwardSwitch(bool state) +prefix_ senf::ppi::module::ForwardSwitch::ForwardSwitch(bool state) + :forward_(state) { route( input, output ); input.onRequest( &ForwardSwitch::onRequest ); - forward_ = state; } -prefix_ bool ForwardSwitch::forward(){ - return forward_; +prefix_ void senf::ppi::module::ForwardSwitch::onRequest() +{ + if(forward_){ + output.write(input.read()); + } else { + input.read(); // and discard automatically + } } -prefix_ bool ForwardSwitch::forward(bool state){ - forward_ = state; - return state; +prefix_ bool senf::ppi::module::ForwardSwitch::forward(){ + return forward_; +} + +prefix_ bool senf::ppi::module::ForwardSwitch::forward(bool state){ + forward_ = state; + return state; } -prefix_ void ForwardSwitch::stopForwarding(){ - return forward(false); +prefix_ bool senf::ppi::module::ForwardSwitch::stopForwarding(){ + return forward(false); } -prefix_ void ForwardSwitch::startForwarding(){ - return forward(true); +prefix_ bool senf::ppi::module::ForwardSwitch::startForwarding(){ + return forward(true); } #undef prefix_