- Began new overarching window interface - Began outlining renderer interfaces - Began a binary tree implementation in bintree.h, this will act as a generalized binary tree, then red-black tree will be implemented on top of it for sequences (ordered sets)
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
// =====================================================================================================================
|
|
// fennec, a free and open source game engine
|
|
// Copyright © 2025 Medusa Slockbower
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
// =====================================================================================================================
|
|
|
|
#ifndef FENNEC_CORE_EVENT_H
|
|
#define FENNEC_CORE_EVENT_H
|
|
|
|
#include <fennec/lang/types.h>
|
|
#include <fennec/lang/typed.h>
|
|
|
|
namespace fennec
|
|
{
|
|
|
|
struct event;
|
|
|
|
class event_listener {
|
|
public:
|
|
virtual ~event_listener() = default;
|
|
virtual void handle_event(event* event) = 0;
|
|
};
|
|
|
|
struct event {
|
|
const uint64_t type;
|
|
|
|
event() = delete;
|
|
|
|
template<typename EventT>
|
|
event() : type(typeuuid<EventT>()) { }
|
|
|
|
template<typename EventT>
|
|
static void add_listener(event_listener* listener) {
|
|
event::add_listener(listener, typeuuid<EventT, event>());
|
|
}
|
|
|
|
template<typename EventT>
|
|
static void dispatch(EventT* event) {
|
|
dispatch(event);
|
|
}
|
|
|
|
static void add_listener(event_listener* listener, uint64_t type);
|
|
static void remove_listener(event_listener* listener);
|
|
static void dispatch(event* event);
|
|
};
|
|
|
|
}
|
|
|
|
#endif // FENNEC_CORE_EVENT_H
|