tinyfsm icon indicating copy to clipboard operation
tinyfsm copied to clipboard

Add some new features and very very radical changes

Open incloon opened this issue 4 years ago • 0 comments

This version is not fully compatible with the 0.3.2 version. The major difference is that when transit<State> is used, the compiler must be able to see the full declaration of State. In addition, the library <type_traits> and <utility> are required.

The main functions are as follows:

  1. Add a new initial entry function void initial(), just defined in the entry state
  2. Add the default data transfer function during state transition.The return type of exit() can be non-null, in which case the entry must take an argument that has the same type as the return type of exit().When the transit<State> is called, the return value of the old State exit() is passed into the entry function for the new State
  3. Add data transfer function during state transition.When you use Transit <State>, you can pass in a user's own data, requiring that the user's data type be the same as the entry function's argument type.
  4. When FSMList dispatches events, it does not require all state machines to have the react function for the event.It is assumed that the response events of all state machines are different, that forwarding is done only once. macro TINYFSM_ENABLE_MULTIDISPATCH need to be defined to allow multiple dispatches of events

This version would have caused the existing examples to not compile and the usage documentation to be updated accordingly, so it might be better to put it in a new dev branch for now. I have modified the elevator example to be compatible with this version. Hopefully these features will help with this project

incloon avatar May 15 '21 17:05 incloon