class ResourceListenerManager

Handles all active implementations of IResourceListener interface and notifies them when events they're listening to occur.

Public

Constructors

ResourceListenerManager

ResourceListenerManager()

Methods

~ResourceListenerManager

~ResourceListenerManager() noexcept

RegisterListener

void RegisterListener(IResourceListener *listener)

Register a new listener to notify for events.

UnregisterListener

void UnregisterListener(IResourceListener *listener)

Unregister a listener so it will no longer receive notifications.

MarkListenerDirty

void MarkListenerDirty(IResourceListener *listener)

Marks the listener as dirty which forces the manager to updates its internal list of resources for the listener.

Update

void Update()

Refreshes the resource maps based on dirty listeners and sends out the necessary events.

NotifyListeners

void NotifyListeners(const UUID &resourceUUID)

Forces the listener to send out events about the specified resource immediately, instead of waiting for the next Update() call.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Methods

UpdateListeners

void UpdateListeners()

Refreshes the listener mapping for any listeners marked as dirty.

OnResourceLoaded

void OnResourceLoaded(const HResource &resource)

Triggered by the resources system when a resource has finished loading.

OnResourceModified

void OnResourceModified(const HResource &resource)

Triggered by the resources system after a resource handle is modified (points to a new resource).

SendResourceLoaded

void SendResourceLoaded(const HResource &resource)

Sends resource loaded event to all listeners referencing this resource.

SendResourceModified

void SendResourceModified(const HResource &resource)

Sends resource modified event to all listeners referencing this resource.

ClearDependencies

void ClearDependencies(IResourceListener *listener)

Clears all the stored dependencies for the listener.

AddDependencies

void AddDependencies(IResourceListener *listener)

Registers all the resource dependencies for the listener.

Fields

mResourceLoadedConn

HEvent mResourceLoadedConn

mResourceModifiedConn

HEvent mResourceModifiedConn

mDirtyListeners

Set<IResourceListener *> mDirtyListeners

mResourceToListenerMap

Map<u64, Vector<IResourceListener *>> mResourceToListenerMap

mListenerToResourceMap

Map<IResourceListener *, Vector<u64>> mListenerToResourceMap

mLoadedResources

Map<UUID, HResource> mLoadedResources

mModifiedResources

Map<UUID, HResource> mModifiedResources

mTempResourceBuffer

Vector<HResource> mTempResourceBuffer

mTempListenerBuffer

Vector<IResourceListener *> mTempListenerBuffer

mMutex

RecursiveMutex mMutex