From: dw6 Date: Wed, 9 Apr 2008 16:28:06 +0000 (+0000) Subject: add on-off switch module. X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0738966edad9188ad34d23b59bb284749e52150b;p=senf.git add on-off switch module. git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@795 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/ForwardSwitch.cci b/PPI/ForwardSwitch.cci new file mode 100644 index 0000000..c292dcc --- /dev/null +++ b/PPI/ForwardSwitch.cci @@ -0,0 +1,51 @@ +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// David Wagner +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "ForwardSwitch.hh" + +#define prefix_ + +prefix_ ForwardSwitch::ForwardSwitch(bool state) +{ + route( input, output ); + input.onRequest( &ForwardSwitch::onRequest ); + forward_ = state; +} + +prefix_ bool ForwardSwitch::forward(){ + return forward_; +} + +prefix_ bool ForwardSwitch::forward(bool state){ + forward_ = state; + return state; +} + +prefix_ void ForwardSwitch::stopForwarding(){ + return forward(false); +} + + +prefix_ void ForwardSwitch::startForwarding(){ + return forward(true); +} + +#undef prefix_ + diff --git a/PPI/ForwardSwitch.hh b/PPI/ForwardSwitch.hh new file mode 100644 index 0000000..4d21415 --- /dev/null +++ b/PPI/ForwardSwitch.hh @@ -0,0 +1,52 @@ +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// David Wagner +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef FORWARDSWITCH_HH_ +#define FORWARDSWITCH_HH_ + +// Custom includes +#include "Connectors.hh" +#include "Module.hh" + +namespace senf { +namespace ppi { +namespace module { + +class ForwardSwitch + : public Module +{ + SENF_PPI_MODULE(ForwardSwitch); +public: + + connector::ActiveInput<> input; + connector::ActiveOutput<> output; + + ForwardSwitch(bool state); + +private: + bool forward_; + bool forward(); + bool forward(bool state); + void stopForwarding(); + void startForwarding(); +}; + +}}} //namespaces +#endif /*FORWARDSWITCH_HH_*/