IEventListener.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "IMultiTreeNode.h"
5 #include "IEvent.h"
6 
7 
8 class IEventListener : public ion::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  void TriggerEvent(IEvent & Event)
27  {
28  OnEvent(Event);
29  if (! Event.IsBlocked())
30  for (auto it = Children.begin(); it != Children.end(); ++ it)
31  (* it)->TriggerEvent(Event);
32  Event.Unblock();
33  }
34 
35 protected:
36 
38 
39 };
virtual void OnEvent(IEvent &Event)
Definition: IEventListener.h:13
bool IsBlocked() const
Definition: IEvent.h:20
void Unblock()
Definition: IEvent.h:15
Definition: IEvent.h:5
set< IEventListener * > Children
Definition: IMultiTreeNode.h:66
Definition: IEventListener.h:8
void RemoveChild(IEventListener *Child)
Definition: IMultiTreeNode.h:30
void AddListener(IEventListener *Listener)
Definition: IEventListener.h:16
void AddChild(IEventListener *Child)
Definition: IMultiTreeNode.h:25
void TriggerEvent(IEvent &Event)
Definition: IEventListener.h:26
void RemoveListener(IEventListener *Listener)
Definition: IEventListener.h:21
Variant of ITreeNode that doesn&#39;t require a single parent relationship.
Definition: IMultiTreeNode.h:15