Spore ModAPI  2.4.0
API for creating C++ mods for Spore
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
App::IMessageManager Class Referenceabstract

This manager defines a messaging system, that allows communication between different parts of the code. More...

#include <IMessageManager.h>

Inheritance diagram for App::IMessageManager:
App::cMessageManager

Classes

struct  Entry
 

Public Types

enum  Options { kOptionAllowLock = 0, kOptionRefCount = 4 }
 
typedef void(* MessageHandler_t) (uint32_t messageID, void *pData, void *pObject)
 A static message handler. This is the equivalent to the IMessageListener::HandleMessage() function. More...
 

Public Member Functions

virtual ~IMessageManager ()
 
virtual bool Initialize ()=0
 
virtual bool Dispose ()=0
 
virtual bool GetOption (Options option)=0
 Returns the boolean value of the specified option, in the IMessageManager::Options enum. More...
 
virtual void SetOption (Options option, bool bValue)=0
 Sets the boolean value of the specified option, in the IMessageManager::Options enum. More...
 
virtual void PostMSG (uint32_t messageID, void *pMessage, IMessageListener *pListener=nullptr)=0
 Sends a message in this manager, notifying all the interfaces listening for the specified message ID. More...
 
virtual void func18h (int, int, int)=0
 
virtual void func1Ch (int, int, int, int, int)=0
 
virtual void AddListener (IMessageListener *pListener, uint32_t messageID)=0
 Adds a message listener to this manager, that will be notified of messages with the specified ID. More...
 
void AddListener (LambdaMessageListener::HandleMessage_T function, const std::initializer_list< uint32_t > messageIDs)
 Adds a message listener to this manager, that will be notified of messages with the specified ID. More...
 
virtual void AddUnmanagedListener (IUnmanagedMessageListener *pListener, uint32_t messageID)=0
 Same as IMessageManager::AddListener(), but this does not call AddRef(). More...
 
virtual void AddHandler (MessageHandler_t pFunction, void *pObject, uint32_t messageID, bool bRefCounted=false, int nPriority=-1)=0
 Adds a static handler function to this manager, that will be notified of messages with the specified ID. More...
 
virtual bool RemoveListener (IMessageListener *pListener, uint32_t messageID, int nPriority=-9999)=0
 Makes the listener stop listening to the specified message ID. More...
 
virtual bool RemoveHandler (MessageHandler_t pFunction, uint32_t messageID, int nPriority=-9999)=0
 Makes the handler stop listening to the specified message ID. More...
 
virtual int func34h (int, int, int)=0
 
virtual int func38h ()=0
 
virtual int func3Ch ()=0
 
virtual int UseMutex (bool bLock)=0
 Locks or unlocks the mutexs in this manager, allowing to safely interact with this manager in different threads. More...
 

Static Public Member Functions

static IMessageManagerGet ()
 Returns the active message manager. More...
 

Protected Member Functions

virtual void AddEntry (const Entry &entry, uint32_t messageID)
 Adds the entry to listen to the given message ID. More...
 
virtual bool RemoveEntry (void *pMessageObject, uint32_t messageID, int nPriority=-9999)
 Removes the entry assigned at the given messageID with the given priority. More...
 

Detailed Description

This manager defines a messaging system, that allows communication between different parts of the code.

When a message is sent from any part of the code, all the objects that are listening to that specific message (which is identified using an ID) are notified. Therefore, all the parts of the code that need to react to certain events can be notified without he sender needing to know them.

To listen to messages, two things can be used. The first one, and the most common, is the IMessageListener interface, which allow classes to listen to messages. Another alternative is using a handler function, which is a static function that receives messages.

Member Typedef Documentation

◆ MessageHandler_t

typedef void(* App::IMessageManager::MessageHandler_t) (uint32_t messageID, void *pData, void *pObject)

A static message handler. This is the equivalent to the IMessageListener::HandleMessage() function.

Member Enumeration Documentation

◆ Options

Enumerator
kOptionAllowLock 

If true, this manager uses mutexs to work with threads. Additionally, the user can use the function IMessageManager::UseMutex(bool).

kOptionRefCount 

If true, the listeners added in the manager will be refcounted.

Constructor & Destructor Documentation

◆ ~IMessageManager()

virtual App::IMessageManager::~IMessageManager ( )
inlinevirtual

Member Function Documentation

◆ AddEntry()

virtual void App::IMessageManager::AddEntry ( const Entry entry,
uint32_t  messageID 
)
protectedvirtual

Adds the entry to listen to the given message ID.

Parameters
entryThe entry that contains the listener or handler function.
messageIDThe message ID the entry will be notified.

Reimplemented in App::cMessageManager.

◆ AddHandler()

virtual void App::IMessageManager::AddHandler ( MessageHandler_t  pFunction,
void *  pObject,
uint32_t  messageID,
bool  bRefCounted = false,
int  nPriority = -1 
)
pure virtual

Adds a static handler function to this manager, that will be notified of messages with the specified ID.

The same handler can be added multiple times using different priorities.

Parameters
pFunctionA pointer to the handler function.
pObjectAn object that will be sent as a parameter in the handler function.
messageIDThe ID of the messages the handler is listening to.
bRefCounted[Optional] If true and kOptionRefCount is true, a kMsgAddRef message will be sent on the handler.
nPriority[Optional] The priority of this handler.

Implemented in App::cMessageManager.

◆ AddListener() [1/2]

virtual void App::IMessageManager::AddListener ( IMessageListener pListener,
uint32_t  messageID 
)
pure virtual

Adds a message listener to this manager, that will be notified of messages with the specified ID.

