|
|
#ifndef __BASICEVENTHANDLER_H_INCL__
#define __BASICEVENTHANDLER_H_INCL__
#include "basicEvent.h"
#include "basicRing.h"
/**
* Class to add a dispatchEvent functionality to derival classes * * @author Gagua */class basicEventHandler{ private:
bool m_bEventsAttached;
public:
// Constructor: registers the object for events at once. The heap may then call dispatchEvent()
// before the derived constructors have built their members; a class whose dispatchEvent() uses
// its members can pass attach = false and call attachEvents() at the end of its own constructor.
basicEventHandler(); explicit basicEventHandler(bool attach); void attachEvents(void); // Destructor
virtual ~basicEventHandler();
// Stops event delivery to this object (returns once a running dispatchEvent() finished).
// ~basicEventHandler does it too, but only after the derived destructors have destroyed their
// members - a class whose dispatchEvent() uses its members should call this first thing in its
// own destructor. Safe to call more than once.
void detachEvents(void);
virtual bool dispatchEvent(EVENT_CONTAINER * Evt) { if ( Evt == NULL ) return false; return true; }};
typedef basicRingElement<basicEventHandler> EventHandlerIterator;typedef basicRing<basicEventHandler> EventHandlerRing;
#endif // __BASICEVENTHANDLER_H_INCL__
|