Book a Demo

Author Topic: Generated State machine and switch/case  (Read 3152 times)

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Generated State machine and switch/case
« on: March 29, 2010, 07:25:01 pm »
Hello all,
I have seen that the generated code of a state machine is in switch / case blocks.

Because some big projects have to handle a LOT of  states (I know a project with 780 states), it is not always the best to use switch/case. In this case a state machine with function pointers or look-up table is preferred.

@EA
It should be selectable which type of source code generation should be used:
1. look-up tables
2. switch-case blocks
3. functional states


info link:
http://www.conman.org/projects/essays/states.html

What do you think about this idea?
« Last Edit: March 29, 2010, 07:27:53 pm by ewiebe »

Wowbagger

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: Generated State machine and switch/case
« Reply #1 on: March 30, 2010, 07:30:04 am »
I'd first point out that implementing a state machine as a big switch isn't uncommon - I've worked with SDL tools that synthesized state machines this way.

However, what I'd also like to point out is the Boost Statechart library: http://www.boost.org/doc/libs/1_34_1/libs/statechart/doc/index.html

Where I work, we are looking into making EA generate Boost::Statechart objects due to what we consider flaws in the existing EA code generation for state machines. It's not trivial, but we are making progress on it.

We've also looked at having EA generate a SMC file (http://smc.sourceforge.net/) and using SMC for code gen.