behavior.h
#ifndef XF_INTERFACE_BEHAVIOR_H
#define XF_INTERFACE_BEHAVIOR_H
#include <string>
#include "xf/event.h"
class XFDispatcher;
class XFDispatcherActiveDefault;
class XFDispatcherPort;
class XFDispatcherActivePort;
class XFDispatcher;
namespace interface {
class XFBehavior
{
// Only XFDispatchers should get access to the 'process' method
friend class ::XFDispatcher;
friend class ::XFDispatcherPort;
public:
using TerminateBehavior = bool;
public:
virtual ~XFBehavior() = default;
virtual void startBehavior() = 0;
virtual void pushEvent(XFEvent * pEvent) = 0;
virtual bool deleteOnTerminate() const = 0;
virtual void setDeleteOnTerminate(bool deleteBehaviour) = 0;
protected:
virtual TerminateBehavior process(const XFEvent * pEvent) = 0;
protected:
XFBehavior() = default;
};
} // namespace interface
#endif // XF_INTERFACE_BEHAVIOR_H
XFDispatcher
Dispatcher used in an IDF (no underlying OS).
Definition: dispatcher.h:36
XFEvent
Base class for all types of events and timeouts.
Definition: event.h:23
interface::XFBehavior
Interface to receive and process events.
Definition: behavior.h:24
interface::XFBehavior::startBehavior
virtual void startBehavior()=0
Starts the behavior.
interface::XFBehavior::deleteOnTerminate
virtual bool deleteOnTerminate() const =0
Tells XF to delete behavior when receiving terminate event.
interface::XFBehavior::pushEvent
virtual void pushEvent(XFEvent *pEvent)=0
Injects an event into the class.
interface::XFBehavior::setDeleteOnTerminate
virtual void setDeleteOnTerminate(bool deleteBehaviour)=0
Sets/Clears the 'delete on terminate' property.
interface::XFBehavior::process
virtual TerminateBehavior process(const XFEvent *pEvent)=0
Called by the dispatcher to process an event.
interface::XFBehavior::TerminateBehavior
bool TerminateBehavior
Type returned by the process() method.
Definition: behavior.h:30