Event manager priority chaining

listeners can register with a priority to get an event into an ordered stream of listeners
This commit is contained in:
marauder2k7 2026-02-19 10:06:54 +00:00
parent 562756a306
commit 299d358d0b
2 changed files with 63 additions and 42 deletions

View file

@ -47,11 +47,13 @@ class EventManagerListener : public Dispatcher::IMessageListener
/// Stores subscription information for a subscriber.
struct Subscriber
{
SimObjectPtr< SimObject > listener; ///< The listener object.
StringTableEntry callback; ///< The callback to execute when the event is triggered.
StringTableEntry event; ///< The event being listened for.
U32 callDepth;
bool removeFlag;
SimObjectPtr< SimObject > listener; ///< The listener object.
StringTableEntry callback; ///< The callback to execute when the event is triggered.
StringTableEntry event; ///< The event being listened for.
S32 priority;
U32 callDepth;
bool removeFlag;
};
/// Subscriber table hashed by event name.
@ -154,7 +156,7 @@ public:
/// Triggers an event.
bool postEvent( const char* eventName, const char* data );
/// Adds a subscription to an event.
bool subscribe( SimObject *callbackObj, const char* event, const char* callback = NULL );
bool subscribe( SimObject *callbackObj, const char* event, const char* callback = NULL, S32 priority = 0 );
/// Remove a subscriber from an event.
void remove( SimObject *cbObj, const char* event );
void removeAll( SimObject *cbObj );