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

Base implementation for logging components using Qt event queue. More...

#include <CLogCompBase.h>

Inheritance diagram for ilog::CLogCompBase:
ilog::TMessageDelegatorComp< icomp::CComponentBase > icomp::CComponentBase ilog::IMessageConsumer icomp::IComponent istd::IPolymorphic istd::IPolymorphic ilog::CLogComp ilog::CStreamLogCompBase ifile::CTextFileLogComp ifile::CTextFileLogStreamerComp ilog::CConsoleLogComp

Public Types

typedef ilog::TMessageDelegatorComp< icomp::CComponentBaseBaseClass
 Base class typedef for component functionality.
 
typedef QObject BaseClass2
 Base class typedef for QObject functionality.
 
- Public Types inherited from ilog::TMessageDelegatorComp< icomp::CComponentBase >
typedef icomp::CComponentBase BaseClass
 Base class typedef.
 
- Public Types inherited from ilog::IMessageConsumer
typedef istd::TSharedInterfacePtr< istd::IInformationProviderMessagePtr
 Shared pointer type for message objects.
 

Signals

void EmitAddMessage (const MessagePtr &messagePtr)
 Signal emitted when a message is added.
 

Public Member Functions

 CLogCompBase ()
 Default constructor.
 
virtual void AddMessage (const MessagePtr &messagePtr) override
 Add a message to this log component.
 
- Public Member Functions inherited from ilog::TMessageDelegatorComp< icomp::CComponentBase >
virtual bool IsMessageSupported (int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
 Check if a message is supported.
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Member Functions

virtual void WriteMessageToLog (const MessagePtr &messagePtr)=0
 Abstract method called to process a message.
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual void OnComponentCreated ()
 
virtual void OnComponentDestroyed ()
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 

Additional Inherited Members

- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 

Detailed Description

Base implementation for logging components using Qt event queue.

CLogCompBase provides thread-safe message delivery by using Qt signals and slots to transport messages between threads. When AddMessage() is called (potentially from a worker thread), it emits a signal that's delivered on the component's thread where WriteMessageToLog() is called.

This class combines QObject (for signals/slots) with TMessageDelegatorComp to provide both thread-safe message handling and message delegation capabilities.

Derived classes must implement WriteMessageToLog() to define what happens to messages when they arrive.

Thread Safety
AddMessage() is thread-safe and can be called from any thread. The message is queued via Qt's signal/slot mechanism and processed on the component's thread. This makes it safe to log from worker threads to a UI-based log viewer or any other thread-sensitive consumer.
Message Delegation
Inherits from TMessageDelegatorComp, so messages can be forwarded to a slave consumer if configured. This allows chaining multiple log handlers.
Signal/Slot Mechanism
Uses EmitAddMessage signal connected to OnAddMessage slot. Qt handles thread transitions automatically based on the connection type.
Usage Example
// Derive to create custom log component
class MyLogComp : public ilog::CLogCompBase
{
protected:
virtual void WriteMessageToLog(const MessagePtr& messagePtr) override {
// Process message on component's thread
qDebug() << messagePtr->GetInformationDescription();
// Forward to slave consumer if present
if (m_slaveMessageConsumerCompPtr.IsValid()) {
m_slaveMessageConsumerCompPtr->AddMessage(messagePtr);
}
}
};
// Usage from any thread
MyLogComp* log = new MyLogComp;
// ... initialize component ...
// Safe to call from worker thread
log->AddMessage(messagePtr);
Base implementation for logging components using Qt event queue.
Shared ownership smart pointer for interface types.
See also
ilog::CLogComp, ilog::CConsoleLogComp, ilog::CStreamLogCompBase

Definition at line 73 of file CLogCompBase.h.

Member Typedef Documentation

◆ BaseClass

Base class typedef for component functionality.

Definition at line 80 of file CLogCompBase.h.

◆ BaseClass2

Base class typedef for QObject functionality.

Definition at line 83 of file CLogCompBase.h.

Constructor & Destructor Documentation

◆ CLogCompBase()

ilog::CLogCompBase::CLogCompBase ( )

Default constructor.

Connects the EmitAddMessage signal to OnAddMessage slot for thread-safe message delivery.

Member Function Documentation

◆ AddMessage()

virtual void ilog::CLogCompBase::AddMessage ( const MessagePtr messagePtr)
overridevirtual

Add a message to this log component.

Thread-safe method that can be called from any thread. Emits EmitAddMessage signal which is delivered on the component's thread where OnAddMessage slot processes it.

Parameters
messagePtrShared pointer to message to log
Note
This method returns immediately after emitting the signal. Actual message processing happens asynchronously.

Reimplemented from ilog::TMessageDelegatorComp< icomp::CComponentBase >.

Reimplemented in ilog::CLogComp.

◆ EmitAddMessage

void ilog::CLogCompBase::EmitAddMessage ( const MessagePtr messagePtr)
signal

Signal emitted when a message is added.

This signal provides thread-safe message delivery. When AddMessage() is called from any thread, this signal is emitted and Qt delivers it to the OnAddMessage slot on the component's thread.

Parameters
messagePtrShared pointer to message being added

◆ WriteMessageToLog()

virtual void ilog::CLogCompBase::WriteMessageToLog ( const MessagePtr messagePtr)
protectedpure virtual

Abstract method called to process a message.

Derived classes must implement this to define message handling behavior. This is always called on the component's thread, regardless of which thread called AddMessage().

Parameters
messagePtrShared pointer to message to process
Example
virtual void WriteMessageToLog(const MessagePtr& messagePtr) override {
// Store in container
m_messages.append(messagePtr);
// Update UI
UpdateDisplay();
// Forward to slave
if (m_slave) m_slave->AddMessage(messagePtr);
}
virtual void WriteMessageToLog(const MessagePtr &messagePtr)=0
Abstract method called to process a message.

Implemented in ilog::CLogComp, and ilog::CStreamLogCompBase.


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