On Mon, 14 Aug 2000, Baruch Even wrote:

> I'm reading the ButtonPolicy classes now and I'm writing these comments as
> I go along.
> 
> 1. To use the map for the state machine transition table you can map based
> on a pair<current, input> and the result can be the output.

and I got a compiler error within gcc which appeared to dislike using
make_pair<> to build just such a pair.  That's why I switched to using
vectors to implement the lookup table.  It's faster than a map anyway
since it goes directly to the appropriate cell: O(1) vs O(log2(n)).
There is not much difference in memory requirements although the
executable size should be smaller since vector<> tends to have much
smaller code size than map<>.

> 2. I remember seeing on the cpptips mailing list a mention to a state
> machine compiler, in which you give it a state machine as a table or the
> like and it outputs the C++ code to run through it, maybe we can put it to
> use here too (too much hand coding for a state machine that is easier to
> explain and read as a table)

I've heard of one but can't find it in my email archive.  I think it was
called something like PCCS or similar.  IIRC Asger used it a couple of
years ago.  I will draw up the diagrams with dia and include them in the
GUII doc -- when I eventually get around to rewriting it.

The tables are pretty simple and the handcoding is also straight forward.
But I agree a tool that builds them would be nice.  I don't expect there
will be much need for adding other policies, but better explanations may
be needed though.

Allan (ARRae)


Reply via email to