|
AGXDynamics
2.31.1.0
|
Class for polling messages from the LOGGER system in a Subscriber pattern. More...
#include <LoggerSubscriber.h>
Inheritance diagram for agx::LoggerSubscriber:Classes | |
| class | LogCallback |
Public Types | |
| typedef std::pair< int, agx::String > | Message |
| typedef agx::Vector< Message > | MessageVector |
Public Member Functions | |
| LoggerSubscriber (int levelMask=agx::Notify::NOTIFY_INFO|agx::Notify::NOTIFY_WARNING|agx::Notify::NOTIFY_ERROR) | |
| Constructor for a logger mailbox. More... | |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| void | clear (int levelMask=ALL_LEVELS) |
| Remove all messages. More... | |
| bool | empty (int levelMask=ALL_LEVELS) const |
| bool | getEnable () const |
| bool | getMessages (MessageVector &messages, bool clearMessages, int levelMask=ALL_LEVELS) |
Get a copy of all messages matching the specified notify level levelMask in the message queue. More... | |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| std::string | pop (int levelMask=ALL_LEVELS) |
| Get all available messages and then remove them. More... | |
| size_t | pop (agx::StringVector &outMessages, int levelMask=ALL_LEVELS) |
| Get all available messages and then remove them. More... | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| void | setEnable (bool flag) |
| Enable/disable the capturing of messages. More... | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Static Public Attributes | |
| static int | ALL_LEVELS |
Protected Member Functions | |
| virtual | ~LoggerSubscriber () |
| Destructor. More... | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
| void | message (const agx::String &msg, int notifyLevel) |
| Callback that will be called when a new message is present. More... | |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
Class for polling messages from the LOGGER system in a Subscriber pattern.
Messages is stored until the message pop() is called. The class is reentrant thread safe.
There are a message queue for each NotifyLevel. So all methods can use a bitmask to filter out which queue that is requested.
Definition at line 33 of file LoggerSubscriber.h.
| typedef std::pair<int, agx::String> agx::LoggerSubscriber::Message |
Definition at line 87 of file LoggerSubscriber.h.
Definition at line 88 of file LoggerSubscriber.h.
| agx::LoggerSubscriber::LoggerSubscriber | ( | int | levelMask = agx::Notify::NOTIFY_INFO|agx::Notify::NOTIFY_WARNING|agx::Notify::NOTIFY_ERROR | ) |
Constructor for a logger mailbox.
| levelMask | - Specifies which levels of messages that will be captured. Default is all messages with equal or higher level that NOTIFY_INFO. |
|
protectedvirtual |
Destructor.
|
protectedinherited |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
| void agx::LoggerSubscriber::clear | ( | int | levelMask = ALL_LEVELS | ) |
Remove all messages.
| levelMask | - Specifies which levels of messages that should be cleared, by default all levels |
|
protectedinherited |
| bool agx::LoggerSubscriber::empty | ( | int | levelMask = ALL_LEVELS | ) | const |
| levelMask | - Specifies which levels of messages that should be checked for, by default all levels |
|
staticprotectedinherited |
| bool agx::LoggerSubscriber::getEnable | ( | ) | const |
| bool agx::LoggerSubscriber::getMessages | ( | MessageVector & | messages, |
| bool | clearMessages, | ||
| int | levelMask = ALL_LEVELS |
||
| ) |
Get a copy of all messages matching the specified notify level levelMask in the message queue.
Each message contains a pair of: NOTIFY level (INFO, WARNING, ERROR) and the message string in chronological order
| messages | - Reference to a message queue that will be populated with all the matching messages |
| clearMessages | - If true, the message queue will be cleared from the matching messages |
|
inherited |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::EntityStorage::getInstances(), and agx::Object::getResource().
|
protected |
Callback that will be called when a new message is present.
| std::string agx::LoggerSubscriber::pop | ( | int | levelMask = ALL_LEVELS | ) |
Get all available messages and then remove them.
| levelMask | - Specifies which levels of messages that should be checked for. |
| size_t agx::LoggerSubscriber::pop | ( | agx::StringVector & | outMessages, |
| int | levelMask = ALL_LEVELS |
||
| ) |
Get all available messages and then remove them.
| [out] | outMessages | - Where messages will be stored |
| levelMask | - Specifies which levels of messages that should be captured. |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
| void agx::LoggerSubscriber::setEnable | ( | bool | flag | ) |
Enable/disable the capturing of messages.
| flag | - If true messages will be captured |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
|
staticinherited |
|
static |
Definition at line 38 of file LoggerSubscriber.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.