IEventListener.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include "IEvent.h"
6 
7 
8 class IEventListener : public IMultiTreeNode<IEventListener>
9 {
10 
11 public:
12 
13  virtual void OnEvent(IEvent & Event)
14  {}
15 
16  void AddListener(IEventListener * Listener)
17  {
19  }
20 
21  void RemoveListener(IEventListener * Listener)
22  {
24  }
25 
26 protected:
27 
29 
30  void TriggerEvent(IEvent & Event)
31  {
32  OnEvent(Event);
33  if (! Event.IsBlocked())
34  for (auto it = Children.begin(); it != Children.end(); ++ it)
35  (* it)->TriggerEvent(Event);
36  Event.Unblock();
37  }
38 
39 };
virtual void OnEvent(IEvent &Event)
Definition: IEventListener.h:13
std::set< IEventListener * > Children
Definition: ionTreeNode.h:161
bool IsBlocked() const
Definition: IEvent.h:22
void Unblock()
Definition: IEvent.h:17
Definition: IEvent.h:7
Definition: IEventListener.h:8
void AddChild(Implementation *Child)
Definition: ionTreeNode.h:120
void RemoveChild(Implementation *Child)
Definition: ionTreeNode.h:125
void AddListener(IEventListener *Listener)
Definition: IEventListener.h:16
Variant of ITreeNode that doesn&#39;t require a single parent relationship.
Definition: ionTreeNode.h:110
void TriggerEvent(IEvent &Event)
Definition: IEventListener.h:30
void RemoveListener(IEventListener *Listener)
Definition: IEventListener.h:21