ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
ilog::IMessageConsumer Class Referenceabstract

Common interface for a message container consuming information objects (messages). More...

#include <IMessageConsumer.h>

Inheritance diagram for ilog::IMessageConsumer:
istd::IPolymorphic ilog::TMessageDelegatorComp< icomp::CComponentBase > ilog::CMessageContainer ilog::TMessageDelegatorComp< BaseComponent > iloggui::CMessageBoxComp iqtgui::CGuiApplicationComp::TrayMessages iqtgui::CSplashScreenGuiComp ilog::CLogCompBase ilog::CLogComp iloggui::CLogGuiComp ilog::CLogComp ilog::CStreamLogCompBase ifile::CTextFileLogComp ifile::CTextFileLogStreamerComp ilog::CConsoleLogComp

Public Types

typedef istd::TSharedInterfacePtr< istd::IInformationProviderMessagePtr
 Shared pointer type for message objects.
 

Public Member Functions

virtual bool IsMessageSupported (int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const =0
 Check if a message is supported by this consumer.
 
virtual void AddMessage (const MessagePtr &messagePtr)=0
 Adds a message to this consumer.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Detailed Description

Common interface for a message container consuming information objects (messages).

This is the fundamental interface in the ilog library that all message consumers must implement. It provides a standardized way to check message support and add messages to the consumer.

The interface uses a shared pointer (MessagePtr) for message ownership, ensuring automatic memory management. Consumers can be chained together, filtered, or routed based on message properties.

Thread Safety
Implementations must handle thread safety. Most implementations use Qt signals for thread-safe message delivery.
Usage Example
// Create a consumer
// Check if consumer accepts error messages
if (consumer->IsMessageSupported(istd::IInformationProvider::IC_ERROR)) {
// Create and send error message
1001, "Error occurred", "Module"));
consumer->AddMessage(msg);
}
Basic implementation of the istd::IInformationProvider interface for log messages.
Definition CMessage.h:80
@ IC_ERROR
Information about error, processing could not be done correctly.
Shared ownership smart pointer for interface types.
See also
ilog::CLogComp, ilog::CConsoleLogComp, ilog::CMessageContainer

Definition at line 47 of file IMessageConsumer.h.

Member Typedef Documentation

◆ MessagePtr

Shared pointer type for message objects.

Definition at line 51 of file IMessageConsumer.h.

Member Function Documentation

◆ AddMessage()

virtual void ilog::IMessageConsumer::AddMessage ( const MessagePtr messagePtr)
pure virtual

Adds a message to this consumer.

This method transfers ownership of the message to the consumer via shared pointer. The consumer may store, display, forward, or otherwise process the message.

Most implementations deliver messages asynchronously using Qt signals/slots to ensure thread safety when messages are added from worker threads.

Parameters
messagePtrShared pointer to the message. After this call, the message is owned by the shared pointer and will be automatically deleted when no longer referenced.
Note
This method should not throw exceptions. Implementations should handle errors gracefully (e.g., by logging internally or ignoring invalid messages).
Warning
The message object should not be modified after being added to a consumer, as multiple consumers may reference the same message object.
Example
// Create message with shared pointer
2001,
"File not found: config.xml",
"ConfigLoader"
)
);
// Add to consumer (ownership transferred)
consumer->AddMessage(msg);
// msg can still be used as shared pointer maintains reference count
// but don't modify the message after adding it
See also
IsMessageSupported()

Implemented in ilog::CMessageContainer, ilog::CLogComp, ilog::CLogCompBase, ilog::TMessageDelegatorComp< BaseComponent >, ilog::TMessageDelegatorComp< icomp::CComponentBase >, iloggui::CLogGuiComp, iloggui::CMessageBoxComp, iqtgui::CGuiApplicationComp::TrayMessages, and iqtgui::CSplashScreenGuiComp.

◆ IsMessageSupported()

virtual bool ilog::IMessageConsumer::IsMessageSupported ( int  messageCategory = -1,
int  messageId = -1,
const istd::IInformationProvider messagePtr = NULL 
) const
pure virtual

Check if a message is supported by this consumer.

This method allows consumers to filter messages based on category, ID, or the complete message object. It's used to determine whether a message should be sent to this consumer before actually adding it.

Parameters
messageCategoryCategory of message (IC_NONE, IC_INFO, IC_WARNING, IC_ERROR, IC_CRITICAL) or -1 if category check should be skipped.
See also
istd::IInformationProvider::InformationCategory.
Parameters
messageIdNumeric ID of message or -1 if ID check should be skipped. Message IDs are application-defined for filtering and routing.
messagePtrOptional pointer to complete message object for detailed inspection, or NULL if not needed. The consumer will not store this pointer.
Returns
true if the message is supported and should be sent to this consumer, false if the message should be filtered out.
Note
Returning false does not indicate an error; it simply means the message doesn't match the consumer's filter criteria.
Example
// Check if consumer accepts warnings
if (consumer->IsMessageSupported(istd::IInformationProvider::IC_WARNING)) {
// Consumer accepts warnings
}
// Check specific message ID
if (consumer->IsMessageSupported(-1, 5001)) {
// Consumer accepts message ID 5001
}
// Check complete message
if (consumer->IsMessageSupported(-1, -1, &msg)) {
// Consumer accepts this specific message
}
@ IC_INFO
Normal information level.
@ IC_WARNING
Information about warning, processing could be done.

Implemented in ilog::CLogComp, ilog::CMessageContainer, ilog::CStreamLogCompBase, ilog::TMessageDelegatorComp< BaseComponent >, ilog::TMessageDelegatorComp< icomp::CComponentBase >, iloggui::CLogGuiComp, iloggui::CMessageBoxComp, iqtgui::CGuiApplicationComp::TrayMessages, and iqtgui::CSplashScreenGuiComp.


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