PPI/Ratefilter: added interval setter and unit tests
[senf.git] / PPI / IOEvent.cti
index 549bd47..5f36a06 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institute for Open Communication Systems (FOKUS) 
-// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -26,6 +26,7 @@
 //#include "IOEvent.ih"
 
 // Custom includes
+#include <boost/bind.hpp>
 
 #define prefix_ inline
 ///////////////////////////////cti.p///////////////////////////////////////
 
 template <class Handle>
 prefix_ senf::ppi::IOEvent::IOEvent(Handle handle, unsigned events)
-    : fd_(retrieve_filehandle(handle)), events_(events)
+    : fd_ (senf::scheduler::get_descriptor(handle)),
+      event_ ("senf::ppi::IOEvent", boost::bind(&IOEvent::cb,this,_1), fd_, events, false) 
 {}
 
+template <class Handle>
+prefix_ void senf::ppi::IOEvent::set(Handle handle, unsigned events)
+{
+    if (handle) {
+        fd_ = senf::scheduler::get_descriptor(handle);
+        event_.events(events).handle(fd_);
+    }
+    else {
+        event_.disable();
+        fd_ = -1;
+    }
+}
+
 ///////////////////////////////cti.e///////////////////////////////////////
 #undef prefix_