Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When to set m_current_state #35

Open
nyfelix opened this issue Apr 14, 2020 · 0 comments
Open

When to set m_current_state #35

nyfelix opened this issue Apr 14, 2020 · 0 comments

Comments

@nyfelix
Copy link

nyfelix commented Apr 14, 2020

Hi,
thank you for that wonderful and lean implementation of an FSM.
When test driving it, I came across the following question (probably not an issue):

The m_current_state is set after execution of transition->state_to->on_enter.
This means, you cannot set a trigger in the on_enter function to directly move to the next state.
Is this meant to be like this, or should m_current_state rather be set before execution of transition->state_to->on_enter?

void Fsm::make_transition(Transition* transition)
{
// Execute the handlers in the correct order.
if (transition->state_from->on_exit != NULL)
transition->state_from->on_exit();

if (transition->on_transition != NULL)
transition->on_transition();

if (transition->state_to->on_enter != NULL)
transition->state_to->on_enter();

m_current_state = transition->state_to;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant