34 lines
887 B
C
34 lines
887 B
C
#pragma once
|
|
|
|
#include "aliases.h"
|
|
|
|
enum {
|
|
ES_INIT_SUCCESS = 0,
|
|
ES_INIT_NULL_POINTER,
|
|
ES_INIT_ALREADY_INITIALISED,
|
|
ES_INIT_ALLOCATION_FAILED,
|
|
};
|
|
|
|
typedef struct event Event;
|
|
struct event {
|
|
u64 id;
|
|
};
|
|
|
|
typedef struct event_listener EventListener;
|
|
struct event_listener {
|
|
Event event;
|
|
u64 id;
|
|
};
|
|
|
|
typedef struct event_system EventSystem;
|
|
|
|
typedef void (EventCallback)(void *data);
|
|
|
|
u32 es_init(EventSystem **es, u64 initial_event_capacity, u64 initial_listeners_capacity);
|
|
void es_deinit(EventSystem **es);
|
|
Event es_register_event(EventSystem *es);
|
|
void es_deregister_event(EventSystem *es, Event event);
|
|
EventListener es_add_event_listener(EventSystem *es, u64 id, EventCallback *listener);
|
|
void es_remove_event_listener(EventSystem *es, EventListener listener);
|
|
void es_emit_event(EventSystem *es, u64 id, void *data);
|