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
7class XFDispatcher;
8class XFDispatcherActiveDefault;
9class XFDispatcherPort;
10class XFDispatcherActivePort;
11class XFDispatcher;
12
13namespace interface {
14
24{
25 // Only XFDispatchers should get access to the 'process' method
26 friend class ::XFDispatcher;
27 friend class ::XFDispatcherPort;
28
29public:
30 using TerminateBehavior = bool;
31
32public:
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
40protected:
41 virtual TerminateBehavior process(const XFEvent * pEvent) = 0;
42
43protected:
44 XFBehavior() = default;
45};
46
47} // namespace interface
48#endif // XF_INTERFACE_BEHAVIOR_H
Dispatcher used in an IDF (no underlying OS).
Definition: dispatcher.h:36
Base class for all types of events and timeouts.
Definition: event.h:23
Interface to receive and process events.
Definition: behavior.h:24
virtual void startBehavior()=0
Starts the behavior.
virtual bool deleteOnTerminate() const =0
Tells XF to delete behavior when receiving terminate event.
virtual void pushEvent(XFEvent *pEvent)=0
Injects an event into the class.
virtual void setDeleteOnTerminate(bool deleteBehaviour)=0
Sets/Clears the 'delete on terminate' property.
virtual TerminateBehavior process(const XFEvent *pEvent)=0
Called by the dispatcher to process an event.
bool TerminateBehavior
Type returned by the process() method.
Definition: behavior.h:30