Index: trunk/include/Pacpus/kernel/InputOutputInterface.h
===================================================================
--- trunk/include/Pacpus/kernel/InputOutputInterface.h	(revision 258)
+++ trunk/include/Pacpus/kernel/InputOutputInterface.h	(revision 269)
@@ -18,10 +18,31 @@
     typedef T data_type;
     typedef C component_type;
-    typedef void (C::*process_data_function_type)(const T &);
-
-    InputInterface(QString name, C * component, process_data_function_type processMethod)
-        : InputInterfaceBase(name, component, component)
-        , method(processMethod)
-    {
+    typedef void (C::*process_data_function_type_with_event)(T&, PacpusEvent);
+    typedef void (C::*process_data_function_type)(T&);
+    typedef void (C::*process_const_data_function_type_with_event)(T const&, PacpusEvent);
+    typedef void (C::*process_const_data_function_type)(T const&);
+
+    InputInterface(QString name, C* component, process_data_function_type_with_event processingMethod)
+        : InputInterfaceBase(name, component, component)
+    {
+        mProcessingMethod.fe = processingMethod;
+    }
+    
+    InputInterface(QString name, C* component, process_data_function_type processingMethod)
+        : InputInterfaceBase(name, component, component)
+    {
+        mProcessingMethod.f = processingMethod;
+    }
+    
+    InputInterface(QString name, C* component, process_const_data_function_type_with_event processingMethod)
+        : InputInterfaceBase(name, component, component)
+    {
+        mProcessingMethod.cfe = processingMethod;
+    }
+    
+    InputInterface(QString name, C* component, process_const_data_function_type processingMethod)
+        : InputInterfaceBase(name, component, component)
+    {
+        mProcessingMethod.cf = processingMethod;
     }
 
@@ -35,5 +56,5 @@
     }
 
