From: dw6 Date: Tue, 15 Jan 2008 16:38:18 +0000 (+0000) Subject: add a class for a ratefilter X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=aed52b6070e9f7d95efad9de84a41e5ea7413255;p=senf.git add a class for a ratefilter git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@606 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/RateFilter.cc b/PPI/RateFilter.cc new file mode 100644 index 0000000..00e4568 --- /dev/null +++ b/PPI/RateFilter.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// 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. + +/** \file + \brief ppitest non-inline non-template implementation */ + +#include "RateFilter.hh" + +#define prefix_ +// //////////////////////////////////////////////////////////////////////// +// RateFilter + + +senf::ppi::module::RateFilter::RateFilter(senf::ClockService::clock_type interval) + : timer(interval) +{ + route(input,timer); + route(timer,output); + registerEvent(timer, &RateFilter::timeout); +} + +void senf::ppi::module::RateFilter::timeout() +{ + output(input()); +} + + +/* this should be what should happen. but _this_ most likely won't work +void senf::ppi::module::RateFilter::changeInterval(senf::ClockService::clock_type interval) +{ + //timer = ppi::IntervalTimer(interval); +} +*/ \ No newline at end of file diff --git a/PPI/RateFilter.hh b/PPI/RateFilter.hh new file mode 100644 index 0000000..3cc9c3b --- /dev/null +++ b/PPI/RateFilter.hh @@ -0,0 +1,52 @@ +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// 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 RATEFILTER_HH_ +#define RATEFILTER_HH_ + +// Custom includes +#include "Connectors.hh" +#include "Module.hh" +#include "IntervalTimer.hh" + + +namespace senf { +namespace ppi { +namespace module { + +class RateFilter + : public Module +{ + SENF_PPI_MODULE(RateFilter); +public: + + connector::ActiveInput input; + connector::ActiveOutput output; + + RateFilter(senf::ClockService::clock_type interval); +// void changeInterval(senf::ClockService::clock_type interval); not yet implemented! + +private: + void timeout(); + ppi::IntervalTimer timer; +}; + +}}} //namespaces + +#endif /*RATEFILTER_HH_*/