9 #ifndef __EventEmitter_h
10 #define __EventEmitter_h
31 template<
typename FuncType>
38 void on (
const std::string& event_name, FuncType func);
40 void on (
const std::string& event_name, FuncType* func);
42 template<
class ... Types>
43 void emit (
const std::string& event_name, Types ... args);
47 std::map<std::string, std::vector<FuncType*> > event_map;
52 template<
typename FuncType>
56 template<
typename FuncType>
59 on(event_name, &_func);
62 template<
typename FuncType>
65 if (event_map.find(event_name) == event_map.end()) {
66 event_map[event_name] = {_func};
68 event_map[event_name].push_back(_func);
72 template<
typename FuncType>
73 template<
class ... Types>
76 if (event_map.find(event_name) != event_map.end())
78 auto func_b = event_map[event_name].begin();
79 auto func_e = event_map[event_name].end();
80 for (; func_b != func_e; func_b++) {