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

Handle multiple FSMs #39

Open
amiguels opened this issue Apr 27, 2023 · 3 comments
Open

Handle multiple FSMs #39

amiguels opened this issue Apr 27, 2023 · 3 comments

Comments

@amiguels
Copy link

I have the need to have, in parallel, several FSM that are exactly the same, but that will be in different states as they respond to a button, but that button is different for all of them.

Considering tinyfsm FSMs are not instances, what is the best way to handle this?

@kth8384
Copy link

kth8384 commented Nov 4, 2023

add a context as a container to hold the instance replace the global static pointer

@chinjo1296
Copy link

Hello,

I have a need to create a vector of FSMs so that I can maintain individual states. The size of the vector is dynamic and will be defined during runtime. Any idea how I can do this??

I would want something like this
std::vector vec;

vec[0]::dispatc(event0);
vec[1]::dispatch(event1);

@ShaharHD
Copy link

ShaharHD commented Oct 16, 2024

Hello,

I have a need to create a vector of FSMs so that I can maintain individual states. The size of the vector is dynamic and will be defined during runtime. Any idea how I can do this??

I would want something like this std::vector vec;

vec[0]::dispatc(event0); vec[1]::dispatch(event1);

Joining the question as well.
I like the tinyFSM concept, but because the state is static, it makes doesn't seem to allow a "clean" way to create instances.

@digint would like to see an example for that if exists?

Maybe the solution is use C++ bind ?
But it will require removing the static variable of current state.
Maybe with if template method?

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

4 participants