AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agx::LoggerSubscriber Class Reference

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.
 
void clear (int levelMask=ALL_LEVELS)
 Remove all messages.
 
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.
 
size_t pop (agx::StringVector &outMessages, int levelMask=ALL_LEVELS)
 Get all available messages and then remove them.
 
std::string pop (int levelMask=ALL_LEVELS)
 Get all available messages and then remove them.
 
void setEnable (bool flag)
 Enable/disable the capturing of messages.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Attributes

static int ALL_LEVELS
 

Protected Member Functions

virtual ~LoggerSubscriber ()
 Destructor.
 
void message (const agx::String &msg, int notifyLevel)
 Callback that will be called when a new message is present.
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

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.

Member Typedef Documentation

◆ Message

Definition at line 87 of file LoggerSubscriber.h.

◆ MessageVector

Constructor & Destructor Documentation

◆ LoggerSubscriber()

agx::LoggerSubscriber::LoggerSubscriber ( int  levelMask = agx::Notify::NOTIFY_INFO|agx::Notify::NOTIFY_WARNING|agx::Notify::NOTIFY_ERROR)

Constructor for a logger mailbox.

Parameters
levelMask- Specifies which levels of messages that will be captured. Default is all messages with equal or higher level that NOTIFY_INFO.

◆ ~LoggerSubscriber()

virtual agx::LoggerSubscriber::~LoggerSubscriber ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ clear()

void agx::LoggerSubscriber::clear ( int  levelMask = ALL_LEVELS)

Remove all messages.

Parameters
levelMask- Specifies which levels of messages that should be cleared, by default all levels

◆ empty()

bool agx::LoggerSubscriber::empty ( int  levelMask = ALL_LEVELS) const
Parameters
levelMask- Specifies which levels of messages that should be checked for, by default all levels
Returns
true if no messages are present

◆ getEnable()

bool agx::LoggerSubscriber::getEnable ( ) const
Returns
true if messages are being captured

◆ getMessages()

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

Parameters
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
Returns
true if any messages were awailable.

◆ message()

void agx::LoggerSubscriber::message ( const agx::String &  msg,
int  notifyLevel 
)
protected

Callback that will be called when a new message is present.

◆ pop() [1/2]

size_t agx::LoggerSubscriber::pop ( agx::StringVector &  outMessages,
int  levelMask = ALL_LEVELS 
)

Get all available messages and then remove them.

Parameters
[out]outMessages- Where messages will be stored
levelMask- Specifies which levels of messages that should be captured.
Returns
the number of available messages

◆ pop() [2/2]

std::string agx::LoggerSubscriber::pop ( int  levelMask = ALL_LEVELS)

Get all available messages and then remove them.

Parameters
levelMask- Specifies which levels of messages that should be checked for.
Returns
all messages concatenated into a string. Messages will be separated with a newline

◆ setEnable()

void agx::LoggerSubscriber::setEnable ( bool  flag)

Enable/disable the capturing of messages.

Parameters
flag- If true messages will be captured

Member Data Documentation

◆ ALL_LEVELS

int agx::LoggerSubscriber::ALL_LEVELS
static

Definition at line 38 of file LoggerSubscriber.h.


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