This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventDispatcher.h
58 lines (54 loc) · 1.97 KB
/
EventDispatcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* File: EventProcessor.h
* Author: max
*
* Created on 29 Октябрь 2013 г., 12:38
*/
#ifndef EVENTDISPARCHER_H
#define EVENTDISPARCHER_H
#include <vector>
#include <SDL2/SDL.h>
#include "IEventListener.h"
/**
* @brief Перенаправляет сообщение слушателям
*/
class EventDispatcher {
public:
/**
* @brief добавляет слушателя в список, если его еще там нет
* @param указатель на слушателя
*/
void addListener(IEventListener *);
/**
* @brief Удаляет слушателя из списка
* @param указатель на слушателя
*/
void deleteListener(const IEventListener*);
/**
* @brief Заменяет слушателя на другого.
* Не меняет, если параметры равны.
* Если первый не найден то хз что делать.
* И не известно что делать если 2й уже есть в списке
* На данный момент не делаем ничего
* @param кого менять
* @param на кого менять
*/
void replaceListener(const IEventListener *, IEventListener *);
/**
* @brief Отправка сообщения
* @param сообщение
* @return если сообщение обработано то указатель на обработавшего, иначе NULL
*/
IEventListener* dispatch(const SDL_Event*) ;
/**
* @brief Посылает каждому из списка сообщение "простой"
*/
void idle();
virtual ~EventDispatcher();
private:
typedef std::vector<IEventListener*> EventVector;
typedef EventVector::const_iterator const_iterator;
typedef EventVector::iterator iterator;
EventVector m_listeners; /// Список слушателей
};
#endif /* EVENTDISPARCHER_H */