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

How do you pass a SM to a function? #20

Open
Ricodan opened this issue Jun 3, 2019 · 1 comment
Open

How do you pass a SM to a function? #20

Ricodan opened this issue Jun 3, 2019 · 1 comment
Labels

Comments

@Ricodan
Copy link

Ricodan commented Jun 3, 2019

main()
{
MyStateMachine::start();

gatherInformation();

dispatcherAndDecisionMakingFunction(MyStateMachine );

}

Something like this is what I'd like to accomplish.

@digint
Copy link
Owner

digint commented Jun 13, 2019

TinyFSM state machines are not instances, you can't "pass" them to a function. What you can do is create a function template, something like this:

// declare function
template<typename F>
dispatcherAndDecisionMakingFunction(void) {
    F::staticStateMachineFunction(void);
}

// call function
dispatcherAndDecisionMakingFunction<MyStateMachine>();

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

No branches or pull requests

2 participants