A single listener can be listening to multiple message IDs. If the kOptionRefCount option is true, the IMessageListener::AddRef() method will be called on the listener.

Parameters
pListenerThe message listener to add.
messageIDThe ID of the messages the listener is listening to.

Implemented in App::cMessageManager.

◆ AddListener() [2/2]

void App::IMessageManager::AddListener ( LambdaMessageListener::HandleMessage_T  function,
const std::initializer_list< uint32_t >  messageIDs 
)
inline

Adds a message listener to this manager, that will be notified of messages with the specified ID.

A single listener can be listening to multiple message IDs.

Parameters
functionThe message listener to add.
messageIDsA list of the IDs of the messages the listener will listen to.

◆ AddUnmanagedListener()

virtual void App::IMessageManager::AddUnmanagedListener ( IUnmanagedMessageListener pListener,
uint32_t  messageID 
)
pure virtual

Same as IMessageManager::AddListener(), but this does not call AddRef().

Parameters
pListenerThe message listener to add.
messageIDThe ID of the messages the listener is listening to.

Implemented in App::cMessageManager.

◆ Dispose()

virtual bool App::IMessageManager::Dispose ( )
pure virtual

Implemented in App::cMessageManager.

◆ func18h()

virtual void App::IMessageManager::func18h ( int  ,
int  ,
int   
)
pure virtual

Implemented in App::cMessageManager.

◆ func1Ch()

virtual void App::IMessageManager::func1Ch ( int  ,
int  ,
int  ,
int  ,
int   
)
pure virtual

Implemented in App::cMessageManager.

◆ func34h()

virtual int App::IMessageManager::func34h ( int  ,
int  ,
int   
)
pure virtual

Implemented in App::cMessageManager.

◆ func38h()

virtual int App::IMessageManager::func38h ( )
pure virtual

Implemented in App::cMessageManager.

◆ func3Ch()

virtual int App::IMessageManager::func3Ch ( )
pure virtual

Implemented in App::cMessageManager.

◆ Get()

static IMessageManager* App::IMessageManager::Get ( )
static

Returns the active message manager.

Same as MessageManager().

◆ GetOption()

virtual bool App::IMessageManager::GetOption ( Options  option)
pure virtual

Returns the boolean value of the specified option, in the IMessageManager::Options enum.

Parameters
optionThe option whose value will be returned.

Implemented in App::cMessageManager.

◆ Initialize()

virtual bool App::IMessageManager::Initialize ( )
pure virtual

Implemented in App::cMessageManager.

◆ PostMSG()

virtual void App::IMessageManager::PostMSG ( uint32_t  messageID,
void *  pMessage,
IMessageListener pListener = nullptr 
)
pure virtual

Sends a message in this manager, notifying all the interfaces listening for the specified message ID.

Parameters
messageIDThe ID this message notifies.
pMessageData related to the message, not all messages need to use this.
pListener[Optional] The IMessageListener that will receive this message. If this is specified, no other listener will be notified.

Implemented in App::cMessageManager.

◆ RemoveEntry()

virtual bool App::IMessageManager::RemoveEntry ( void *  pMessageObject,
uint32_t  messageID,
int  nPriority = -9999 
)
protectedvirtual

Removes the entry assigned at the given messageID with the given priority.

If the priority is -9999, it will be ignored. If the entry is refcounted and kOptionRefCount is true, Release() will be called on the listener (or a kMsgRelease will be sent to the handler). This function works for both listeners and handlers.

Parameters
pMessageObjectThe handler or listener to remove.
messageIDThe message ID the entry will be removed from.
nPriority[Optional] The priority of the entry to be removed.
Returns
Whether the entry was removed or not.

Reimplemented in App::cMessageManager.

◆ RemoveHandler()

virtual bool App::IMessageManager::RemoveHandler ( MessageHandler_t  pFunction,
uint32_t  messageID,
int  nPriority = -9999 
)
pure virtual

Makes the handler stop listening to the specified message ID.

Optionally, a priority can be specified; if so, only if the handler with that priority will be removed.

Parameters
pFunctionThe handler function to remove.
messageIDThe ID of the messages the handler is listening to, and that will stop listening.
nPriority[Optional] The priority the handler must have to be removed. If it's -9999 (by default), it will be ignored.
Returns
Whether the handler was removed or not.

Implemented in App::cMessageManager.

◆ RemoveListener()

virtual bool App::IMessageManager::RemoveListener ( IMessageListener pListener,
uint32_t  messageID,
int  nPriority = -9999 
)
pure virtual

Makes the listener stop listening to the specified message ID.

Optionally, a priority can be specified; if so, only if the listener with that priority will be removed.

Parameters
pListenerThe listener to remove.
messageIDThe ID of the messages the listener is listening to, and that will stop listening.
nPriority[Optional] The priority the listener must have to be removed. If it's -9999 (by default), it will be ignored.
Returns
Whether the handler was removed or not.

Implemented in App::cMessageManager.

◆ SetOption()

virtual void App::IMessageManager::SetOption ( Options  option,
bool  bValue 
)
pure virtual

Sets the boolean value of the specified option, in the IMessageManager::Options enum.

Parameters
optionThe option whose value will be set.
bValueThe new boolean value of the option.

Implemented in App::cMessageManager.

◆ UseMutex()

virtual int App::IMessageManager::UseMutex ( bool  bLock)
pure virtual

Locks or unlocks the mutexs in this manager, allowing to safely interact with this manager in different threads.

If kOptionAllowLock is not true, this won't do anything.

Parameters
bLockTrue -> Lock; False -> Unlock

Implemented in App::cMessageManager.


The documentation for this class was generated from the following file: