Class FSMTransition#

Inheritance Relationships#

Base Type#

Class Documentation#

class FSMTransition : public Karana::Core::Base#

An edge in the graph that makes up an FSM.

Public Functions

FSMTransition(const kc::ks_ptr<FSMState> &parent_state, const kc::ks_ptr<FSMState> &child_state, std::function<bool()> should_transition_fn)#

FSMTransition constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

Parameters:
  • parent_state – The parent FSMState of the edge.

  • child_state – The child FSMState of the edge.

  • should_transition_fn – The function that indicates whether this state should transition or not. This should return true when it is time to transition, and false when it is not. The FSM.update method checks these functions to decide when to transition.

const kc::ks_ptr<FSMState> &getParentState() const#

Get the parent state for this edge.

Returns:

The parent state for this edge.

const kc::ks_ptr<FSMState> &getChildState() const#

Get the child state for this edge.

Returns:

The child state for this edge.

Public Members

std::function<bool()> should_transition_fn#

Function that indicates if we should transition. true for yes and false for no.

Karana::Core::CallbackRegistry<void> on_transition_fns#

Functions that execute when transitioning on this edge.

Public Static Functions

static kc::ks_ptr<FSMTransition> create(const kc::ks_ptr<FSMState> &parent_state, const kc::ks_ptr<FSMState> &child_state, std::function<bool()> should_transition_fn)#

Create a new instance of FSMTransition.

Parameters:
  • parent_state – The parent FSMState of the edge.

  • child_state – The child FSMState of the edge.

  • should_transition_fn – The function that indicates whether this state should transition or not. This should return true when it is time to transition, and false when it is not. The FSM.update method checks these functions to decide when to transition.

Returns:

A pointer to the newly created instance of FSMTransition.

Protected Functions

virtual void _discard(Karana::Core::ks_ptr<Karana::Core::Base> &base) override#

Discard the the object. Derived classes should implement this with the logic required to discard themselves if applicable.

Parameters:

base – - A pointer to the object to discard.