Dispatching events

The dispatchEvent() operation uses a switch statement to process the outbound transitions from the states of an object.

About this task

For example, the dispatchEvent() operation generated for the operating state of the Furnace in the HomeHeatingSystem sample, uses roughly the following switch statement to process the out transitions from the idle, shutting, working, and starting substates of the operating orthogonal state:

static int operating_dispatchEvent(Furnace* const me,
short id) {
   int res = eventNotConsumed;
   switch (me->operating_active) {
      case Furnace_idle:
      {
         /* process out transitions from idle state */
         res = eventConsumed;
         break;
      };

      case Furnace_shutting:
      {
         /* process out transitions from shutting
            state */
         res = eventConsumed;
         break;
      };
      case Furnace_starting:
      {
         /* process out transitions from starting 
            state */
         res = eventConsumed;
         break;
      };
      case Furnace_working:
      {
         /* process out transitions from working
            state */
         res = eventConsumed;
         break;
      };
      default:
      break;
   };
   return res;
}

Feedback