Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2006-02-22 19:34:54


David Greene wrote:
> I had assumed that if a state_machine definition did not mention any
> reaction for a particular event in a particular state, occurrence
> of that event in that state would be flagged as a runtime error.
>
> It appears that instead, the event is simply dropped.

This is the behavior mandated by the UML standard.

> Can this behavior be changed? It would be tremendously helpful
> for debugging purposes. Adding an error state and a bunch of
> transitions into it seems like overkill, especially if the
> cross product between states and events is large but the "in-
> and out-degree" of states is small.

[untested code]

struct EvUnconsumedEvent() : sc::event<EvUnconsumedEvent> {};

// Add the following member to your state_machine
// subtype (see reference):
void unconsumed_event( const sc::event_base & )
{
  post_event( new EvUnconsumedEvent() );
}

Your machine has two outermost states, e.g. Normal and
UnconsumedEventError and a transition triggered by EvUnconsumedEvent
leading from Normal to UnconsumedEventError. Of course, Normal would
then contain all the states you have now.

HTH & Regards,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net