Reputation: 1347
I have been reading about event managers and I understand the basic mechanics, or so I thought. I have been seeing situations where something such as
IEvent* pEvent = m_events;
while(pEvent) {
removeEvent(pEvent);
pEvent->Dispatch(); // What is this?
pEvent = pEvent->Next;
}
However, what is the point of doing "pEvent->Dispatch"? I thought it would have something to do with the event listening, but I am not exactly sure to be honest.
Upvotes: 1
Views: 126
Reputation: 70442
The "listening" for events has already completed by the time the code fragment you presented is being called. After "listening", all the events have been collected in some container, and each event needs to be processed. The Dispatch
is likely a virtual method on the IEvent
class, so that each derived event can be handled by a routine specific to that kind of event.
class IEvent {
protected:
virtual ~IEvent () {}
virtual void Dispatch () = 0;
//...
};
Upvotes: 2