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
6 class XF;
7 class DispatcherThread;
8
9 namespace interface {
10
11 class XFBehavior;
12
28 class XFDispatcher
29{
30 friend class ::XF;
31 friend class ::DispatcherThread;
32
33 public:
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
52 protected:
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
DispatcherThread
The DispatcherThread calls the XFDispatcher execute() method in a separate thread.
Definition: xf.cpp:61
XFBehavior
Base class for state machines, activities, process and data flows.
Definition: behavior.h:29
XFEvent
Base class for all types of events and timeouts.
Definition: event.h:23
XF
Static class grouping the basic methods for the XF together.
Definition: xf.h:73
interface::XFBehavior
Interface to receive and process events.
Definition: behavior.h:24
interface::XFDispatcher
Interface for the XF dispatcher providing the event processing loop.
Definition: dispatcher.h:29
interface::XFDispatcher::unscheduleTimeout
virtual void unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior)=0
Removes all timeouts corresponding the given parameters.
interface::XFDispatcher::getInstance
static XFDispatcher * getInstance()
Returns a pointer to the single instance of XFDispatcher.
Definition: dispatcher.cpp:22
interface::XFDispatcher::execute
virtual int execute(const void *param=nullptr)=0
Main loop of the dispatcher. Implements event loop processing.
interface::XFDispatcher::dispatchEvent
virtual void dispatchEvent(const XFEvent *pEvent) const =0
Dispatches the event to the corresponding behavioral part.
interface::XFDispatcher::pushEvent
virtual void pushEvent(XFEvent *pEvent)=0
Adds event to the events queue.
interface::XFDispatcher::XFDispatcher
XFDispatcher()=default
interface::XFDispatcher::executeOnce
virtual void executeOnce()=0
Executes once the dispatcher.
interface::XFDispatcher::scheduleTimeout
virtual void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior)=0
Adds a new timeout to be handled.