PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIStateLambda Class Reference

State implementation that forwards enter and exit virtual methods to callbacks. More...

#include <pistatemachine_state.h>

Inheritance diagram for PIStateLambda:
Inheritance graph
[legend]

Public Member Functions

 PIStateLambda (std::function< void()> on_enter, std::function< void()> on_exit=nullptr, const PIString &n={})
 Creates a state backed by enter and exit callbacks.
 
void onEnter () override
 Executes the enter callback.
 
void onExit () override
 Executes the exit callback.
 
- Public Member Functions inherited from PIStateBase
 PIStateBase (const PIString &n={})
 Creates a state with an optional diagnostic name.
 
virtual ~PIStateBase ()
 Destroys the state together with owned child states and transitions.
 
virtual void onEnter ()
 Called when the state becomes active.
 
virtual void onExit ()
 Called when the state becomes inactive.
 
virtual void onFinish ()
 Called when a final child finishes this state.
 
PIStateMachinemachine () const
 Returns the root state machine.
 
PIStateBaseparent () const
 Returns the parent state.
 
PIStateBaseactiveChild () const
 Returns the active child of a non-parallel compound state.
 
PIVector< PIStateBase * > activeChildren () const
 Returns active child states.
 
PIVector< PIStateBase * > activeAtomics () const
 Returns active atomic leaf states below this state.
 
void addState (PIStateBase *s)
 Adds a child state owned by this state.
 
void addStates (PIVector< PIStateBase * > s)
 Adds multiple child states owned by this state.
 
void setInitialState (PIStateBase *s)
 Sets the initial child state for a non-parallel compound state.
 
PITransitionBaseaddTransition (PIStateBase *target, int event_id)
 Adds an event-driven transition from this state to target.
 
PITransitionTimeoutaddTimeoutTransition (PIStateBase *target, PISystemTime timeout)
 Adds a timeout transition that fires while this state stays active.
 
void setParallel (bool yes)
 Enables or disables parallel activation of child states.
 
const PIStringgetName () const
 Returns the state name.
 
bool isStateMachine () const
 Returns true for the root machine object.
 
bool isActive () const
 Returns true if the state is currently active.
 
bool isParallel () const
 Returns true if child states are activated in parallel.
 
bool isFinal () const
 Returns true if the state is marked as final.
 
bool isAtomic () const
 Returns true if the state has no children.
 
bool isCompound () const
 Returns true if the state owns child states.
 
const PIVector< PIStateBase * > & getChildren () const
 Returns direct child states.
 
const PIVector< PITransitionBase * > & getTransitions () const
 Returns outgoing transitions owned by this state.
 
void print (PIString prefix={})
 Prints the state tree and active branches to piCout.
 
PIVector< PIStateBase * > gatherStates ()
 Returns this state and all descendant states.
 

Additional Inherited Members

Detailed Description

State implementation that forwards enter and exit virtual methods to callbacks.