You.i Engine
YiEventHandler.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_EVENT_HANDLER_H_
3 #define _YI_EVENT_HANDLER_H_
4 
5 #include "framework/YiPredef.h"
6 #include "utility/YiLazy.h"
7 
8 #include <memory>
9 #include <mutex>
10 
17 class CYIEventFilter;
19 class CYIEvent;
20 class CYIEventDispatcher;
21 
26 {
27  friend class CYIEventDispatcher;
28 
29  typedef std::vector<std::shared_ptr<CYIEventFilterProxy>> YI_EVENT_FILTER_LIST;
30 
31 public:
34  virtual ~CYIEventHandler();
35 
37 
50  bool RegisterEventFilter(CYIEventFilter *pFilter);
51 
63 
69  bool PreFilter(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent);
70 
76  bool PostFilter(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent);
77 
83  bool AreEventsEnabled() const;
84 
88  void EnableEvents(bool enable);
89 
95  virtual bool HandleEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent) = 0;
96 
97 protected:
99 
100 private:
101  CYILazy<std::mutex> m_filterList;
102  std::shared_ptr<CYIEventHandlerProxy> m_pEventHandlerProxy;
103  YI_EVENT_FILTER_LIST m_eventFilterList;
104 };
105 
108 #endif /* _YI_EVENT_HANDLER_H_ */
bool RegisterEventFilter(CYIEventFilter *pFilter)
Allows registering of event filters which can be used to perform processing on an event before and af...
Definition: YiEventHandler.h:25
bool AreEventsEnabled() const
Base class for events.
Definition: YiEvent.h:27
bool PreFilter(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent)
Proxy for a CYIEventFilter allowing safe destruction of the internal event filter objects...
Definition: YiEventFilterProxy.h:24
void EnableEvents(bool enable)
bool m_enableEvents
Definition: YiEventHandler.h:98
virtual bool HandleEvent(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent)=0
virtual ~CYIEventHandler()
bool PostFilter(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent)
Stores, queues and dispatches events as well as sending notifications to IYIEventDispatcherListener o...
Definition: YiEventDispatcher.h:66
Allows children that inherit from this class to implement processing before and after events are hand...
Definition: YiEventFilter.h:24
bool UnregisterEventFilter(CYIEventFilter *pFilter)
Proxy for a CYIEventHandler allowing safe destruction of the internal event handler objects...
Definition: YiEventHandlerProxy.h:25
CYIEventHandler & operator=(const CYIEventHandler &)