Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

PolymorphEvent Class Reference

#include <PolymorphEvent.hh>

List of all members.

Public Methods

virtual void send () const=0

Protected Methods

virtual ~PolymorphEvent ()
 Need virtual destructor for polymorphic queues.


Static Protected Methods

template<typename EvType> void sendTypedEvent (const EvType &event)


Detailed Description

Derive your class from a PolymorphEvent to make it usable polymorphically. This just requires that your event subclass then define the send() pure virtual method, typically simply as
    struct ConcreteEvent: public PolymorphEvent
    {
        // ... your event-specific data and methods ...
        // ... and the override:
        virtual void send() const { sendTypedEvent(*this); }
    };

Definition at line 38 of file PolymorphEvent.hh.


Member Function Documentation

virtual void PolymorphEvent::send   [pure virtual]
 

Causes this event to be sent out to all listeners. The subclass must provide an override so the event can be used polymorphically. This allows you to have a container of PolymorphEvent's of unknown concrete types, e.g. to queue events of different types.

Referenced by EventSender< PolymorphEvent >::send().

template<typename EvType>
void PolymorphEvent::sendTypedEvent const EvType &    event [inline, static, protected]
 

The class derived from PolymorphEvent must override send() to make it call EventSender<EvType>::send(). It can also simply override it by making it call this method, sendTypedEvent, with *this. This method is really just a helper to simplify the syntax required for overriding send().

Definition at line 62 of file PolymorphEvent.hh.


The documentation for this class was generated from the following file:
Generated on Sun Feb 16 16:56:24 2003 for C++ Event Handling Template Library by doxygen1.2.18