dispatcher.h
#ifndef XF_INTERFACE_DISPATCHER_H
#define XF_INTERFACE_DISPATCHER_H
#include "xf/event.h"
class XF;
class DispatcherThread;
namespace interface {
class XFBehavior;
class XFDispatcher
{
friend class ::XF;
friend class ::DispatcherThread;
public:
virtual ~XFDispatcher() = default;
static XFDispatcher * getInstance();
virtual void pushEvent(XFEvent * pEvent) = 0;
virtual void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior * pBehavior) = 0;
virtual void unscheduleTimeout(int timeoutId, interface::XFBehavior * pBehavior) = 0;
protected:
XFDispatcher() = default;
virtual int execute(const void * param = nullptr) = 0;
virtual void executeOnce() = 0;
virtual void dispatchEvent(const XFEvent * pEvent) const = 0;
};
} // namespace interface
#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.