Loading...
Searching...
No Matches
EventReceiver.h
Go to the documentation of this file.
1//
2// EventReceiver.h
3//
4
5#ifndef EVENTRECEIVER_H
6#define EVENTRECEIVER_H
7
8#pragma once
9
12#include <SFML/Window/Event.hpp>
13#include <map>
14#include <string>
15#include <vector>
16
17namespace ml
18{
37 {
38 public:
48 virtual void process(const std::string& key,
49 const std::optional<sf::Event>& event);
50
61 template<typename ENUM_TYPE>
62 void process(ENUM_TYPE eventName, const std::optional<sf::Event>& event);
63
64 virtual ~EventReceiver() = default;
65
67
74 std::vector<EventCallback>& getCallbacks(const std::string& key);
76
77 private:
78 std::map<std::string, std::vector<EventCallback>> _callbacks;
79 };
80
81} // namespace ml
82
83#include "../../../../src/Engine/Events/EventReceiver.tpp"
84#endif // EVENTRECEIVER_H
Base class for all event-receiving traits.
virtual ~EventReceiver()=default
void process(ENUM_TYPE eventName, const std::optional< sf::Event > &event)
Invoke all callbacks registered for eventName.
virtual void process(const std::string &key, const std::optional< sf::Event > &event)
Invoke all callbacks registered for key.
Definition Component.h:18