Simplified XF 1.1.0
behavior.h
1#ifndef XF_BEHAVIOR_H
2#define XF_BEHAVIOR_H
3
4#include "xf/interface/behavior.h"
5#include "xf/interface/dispatcher.h"
6#include "xf/eventstatus.h"
7#include "xf/initialevent.h"
8#include "xf/defaulttransition.h"
9#include "xf/timeout.h"
10
11class XFTimeout;
12
29{
30public:
31 #define GEN(event) pushEvent(new event)
32
36 explicit XFBehavior();
37 ~XFBehavior() override;
38
39 void startBehavior() override;
40
41 void pushEvent(XFEvent * pEvent) override;
42
43 bool deleteOnTerminate() const override;
44 void setDeleteOnTerminate(bool deleteBehaviour) override;
45
46protected:
53
54 const XFEvent * getCurrentEvent() const;
56
57
63
64 inline void scheduleTimeout(int timeoutId, int interval) { getDispatcher()->scheduleTimeout(timeoutId, interval, this); }
65 inline void unscheduleTimeout(int timeoutId) { getDispatcher()->unscheduleTimeout(timeoutId, this); }
66
67private:
68 void setCurrentEvent(const XFEvent * pEvent);
69
83 TerminateBehavior process(const XFEvent * pEvent) override;
84
85protected:
88};
89 // end of xf_core group
91#endif // XF_BEHAVIOR_H
Base class for state machines, activities, process and data flows.
Definition: behavior.h:29
virtual XFEventStatus processEvent()=0
XFBehavior()
Default constructor for the behavior.
bool deleteOnTerminate() const override
Tells XF to delete behavior when receiving terminate event.
const XFEvent * pCurrentEvent_
Reference to actually processed event.
Definition: behavior.h:87
void pushEvent(XFEvent *pEvent) override
Injects an event into the class.
void unscheduleTimeout(int timeoutId)
Unschedules a timeout for this state machine.
Definition: behavior.h:65
void scheduleTimeout(int timeoutId, int interval)
Schedules a timeout for this state machine.
Definition: behavior.h:64
void startBehavior() override
Starts the behavior, resp. the state machine.
interface::XFDispatcher * getDispatcher()
Returns reference to actual dispatcher.
bool deleteOnTerminate_
Indicates if the behavior can be deleted after reception of a 'terminate event'.
Definition: behavior.h:86
const XFTimeout * getCurrentTimeout()
Returns a reference to the actually processed timeout.
void setDeleteOnTerminate(bool deleteBehaviour) override
Sets/Clears the 'delete on terminate' property.
const XFEvent * getCurrentEvent() const
Returns the current event to be processed in processEvent().
Base class for all types of events and timeouts.
Definition: event.h:23
Event status returned after event processing.
Definition: eventstatus.h:16
Used by the TimeoutManager to create and handle a timeout.
Definition: timeout.h:28
Interface to receive and process events.
Definition: behavior.h:24
bool TerminateBehavior
Type returned by the process() method.
Definition: behavior.h:30
Interface for the XF dispatcher providing the event processing loop.
Definition: dispatcher.h:29
virtual void unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior)=0
Removes all timeouts corresponding the given parameters.
virtual void scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior)=0
Adds a new timeout to be handled.