Class KPState¶
- Defined in File KPState.hpp
Class Documentation¶
-
class
KPState¶ Public Functions
-
const char *
getName() const¶ Get the Name object
- Return
- const char* pointer to the name assigned to this state
-
virtual void
enter(KPStateMachine &machine) = 0¶ [Required] Subclass must override this method and specify the behavior when entering this state
- Parameters
machine:
-
virtual void
leave(KPStateMachine &machine)¶ When override, this method is called just before the transition to new state
- Parameters
machine: State machine owning this state
-
virtual void
update(KPStateMachine &machine)¶ Override to receive runtime lifecycle loop while in this state
- Parameters
machine: State machine owning this state
-
unsigned long
timeSinceLastTransition() const¶ Return time since the last call to enter lifecycle method
- Return
- unsigned long
-
void
setTimeCondition(unsigned long seconds, std::function<void()> callback)¶ Convenient method for time-based state condition
- Parameters
seconds: time until the callback is executedcallback: callback to execute when the time expires
-
void
setCondition(std::function<bool()> conditionstd::function<void()> callback)¶ Set the state condition.
- Parameters
condition: callable that returns true on abitary conditioncallback: callable to be executed when condition returns true
-
const char *