testfsm : shows one technique for creating FSMs in C++

Download Files

Changes

  1. Initial Version

Installation

None.

Notes

testfsm shows one technique for creating FSMs in C++. I tried it as an experiment to see if was a viable, easy to maintain architecture.

The only other interesting bit from this is the "syntax highlighting"-like code. The test FSM highlights C/C++ comments in a given string. When you run it in console mode the comments show up in green and the normal text shows up in white. Here's the relevant code snippet:

MyFSM::MyFSM()
  {
  m_hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
  }

inline void MyFSM::CommentColor()
  {
  SetConsoleTextAttribute(m_hconsole, FOREGROUND_GREEN);
  }
inline void MyFSM::NormalColor()
  {
  SetConsoleTextAttribute(m_hconsole, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
  }





Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001-2010