Loading...
Searching...
No Matches
EventReceiver.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith.
2// Malena Framework — Licensed under PolyForm Noncommercial 1.0.0; commercial use requires a paid license. See LICENSE.
3
4//
5// EventReceiver.h
6//
7
8#ifndef MALENA_EVENTRECEIVER_H
9#define MALENA_EVENTRECEIVER_H
10
11#pragma once
12
16#include <SFML/Window/Event.hpp>
17#include <map>
18#include <string>
19#include <vector>
20#include <optional>
21namespace ml
22{
23 class Core; // fwd: EventReceiver stores its owning Core (see _selfCore)
42 {
43 public:
53 virtual void process(const std::string& key,
54 const std::optional<sf::Event>& event);
55
66 template<typename ENUM_TYPE>
67 void process(ENUM_TYPE eventName, const std::optional<sf::Event>& event);
68
69 virtual ~EventReceiver() = default;
70
72
79 std::vector<EventCallback>& getCallbacks(const std::string& key);
81
93 Core* _selfCore = nullptr;
94
95 private:
96 std::map<std::string, std::vector<EventCallback>> _callbacks;
97 };
98
99} // namespace ml
100
101#include "../../../../src/Engine/Events/EventReceiver.tpp"
102#endif // MALENA_EVENTRECEIVER_H
Virtual base class for all Malena framework objects.
Definition Core.h:97
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.
#define MALENA_API
Definition Animate.h:25