dispatcher.h
#ifndef XF_COMMON_DISPATCHER_H
#define XF_COMMON_DISPATCHER_H
#include <config/xf-config.h>
#if (USE_XF_COMMON_DISPATCHER_CLASS != 0)
#include "xf/interface/dispatcher.h"
#include "xf/interface/mutex.h"
/*
* Please include the XFEventQueueDefault class in the xf-config file!
* Example: #include "default/eventqueue-default.h"
* and
* define the XFEventQueueDefault class as the class representing the
* XFEventQueue used by the dispatcher.
* Example: using XFEventQueue = XFEventQueueDefault;
*
* In case you want to provide you own event queue, you must implement
* your own XFEventQueue class and include the header file in the xf-config file.
*/
class XFDispatcher : public interface::XFDispatcher
{
friend class interface::XFDispatcher;
public:
virtual ~XFDispatcher();
void pushEvent(XFEvent * pEvent) override;
void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior * pBehavior) override;
void unscheduleTimeout(int timeoutId, interface::XFBehavior * pBehavior) override;
void executeOnce() override;
int execute(const void * param = nullptr) override;
protected:
XFDispatcher(); // Do not allow to create addition objects outside class space (singleton).
void dispatchEvent(const XFEvent * pEvent) const override;
protected:
XFEventQueue events_;
interface::XFMutex * pMutex_;
};
// end of port_common group
#endif // USE_XF_COMMON_DISPATCHER_CLASS
#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