add comments on XFState.h
This commit is contained in:
parent
262b89fe45
commit
dac64a2d64
@ -21,19 +21,62 @@ class XFBehavior;
|
|||||||
class XFState {
|
class XFState {
|
||||||
friend class XFBehavior;
|
friend class XFBehavior;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Create and initialise a State for the behavior.
|
||||||
|
* Have to be initialized in the constructor of the behavior.
|
||||||
|
* @param behavior Pointer to the behavior class. Use the keyword this
|
||||||
|
*/
|
||||||
XFState(XFBehavior* behavior);
|
XFState(XFBehavior* behavior);
|
||||||
~XFState() = default;
|
~XFState() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the conditional state of an custom event.
|
||||||
|
* @param evid Id of the event for set the next State
|
||||||
|
* @param state Pointer to the next state
|
||||||
|
*/
|
||||||
inline void addTransition(const int evid, XFState* state) { addTransition(XFEvent::XFEventType::Event, evid, 0, state); };
|
inline void addTransition(const int evid, XFState* state) { addTransition(XFEvent::XFEventType::Event, evid, 0, state); };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a new timer with a certain duration on every entry of this state.
|
||||||
|
* Set next state after
|
||||||
|
* @param time Time duration of the timeout
|
||||||
|
* @param nextState Pointer to the next state
|
||||||
|
*/
|
||||||
inline void setTimeout(int time, XFState* nextState) { addTransition(XFEvent::XFEventType::Timeout, XFEvent::Timeout, time, nextState); };
|
inline void setTimeout(int time, XFState* nextState) { addTransition(XFEvent::XFEventType::Timeout, XFEvent::Timeout, time, nextState); };
|
||||||
|
|
||||||
|
// Callback typedef for callback without parameter
|
||||||
typedef void (XFBehavior::*callback)();
|
typedef void (XFBehavior::*callback)();
|
||||||
typedef void (XFBehavior::*callbackEv)(const XFEvent* ev);
|
|
||||||
//inline void registerOnState(callback cbState) { cbState_ = cbState; };
|
//inline void registerOnState(callback cbState) { cbState_ = cbState; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the method for the entry callback without parameter
|
||||||
|
* @param cbEntry Callback automatically called when the state is onEntry
|
||||||
|
*/
|
||||||
inline void registerOnEntry(callback cbEntry) { cbEntry_ = cbEntry; };
|
inline void registerOnEntry(callback cbEntry) { cbEntry_ = cbEntry; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the method for the exit callback without parameter
|
||||||
|
* @param cbExit Callback automatically called when the state is onExit
|
||||||
|
*/
|
||||||
inline void registerOnExit(callback cbExit) { cbExit_ = cbExit; };
|
inline void registerOnExit(callback cbExit) { cbExit_ = cbExit; };
|
||||||
|
|
||||||
|
|
||||||
|
//Callback typedef for callback with event in parameter
|
||||||
|
typedef void (XFBehavior::*callbackEv)(const XFEvent* ev);
|
||||||
|
|
||||||
//inline void registerOnState(callbackEv cbState) { cbEvState_ = cbState; };
|
//inline void registerOnState(callbackEv cbState) { cbEvState_ = cbState; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the method for the entry callback with event in parameter.
|
||||||
|
* @param cbEntry Callback automatically called when the state is onEntry
|
||||||
|
*/
|
||||||
inline void registerOnEntry(callbackEv cbEntry) { cbEvEntry_ = cbEntry; };
|
inline void registerOnEntry(callbackEv cbEntry) { cbEvEntry_ = cbEntry; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the method for the exit callback with event in parameter
|
||||||
|
* @param cbExit Callback automatically called when the state is onExit
|
||||||
|
*/
|
||||||
inline void registerOnExit(callbackEv cbExit) { cbEvExit_ = cbExit; };
|
inline void registerOnExit(callbackEv cbExit) { cbEvExit_ = cbExit; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -65,6 +108,10 @@ protected:
|
|||||||
|
|
||||||
class XFInitialState : public XFState {
|
class XFInitialState : public XFState {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Use for set next state of the Initial State.
|
||||||
|
* @param state Pointer to the next state
|
||||||
|
*/
|
||||||
inline XFInitialState(XFBehavior* behavior) : XFState(behavior) {};
|
inline XFInitialState(XFBehavior* behavior) : XFState(behavior) {};
|
||||||
~XFInitialState() = default;
|
~XFInitialState() = default;
|
||||||
inline void addInitialTransition(XFState* state) { addTransition(XFEvent::XFEventType::Initial, XFEvent::Initial, 0, state); };
|
inline void addInitialTransition(XFState* state) { addTransition(XFEvent::XFEventType::Initial, XFEvent::Initial, 0, state); };
|
||||||
|
Reference in New Issue
Block a user