#include <manager.h>
Collaboration diagram for MessageManager:
Public Member Functions | |
~MessageManager () | |
Static Public Member Functions | |
void | init () |
Initialize the message manger. | |
void | cleanup () |
Cleanup message manager. | |
void | PostMessage (const Message &m) |
Send a message to all the handlers. | |
void | DoExitOnFatal (bool yes_no) |
Select whether the manager should exit on a fatal message or not. | |
void | SelectMessageTypes (MessageHandler *hdl, Message::Type mask) |
Called by a message handler do set which sorts of messages it wants to receive. | |
bool | IsRequestedType (Message::Type t) |
Check if passed message type is requested by any handler. | |
void | RegisterHandler (MessageHandler *hdl) |
Internal registration function of message handlers called by their destructor. | |
void | UnregisterHandler (MessageHandler *hdl) |
Internal unregistration function of message handlers called by their destructor. | |
Private Member Functions | |
bool | _IsRequestedType (Message::Type t) const |
Check if passed message type is requested by any handler. | |
void | _PostMessage (const Message &m) |
Internally used to post a message to all the clients. | |
void | _RecomputeMTMask () |
Internally used to recompute the global message type mask. | |
void | _SelectMessageTypes (MessageHandler *hdl, Message::Type t) |
Internally used to select the message types for this handler. | |
void | _RegisterHandler (MessageHandler *hdl) |
Internally used method for message handler registration. | |
void | _UnregisterHandler (MessageHandler *hdl) |
Internally used method for message handler de-registration. | |
MessageManager (const MessageManager &) | |
Do use this class directly; just its static members. | |
void | operator= (const MessageManager &) |
MessageManager () | |
Do use this class directly; just its static members. | |
Private Attributes | |
LinkedList< MessageHandler > | hdl_list |
List of all message handler classes currently registered. | |
RecursiveMutex | main_mutex |
AtomicInt | type_mask |
bool | exit_on_fatal |
Exit after having delivered a fatal message? | |
Static Private Attributes | |
MessageManager * | manager = NULL |
Static message manager; created by init(). |
Definition at line 67 of file manager.h.
|
Do use this class directly; just its static members.
|
|
Do use this class directly; just its static members.
Definition at line 129 of file manager.cc. References Assert, CritAssert, exit_on_fatal, manager, and type_mask. Referenced by init(). |
|
Definition at line 145 of file manager.cc. References _UnregisterHandler(), Assert, LinkedList< MessageHandler >::first(), hdl_list, LinkedList< MessageHandler >::IsEmpty(), RecursiveMutex::lock(), main_mutex, manager, and RecursiveMutex::unlock(). |
|
Check if passed message type is requested by any handler.
Definition at line 92 of file manager.h. References type_mask, and AtomicInt::val(). Referenced by _PostMessage(), and IsRequestedType(). |
|
Internally used to post a message to all the clients.
Definition at line 26 of file manager.cc. References _IsRequestedType(), exit_on_fatal, LinkedList< MessageHandler >::first(), MessageHandler::HandleMessage(), hdl_list, RecursiveMutex::lock(), main_mutex, Message::MatchesTypeMask(), MessageHandler::mtmask, LinkedListBase< MessageHandler >::next, Message::type(), and RecursiveMutex::unlock(). Referenced by PostMessage(). |
|
Internally used to recompute the global message type mask.
Definition at line 63 of file manager.cc. References LinkedList< MessageHandler >::first(), hdl_list, MessageHandler::mtmask, LinkedListBase< MessageHandler >::next, AtomicInt::set(), and type_mask. Referenced by _SelectMessageTypes(), and _UnregisterHandler(). |
|
Internally used method for message handler registration.
Definition at line 93 of file manager.cc. References LinkedList< MessageHandler >::append(), hdl_list, RecursiveMutex::lock(), main_mutex, MessageHandler::mtmask, and RecursiveMutex::unlock(). Referenced by RegisterHandler(). |
|
Internally used to select the message types for this handler.
Definition at line 77 of file manager.cc. References _RecomputeMTMask(), RecursiveMutex::lock(), main_mutex, MessageHandler::mtmask, and RecursiveMutex::unlock(). Referenced by SelectMessageTypes(). |
|
Internally used method for message handler de-registration.
Definition at line 103 of file manager.cc. References _RecomputeMTMask(), LinkedList< MessageHandler >::dequeue(), hdl_list, RecursiveMutex::lock(), main_mutex, and RecursiveMutex::unlock(). Referenced by UnregisterHandler(), and ~MessageManager(). |
|
Cleanup message manager. The opposite of init(). Definition at line 121 of file manager.cc. References manager. Referenced by main(). |
|
Select whether the manager should exit on a fatal message or not. By default, the manager will do exit(2) after having delivered a fatal message. Definition at line 151 of file manager.h. References exit_on_fatal, and manager. |
|
Initialize the message manger. In order to use the message reporting routines, you must first initialize the message manager using MessageManager::init(), normally from the main thread.
Definition at line 114 of file manager.cc. References MessageManager(). Referenced by main(). |
|
Check if passed message type is requested by any handler.
Definition at line 163 of file manager.h. References _IsRequestedType(), and manager. |
|
|
|
Send a message to all the handlers. Normally, this is not meant to be called directly but via the provided message formatting functions like Warning(), Error(), Fatal(), Debug(). Definition at line 141 of file manager.h. References _PostMessage(), and manager. Referenced by _vaMessage(). |
|
Internal registration function of message handlers called by their destructor.
For internal use only.
Definition at line 170 of file manager.h. References _RegisterHandler(), and manager. Referenced by MessageHandler::MessageHandler(). |
|
Called by a message handler do set which sorts of messages it wants to receive.
For internal use only.
Definition at line 158 of file manager.h. References _SelectMessageTypes(), and manager. Referenced by MessageHandler::SelectMessageTypes(). |
|
Internal unregistration function of message handlers called by their destructor.
For internal use only.
Definition at line 177 of file manager.h. References _UnregisterHandler(), and manager. Referenced by MessageHandler::~MessageHandler(). |
|
Exit after having delivered a fatal message?
Definition at line 89 of file manager.h. Referenced by _PostMessage(), DoExitOnFatal(), and MessageManager(). |
|
List of all message handler classes currently registered.
Definition at line 78 of file manager.h. Referenced by _PostMessage(), _RecomputeMTMask(), _RegisterHandler(), _UnregisterHandler(), and ~MessageManager(). |
|
Mutex to protect the message handler list and the delivery process: Definition at line 81 of file manager.h. Referenced by _PostMessage(), _RegisterHandler(), _SelectMessageTypes(), _UnregisterHandler(), and ~MessageManager(). |
|
Static message manager; created by init().
Definition at line 23 of file manager.cc. Referenced by cleanup(), DoExitOnFatal(), IsRequestedType(), MessageManager(), PostMessage(), RegisterHandler(), SelectMessageTypes(), UnregisterHandler(), and ~MessageManager(). |
|
Bitfield of the message types requested by any message handler. This is actually a Message::Type, but we need the atomic type here. (There is an assertion to check for the size in manager.cc.) Definition at line 86 of file manager.h. Referenced by _IsRequestedType(), _RecomputeMTMask(), and MessageManager(). |