From 970541028bfe65036cb36ab203bb66e7777a66ca Mon Sep 17 00:00:00 2001
From: tho <tho@wiback.org>
Date: Tue, 17 Mar 2009 14:08:11 +0000
Subject: [PATCH] PPI/RateFilter: added interval getter

---
 PPI/Jack.test.cc                   |  2 +-
 PPI/RateFilter.cc                  | 39 ++++++++++++++++++++++++------
 PPI/RateFilter.hh                  | 36 +++++++++++++++++++++------
 Socket/NetdeviceController.test.cc |  6 +++++
 4 files changed, 67 insertions(+), 16 deletions(-)

diff --git a/PPI/Jack.test.cc b/PPI/Jack.test.cc
index 939d48534..10a20e367 100644
--- a/PPI/Jack.test.cc
+++ b/PPI/Jack.test.cc
@@ -21,7 +21,7 @@
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief Jack.test unit tests */
+    \brief Jack unit tests */
 
 //#include "Jack.test.hh"
 //#include "Jack.test.ih"
diff --git a/PPI/RateFilter.cc b/PPI/RateFilter.cc
index 71fc28ab1..c9b4793be 100644
--- a/PPI/RateFilter.cc
+++ b/PPI/RateFilter.cc
@@ -19,21 +19,23 @@
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief ppitest non-inline non-template implementation */
+    \brief RateFilter non-inline non-template implementation */
 
 #include "RateFilter.hh"
+//#include "RateFilter.ih"
 
-#define prefix_
-// ////////////////////////////////////////////////////////////////////////
-// RateFilter
+// Custom includes
 
+//#include "RateFilter.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
 
 senf::ppi::module::RateFilter::RateFilter(senf::ClockService::clock_type interval)
-    : timer(interval) 
+    : timer_(interval) 
 {
-    route(input,timer);
-    route(timer,output);
-    registerEvent(timer, &RateFilter::timeout);
+    route(input, timer_);
+    route(timer_, output);
+    registerEvent(timer_, &RateFilter::timeout);
 }
 
 void senf::ppi::module::RateFilter::timeout()
@@ -41,6 +43,12 @@ void senf::ppi::module::RateFilter::timeout()
     output(input());
 }
 
+senf::ClockService::clock_type senf::ppi::module::RateFilter::interval()
+    const
+{
+    return timer_.interval().first;
+}
+
 
 /*  this should be what should happen. but _this_ most likely won't work
 void senf::ppi::module::RateFilter::changeInterval(senf::ClockService::clock_type interval)
@@ -48,3 +56,18 @@ void senf::ppi::module::RateFilter::changeInterval(senf::ClockService::clock_typ
     //timer = ppi::IntervalTimer(interval);
 }
 */
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "RateFilter.mpp"
+
+
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
diff --git a/PPI/RateFilter.hh b/PPI/RateFilter.hh
index bd681701a..9877124b3 100644
--- a/PPI/RateFilter.hh
+++ b/PPI/RateFilter.hh
@@ -17,14 +17,20 @@
 // 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 RateFilter public header */
+
 #ifndef HH_SENF_PPI_RateFilter_
-#define HH_SENF_PPI_RateFilter_
+#define HH_SENF_PPI_RateFilter_ 1
 
 // Custom includes
 #include "Connectors.hh"
 #include "Module.hh"
 #include "IntervalTimer.hh"
 
+//#include "RateFilter.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
 
 namespace senf {
 namespace ppi {
@@ -34,19 +40,35 @@ class RateFilter
     : public Module
 {
     SENF_PPI_MODULE(RateFilter);
-public:
-
-    connector::ActiveInput<> input;
-    connector::ActiveOutput<> output;
 
+public:
     RateFilter(senf::ClockService::clock_type interval);
 //    void changeInterval(senf::ClockService::clock_type interval);   not yet implemented!
+    senf::ClockService::clock_type interval() const;
+    
+    connector::ActiveInput<> input;
+    connector::ActiveOutput<> output;
 
 private:
     void timeout();
-    ppi::IntervalTimer timer;
+    ppi::IntervalTimer timer_;
 };
 
 }}} //namespaces
 
-#endif /*HH_SENF_PPI_RateFilter_*/
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "RateFilter.cci"
+//#include "RateFilter.ct"
+//#include "RateFilter.cti"
+#endif
+
+
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End:
diff --git a/Socket/NetdeviceController.test.cc b/Socket/NetdeviceController.test.cc
index 8b3725016..dcc8a3bc0 100644
--- a/Socket/NetdeviceController.test.cc
+++ b/Socket/NetdeviceController.test.cc
@@ -41,6 +41,11 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
     senf::NetdeviceController ctrl ("lo");
     BOOST_CHECK_EQUAL( ctrl.interfaceName(), "lo");
 
+    int index = ctrl.interfaceIndex();
+    BOOST_CHECK_EQUAL( index, senf::NetdeviceController(index).interfaceIndex() );
+    
+    BOOST_CHECK_THROW( senf::NetdeviceController("invalid_interfacename"), senf::SystemException );
+    
     int oldMTU;
     SENF_CHECK_NO_THROW( oldMTU = ctrl.mtu());
 
@@ -53,6 +58,7 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
     BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU-16);
     SENF_CHECK_NO_THROW( ctrl.mtu(oldMTU));
     BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU);
+    
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
-- 
GitLab