PPI: More unit tests
[senf.git] / PPI / Events.hh
index cb21dd7..698a433 100644 (file)
@@ -25,6 +25,7 @@
 #define HH_Events_ 1
 
 // Custom includes
+#include <vector>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include "predecl.hh"
 
@@ -64,12 +65,47 @@ namespace ppi {
 
         virtual bool v_isRegistered() = 0;
 
+        void notifyThrottle();
+        void notifyUnthrottle();
+
+        void registerRoute(ForwardingRoute & route);
+
         bool enabled_;
+
+        typedef std::vector<ForwardingRoute*> Routes;
+        Routes routes_;
+
+        friend class ForwardingRoute;
+    };
+    
+    template <class EventType, class Self>
+    class EventImplementationHelper
+    {
+    protected:
+        typedef typename detail::EventArgType<EventType>::type EventArg;
+
+        void callback(EventArg event, boost::posix_time::ptime time);
+        void callback(EventArg event);
+
+    private:
+        detail::EventBinding<EventType> & binding();
+    };
+    
+    template <class Self>
+    class EventImplementationHelper<void,Self>
+    {
+    protected:
+        void callback(boost::posix_time::ptime time);
+        void callback();
+
+    private:
+        detail::EventBinding<void> & binding();
     };
 
     template <class EventType>
     class EventImplementation
-        : public EventDescriptor
+        : public EventDescriptor, 
+          public EventImplementationHelper< EventType, EventImplementation<EventType> >
     {
     public:
         typedef EventType Event;
@@ -78,9 +114,6 @@ namespace ppi {
     protected:
         EventImplementation();
 
-        void callback(EventArg event, boost::posix_time::ptime time);
-        void callback(EventArg event);
-
     private:
         virtual bool v_isRegistered();
         void setBinding(detail::EventBinding<Event> & binding);
@@ -88,6 +121,7 @@ namespace ppi {
         detail::EventBinding<Event> * binding_;
 
         friend class EventManager;
+        friend class EventImplementationHelper< EventType, EventImplementation<EventType> >;
     };
 
 }}