Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/hsmcpp/hsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,15 @@ class HierarchicalStateMachine {
*/
bool isStateActive(const StateID_t state) const;

/**
* @brief Called whenever a change state occurs.
* @details Overwrite this function to get informed when a new state is activated.
*
* @param state ID of the new state
*
*/
virtual void onStateChanged(const StateID_t state) const { }

/**
* @brief Trigger a transition in the HSM.
* @details This function sends event to HSM to trigger a potential transition. The transition is executed asynchronously,
Expand Down
2 changes: 2 additions & 0 deletions src/HsmImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ void HierarchicalStateMachine::Impl::onStateChanged(const StateID_t state, const
} else {
HSM_TRACE_WARNING("no callback registered for state <%s>", getStateName(state).c_str());
}
// notify parent
if (mParent) mParent->onStateChanged(state);
}

void HierarchicalStateMachine::Impl::executeStateAction(const StateID_t state, const StateActionTrigger actionTrigger) {
Expand Down