title: State Machine - Structure To Hold States, Events and pFuncs
body: <p>If I make a state machine and want to use an interface like this:</p>
  
  <pre><code>AddState ( state1, state2, Key_UP );
  AddEvent ( Key_UP );
  AddEventFunction ( Key_UP, &amp;UP_Function);
  AddStateFunction ( state1, &amp;State1_In_Function, &amp;State1_Out_Function);
  AddStateFunction ( state2, &amp;State2_In_Function, &amp;State2_Out_Function);
  
  State1_In_Function  ( void ) { printf ( "In #1 \n" ); }
  State1_Out_Function ( void ) { printf ( "Out #1 \n" ); }
  State2_In_Function  ( void ) { printf ( "In #2 \n" ); }
  State2_Out_Function ( void ) { printf ( "Out #2 \n" ); }
  UP_Function         ( void ) { printf ( "Goin UP \n" ); }
  </code></pre>
  
  <p>That way when I am in state1 and the FSM receives Key_UP the program prints:</p>
  
  <pre><code>Out #1
  Goin UP
  In #2
  </code></pre>
  
  <p>The question is how to store the state and transitional information inside the class without the programmer being required to change an array size. I was thinking I could use a 2D array and make it a state table like usual and to make it more portable I would just handle the addition of events and states by using the vector type to resize as needed. The problem with vectors is that not many embedded devices can use the memory allocation calls. My second option is to call a constructor with the state machine and pass it the size the table would require to be but then if I add any new states or events I need to change these values as well...</p>
  
  <p>So how should I store my states, events and function pointers?!</p>