-    const std::type_info & getDataType() const
+    std::type_info const& getDataType() const
     {
         return typeid(T);
@@ -47,6 +68,13 @@
 
     // FIXME: what's the purpose of this function?
-    void customEvent(QEvent * event)
-    {
+    void customEvent(QEvent* event)
+    {
+        static road_timerange_t const kMaximumBoundedTimeRange = 500;
+
+        if (!event) {
+            LOG_WARN("null event");
+            return;
+        }
+        
         // check that component has been started
         if ((NULL == getComponent()) || (!getComponent()->isActive())) {
@@ -57,11 +85,11 @@
         LOG_TRACE("Receiver: " << getSignature());
 
-        //PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *>(event);
-        PacpusEvent * pacpusEvent = dynamic_cast<PacpusEvent *>(event);
+        //PacpusTypedEvent<T>* typedEvent = dynamic_cast<PacpusTypedEvent<T> *>(event);
+        PacpusEvent* pacpusEvent = dynamic_cast<PacpusEvent*>(event);
         if (!pacpusEvent) {
             LOG_WARN("dynamic_cast failed: not a PacpusEvent");
             return;
         }
-        PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *>(pacpusEvent);
+        PacpusTypedEvent<T>* typedEvent = dynamic_cast<PacpusTypedEvent<T>*>(pacpusEvent);
         if (!typedEvent) {
             LOG_WARN("dynamic_cast failed: incompatible event types");
@@ -71,6 +99,6 @@
         switch (event->type()) {
         case TYPED_EVENT:
-            if (TimeBounded == readingMode() && typedEvent->timerange() < 500) {
-                LOG_WARN("Incorrect TimeRange (0), switch to NeverSkip");
+            if (TimeBounded == readingMode() && typedEvent->timerange() < kMaximumBoundedTimeRange) {
+                LOG_WARN("Incorrect TimeRange (< " << kMaximumBoundedTimeRange << "), switching to NeverSkip mode");
                 readingMode() = NeverSkip;
             }
@@ -83,9 +111,10 @@
                 }
 
-                (dynamic_cast<C*>(component())->*method)(typedEvent->data());
+                mProcessingMethod.invoke(component(), typedEvent->data(), *typedEvent);
                 break;
 
             case GetLast:
-                (dynamic_cast<C*>(component())->*method)(typedEvent->data());
+                mProcessingMethod.invoke(component(), typedEvent->data(), *typedEvent);
+
                 // delete all remaining events
                 QCoreApplication::removePostedEvents(this, TYPED_EVENT);
@@ -93,5 +122,5 @@
 
             case NeverSkip:
-                (dynamic_cast<C*>(component())->*method)(typedEvent->data());
+                mProcessingMethod.invoke(component(), typedEvent->data(), *typedEvent);
                 break;
 
@@ -111,14 +140,50 @@
     }
 
-    // TODO for Pulling mode (not yet implemented !!!)
-    T & getData()
+    // TODO: pull mode (NOT YET IMPLEMENTED!!!)
+    T& getData()
     {
         T data;
-        // TODO ask output data;
+        // TODO: ask the  output data;
         return data;
     }
 
 protected:
-    process_data_function_type method;
+    struct ProcessingMethod
+    {
+        ProcessingMethod()
+        {
+            fe = NULL;
+            f = NULL;
+            cfe = NULL;
+            cf = NULL;
+        }
+
+        void invoke(ComponentBase* component, T& data, PacpusEvent event)
+        {
+            C* comp = dynamic_cast<C*>(component);
+            if (NULL == comp) {
+                LOG_WARN("NULL component");
+                return;
+            }
+            if (fe) {
+                (comp->*fe)(data, event);
+            } else if (f) {
+                (comp->*f)(data);
+            } else if (cfe) {
+                (comp->*cfe)(data, event);
+            } else if (cf) {
+                (comp->*cf)(data);
+            } else {
+                LOG_WARN("no method to invoke");
+            }
+        }
+            
+        process_data_function_type_with_event fe;
+        process_data_function_type f;
+        process_const_data_function_type_with_event cfe;
+        process_const_data_function_type cf;
+    };
+
+    ProcessingMethod mProcessingMethod;
 };
 
@@ -131,5 +196,5 @@
     typedef C component_type;
 
-    OutputInterface(QString name, C * component)
+    OutputInterface(QString name, C* component)
         : OutputInterfaceBase(name, component, component)
     {}
@@ -139,5 +204,5 @@
 
     /// Send data through a typed output
-    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0);
+    void send(T const& data, road_time_t t = road_time(), road_timerange_t tr = 0);
     
     std::size_t getDataSize() const
@@ -146,5 +211,5 @@
     }
 
-    const std::type_info & getDataType() const
+    std::type_info const& getDataType() const
     {
         return typeid(T);
@@ -153,17 +218,17 @@
 
 template <typename T, class C>
-void OutputInterface<T, C>::send(const T & data, road_time_t t, road_timerange_t tr)
-{
-    // FIXME Data Shared
+void OutputInterface<T, C>::send(T const& data, road_time_t t, road_timerange_t tr)
+{
+    // FIXME: use shared data
     //QSharedPointer<T> sharedPointer = new T(data);
 
     for (QList<ConnectionBase>::iterator it = connections().begin(), itend = connections().end(); it != itend; ++it) {
-        // Qt documentatino:
+        // Qt documentation:
         //  The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted.
         //  It is not safe to access the event after it has been posted.    
-        QEvent * newEvent = new PacpusTypedEvent<T>(TYPED_EVENT, data, t, tr);
+        QEvent* pacpusEvent = new PacpusTypedEvent<T>(TYPED_EVENT, data, t, tr);
         QCoreApplication::postEvent(
             it->getInterface(), 
-            newEvent, 
+            pacpusEvent, 
             it->getPriority()
         );
@@ -173,8 +238,8 @@
 
 template <typename T1, typename T2, class C>
-bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t = road_time(), road_timerange_t tr = 0);
+bool checkedSend(OutputInterface<T1, C>* sender, T2 const& data, road_time_t t = road_time(), road_timerange_t tr = 0);
 
 template <typename T1, typename T2, class C>
-bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t, road_timerange_t tr)
+bool checkedSend(OutputInterface<T1, C>* sender, T2 const& data, road_time_t t, road_timerange_t tr)
 {
     if (sender && sender->hasConnection()) {
