Tinyfsm: Can we have multi instance of the same Fsm?

Created on 25 Oct 2017  ·  5Comments  ·  Source: digint/tinyfsm

Since declare typedef F const * state_ptr_const_t; in class Fsm, we cannot get more than one instance for a specific Fsm. Is there any way to avoid this?

question

All 5 comments

As you state correctly, Fsm and states are all static instances of template types. This means that it's not possible to have more than one instance for as specific Fsm.

It might be possible with some template metaprogramming magic, and I remember doing some experiments with this, but it became pretty complicated, so I dropped it (as one main goal of tinyfsm is to keep it simple).

Here's how you can have multiple state machines of the same type, declaring a template state machine: examples/api/multiple_switch.cpp.

I was going to use this library for doing fsm for like thousands of AI bots... this no longer seems viable if I there's not a way to instantiate a Fsm object for each bot. (Novice c++ learner so not positive if there's a workaround).

hm nvermind i'll just be using https://www.boost.org/doc/libs/1_64_0/libs/msm since it matches more closely what I was needing in terms of functionality.

Same problem. I wanted to use this library for a websocket server - websockets as state machines.
_I came across Boost.SML._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ultimatexemnas picture ultimatexemnas  ·  37Comments

andersk picture andersk  ·  81Comments

slothbag picture slothbag  ·  108Comments

click picture click  ·  51Comments

alranel picture alranel  ·  116Comments