Click here to Skip to main content
15,892,809 members

Comments by Trevor Johansen (Top 16 by date)

Trevor Johansen 21-Jul-11 22:53pm View    
Yea I am a bit confused by the C# syntax in your article. I was going to rework my code to allow adding states and events such as:

AddState ( Curr_State, New_State, Event );
AddEvent ( Event Key_UP );
AddEventFunction ( Event Key_UP, pFunc UP_Function);
AddStateFunction ( State, pFunc State_Function);

However I would store these variables into an array as I am already doing but in order to make it flexible I would need to use vectors to allow dynamic resizing. The vector library is not available on embedded devices. I could skirt around this by having a STATE_TABLE [#States][#Events][pFuncs] macro but that's not a very clean implimentation...

Current code is here: http://pastebin.com/sKkcF0Ui
Trevor Johansen 20-Jul-11 23:32pm View    
Well that was a great read! Unfortunately I do not use C#...

I quite like the enum as a class that C# has there. I have to maintain an 2d char array for debugging my enums in english in C/C++.

However I do not get quite a bit of the syntax as I have not dealt with templates yet and am unsure how to apply things to C++. I am working on a version of my code but have some kinks still. I will post it on pastebin tomorrow and I will ask my questions.

Thanks!
Trevor Johansen 15-Jul-11 13:20pm View    
I found this awesome website: http://www.mywikinet.com/mpl/paper/html/example.html and it has a very clean FSM implementation. Should be applicable to C++ and Java, It is much more robust than my FSM and has a better interface.
Trevor Johansen 15-Jul-11 11:52am View    
I have used it to and its handy for things like quick user menus but I prefer not to rely on a closed source project.
Trevor Johansen 15-Jul-11 11:51am View    
Thanks for the heads up on the Boost::FSM. It is open and has all the features I was looking for I believe.

Do they make a Java equivalent of the Boost library do you know?