Simplified XF 1.1.0
dispatcher.h
1#ifndef XF_INTERFACE_DISPATCHER_H
2#define XF_INTERFACE_DISPATCHER_H
3
4#include "xf/event.h"
5
6class XF;
8
9namespace interface {
10
11class XFBehavior;
12
29{
30 friend class ::XF;
31 friend class ::DispatcherThread;
32
33public:
34 virtual ~XFDispatcher() = default;
35
36 static XFDispatcher * getInstance();
37
38 virtual void pushEvent(XFEvent * pEvent) = 0;
45 virtual void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior * pBehavior) = 0;
46
50 virtual void unscheduleTimeout(int timeoutId, interface::XFBehavior * pBehavior) = 0;
51
52protected:
57 XFDispatcher() = default;
58
62 virtual int execute(const void * param = nullptr) = 0;
63
75 virtual void executeOnce() = 0;
76
84 virtual void dispatchEvent(const XFEvent * pEvent) const = 0;
85};
86
87} // namespace interface
88#endif // XF_INTERFACE_DISPATCHER_H
The DispatcherThread calls the XFDispatcher execute() method in a separate thread.
Definition: xf.cpp:61
Base class for state machines, activities, process and data flows.
Definition: behavior.h:29
Base class for all types of events and timeouts.
Definition: event.h:23
Static class grouping the basic methods for the XF together.
Definition: xf.h:73
Interface to receive and process events.
Definition: behavior.h:24
Interface for the XF dispatcher providing the event processing loop.
Definition: dispatcher.h:29
virtual void unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior)=0
Removes all timeouts corresponding the given parameters.
static XFDispatcher * getInstance()
Returns a pointer to the single instance of XFDispatcher.
Definition: dispatcher.cpp:22
virtual int execute(const void *param=nullptr)=0
Main loop of the dispatcher. Implements event loop processing.
virtual void dispatchEvent(const XFEvent *pEvent) const =0
Dispatches the event to the corresponding behavioral part.
virtual void pushEvent(XFEvent *pEvent)=0
Adds event to the events queue.
virtual void executeOnce()=0
Executes once the dispatcher.
virtual void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior)=0
Adds a new timeout to be handled.