Simplified XF 1.1.0

dispatcher.h
1#ifndef XF_COMMON_DISPATCHER_H
2#define XF_COMMON_DISPATCHER_H
3
4#include <config/xf-config.h>
5
6#if (USE_XF_COMMON_DISPATCHER_CLASS != 0)
7
8#include "xf/interface/dispatcher.h"
9#include "xf/interface/mutex.h"
10
11/*
12 * Please include the XFEventQueueDefault class in the xf-config file!
13 * Example: #include "default/eventqueue-default.h"
14 * and
15 * define the XFEventQueueDefault class as the class representing the
16 * XFEventQueue used by the dispatcher.
17 * Example: using XFEventQueue = XFEventQueueDefault;
18 *
19 * In case you want to provide you own event queue, you must implement
20 * your own XFEventQueue class and include the header file in the xf-config file.
21 */
22
35 class XFDispatcher : public interface::XFDispatcher
36{
37 friend class interface::XFDispatcher;
38 public:
39 virtual ~XFDispatcher();
40
41 void pushEvent(XFEvent * pEvent) override;
42
43 void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior * pBehavior) override;
44 void unscheduleTimeout(int timeoutId, interface::XFBehavior * pBehavior) override;
45
46 void executeOnce() override;
47 int execute(const void * param = nullptr) override;
48
49 protected:
50 XFDispatcher(); // Do not allow to create addition objects outside class space (singleton).
51 void dispatchEvent(const XFEvent * pEvent) const override;
52
53 protected:
54 XFEventQueue events_;
55 interface::XFMutex * pMutex_;
56};
57 // end of port_common group
59#endif // USE_XF_COMMON_DISPATCHER_CLASS
60#endif // XF_COMMON_DISPATCHER_H
XFDispatcher
Dispatcher used in an IDF (no underlying OS).
Definition: dispatcher.h:36
XFDispatcher::events_
XFEventQueue events_
Queue holding events waiting to get dispatched.
Definition: dispatcher.h:54
XFDispatcher::executeOnce
void executeOnce() override
Executes once the dispatcher.
XFDispatcher::pMutex_
interface::XFMutex * pMutex_
Mutex to protect event queue.
Definition: dispatcher.h:55
XFDispatcher::pushEvent
void pushEvent(XFEvent *pEvent) override
Adds event to the events queue.
XFDispatcher::unscheduleTimeout
void unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior) override
Removes all timeouts corresponding the given parameters.
XFDispatcher::scheduleTimeout
void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) override
Adds a new timeout to be handled.
XFDispatcher::dispatchEvent
void dispatchEvent(const XFEvent *pEvent) const override
Dispatches the event to the corresponding behavioral part.
XFDispatcher::execute
int execute(const void *param=nullptr) override
Main loop of the dispatcher. Implements event loop processing.
XFEvent
Base class for all types of events and timeouts.
Definition: event.h:23
XFEventQueue
Default Qt implementation for the XFEventQueue interface.
Definition: eventqueue.h:22
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::XFDispatcher
XFDispatcher()=default
interface::XFMutex
Mutex interface needed by the XF to access a mutex.
Definition: mutex.h:18