Simplified XF 1.1.0

behavior.h
1#ifndef XF_INTERFACE_BEHAVIOR_H
2#define XF_INTERFACE_BEHAVIOR_H
3
4#include <string>
5#include "xf/event.h"
6
7 class XFDispatcher;
8 class XFDispatcherActiveDefault;
9 class XFDispatcherPort;
10 class XFDispatcherActivePort;
11 class XFDispatcher;
12
13 namespace interface {
14
23 class XFBehavior
24{
25 // Only XFDispatchers should get access to the 'process' method
26 friend class ::XFDispatcher;
27 friend class ::XFDispatcherPort;
28
29 public:
30 using TerminateBehavior = bool;
31
32 public:
33 virtual ~XFBehavior() = default;
34
35 virtual void startBehavior() = 0;
36 virtual void pushEvent(XFEvent * pEvent) = 0;
37 virtual bool deleteOnTerminate() const = 0;
38 virtual void setDeleteOnTerminate(bool deleteBehaviour) = 0;
39
40 protected:
41 virtual TerminateBehavior process(const XFEvent * pEvent) = 0;
42
43 protected:
44 XFBehavior() = default;
45};
46
47} // namespace interface
48#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