| | | | | |

Events and Signals

    typedef unsigned short QSignal;
    struct QEvent
    {
      QSignal sig;                        // signal of the event instance
      unsigned char poolId;        // pool this event instance comes from
      unsigned char useNum;         // # of times it has been used so far
    };
    
  • Unsigned short limits signal types to 216 (less four for system = 65,532 client-specifiable signals)
  • Event type includes signal and parameters (defined in derived type)
  • struct without constructors and virtual methods enables re-use of event instances in event queue
  • General use pattern:
    1. State handler method receives generic QEvent * e
    2. Handler accesses e->sig
    3. Attribute sig must map uniquely to derived event type
    4. Handler accesses data after specific down cast to concrete event
  • Another example from QCalc[7]

| | Top of Page | 4. Implementating Behavioral Inheritance - 9 of 31