add table impl

This commit is contained in:
Robin Müller 2022-11-16 10:20:44 +01:00
parent 9cc58432c8
commit 01f500a409
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -96,6 +96,14 @@ pub trait EventReceiver<Event: GenericEvent, AuxDataProvider = Params> {
fn receive(&mut self) -> Option<(Event, Option<AuxDataProvider>)>;
}
pub trait ListenerTable<SendProviderError, Event: GenericEvent = EventU32, AuxDataProvider = Params>
{
fn get_listeners(
&mut self,
key: ListenerType,
) -> &[Listener<SendProviderError, Event, AuxDataProvider>];
}
/// Generic event manager implementation.
///
/// # Generics
@ -107,6 +115,7 @@ pub trait EventReceiver<Event: GenericEvent, AuxDataProvider = Params> {
pub struct EventManager<SendProviderError, Event: GenericEvent = EventU32, AuxDataProvider = Params>
{
listeners: HashMap<ListenerType, Vec<Listener<SendProviderError, Event, AuxDataProvider>>>,
//listener_table: Box<dyn ListenerTable<SendProviderError, Event, AuxDataProvider>>,
event_receiver: Box<dyn EventReceiver<Event, AuxDataProvider>>,
}