ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
ilog::CLogComp Class Reference

Complete logging component with message storage and container interface. More...

#include <CLogComp.h>

Inheritance diagram for ilog::CLogComp:
ilog::CLogCompBase ilog::CMessageContainer ilog::TMessageDelegatorComp< icomp::CComponentBase > istd::THierarchicalBase< IHierarchicalMessageContainer > ilog::IMessageConsumer icomp::CComponentBase ilog::IMessageConsumer istd::TChangeDelegator< Base > istd::IPolymorphic icomp::IComponent istd::IPolymorphic istd::CChangeDelegator istd::IPolymorphic istd::IChangeDelegator istd::IChangeable istd::IPolymorphic

Public Types

typedef CLogCompBase BaseClass
 Base class typedef for component functionality.
 
typedef ilog::CMessageContainer BaseClass2
 Base class typedef for container functionality.
 
- Public Types inherited from ilog::CLogCompBase
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.
 
- Public Types inherited from istd::THierarchicalBase< IHierarchicalMessageContainer >
typedef istd::TChangeDelegator< IHierarchicalMessageContainer > BaseClass
 
- Public Types inherited from istd::TChangeDelegator< Base >
typedef Base BaseClass
 
typedef CChangeDelegator BaseClass2
 
- Public Types inherited from istd::CChangeDelegator
typedef istd::IChangeable BaseClass
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
typedef QMultiMap< QByteArray, QVariant > ChangeInfoMap
 

Public Member Functions

virtual bool IsMessageSupported (int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
 Check if a message is supported.
 
virtual void AddMessage (const MessagePtr &messagePtr) override
 Add a message to the log.
 
- Public Member Functions inherited from ilog::CLogCompBase
 CLogCompBase ()
 Default constructor.
 
- 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 ()
 
- Public Member Functions inherited from ilog::CMessageContainer
 CMessageContainer ()
 
 CMessageContainer (const CMessageContainer &container)
 
CMessageContaineroperator= (const CMessageContainer &container)
 
int GetMessagesCount () const
 Get the number of messages in the container.
 
virtual void AddChildContainer (IHierarchicalMessageContainer *childContainerPtr)
 Add a child message container to this object.
 
void SetSlaveConsumer (ilog::IMessageConsumer *consumerPtr)
 Set slave message consumer.
 
void SetMaxMessageCount (int maxMessageCount=-1)
 Set maximal number of messages in the container.
 
virtual bool Serialize (iser::IArchive &archive) override
 
virtual istd::IInformationProvider::InformationCategory GetWorstCategory () const override
 
virtual Messages GetMessages () const override
 
virtual void ClearMessages () override
 
virtual int GetChildsCount () const override
 
virtual IHierarchicalMessageContainerGetChild (int index) const override
 
virtual int GetSupportedOperations () const override
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
 Copy this object from another one.
 
virtual bool IsEqual (const istd::IChangeable &object) const override
 Compare this object with another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const override
 Make a copy of this object.
 
virtual bool ResetData (CompatibilityMode mode) override
 Reset data to its default state.
 
- Public Member Functions inherited from istd::THierarchicalBase< IHierarchicalMessageContainer >
 THierarchicalBase ()
 
virtual void SetParentPtr (typename Base::InterfaceType *parentPtr)
 
virtual int GetHierarchicalFlags () const override
 
virtual typename Base::InterfaceType * GetParent () const override
 
- Public Member Functions inherited from istd::TChangeDelegator< Base >
 TChangeDelegator ()
 
 TChangeDelegator (istd::IChangeable *slavePtr)
 
virtual void OnBeginChanges () override
 Callback function for begin change event.
 
virtual void OnEndChanges (const istd::IChangeable::ChangeSet &changeSet) override
 Callback function for end change event.
 
- Public Member Functions inherited from istd::CChangeDelegator
 CChangeDelegator ()
 
 CChangeDelegator (istd::IChangeable *slavePtr)
 
virtual void SetSlavePtr (istd::IChangeable *slavePtr) override
 Sets the slave object pointer for change delegation.
 
virtual istd::IChangeableGetSlavePtr () const override
 Gets the slave object pointer.
 
- Public Member Functions inherited from istd::IChangeable
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 

Protected Member Functions

virtual void WriteMessageToLog (const MessagePtr &messagePtr) override
 Process a message by storing it in the container.
 
virtual void OnComponentCreated () override
 Called when component is created.
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual void OnComponentDestroyed ()
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 

Additional Inherited Members

- Signals inherited from ilog::CLogCompBase
void EmitAddMessage (const MessagePtr &messagePtr)
 Signal emitted when a message is added.
 
- Static Public Member Functions inherited from ilog::CMessageContainer
template<typename MessageType >
static bool RegisterMessageType (const QByteArray &messageTypeId=QByteArray())
 Register a new message type.
 
- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Protected Types inherited from ilog::CMessageContainer
typedef QVector< IHierarchicalMessageContainer * > Childs
 
- 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())
 
- Protected Attributes inherited from ilog::CMessageContainer
Messages m_messages
 
Childs m_childContainers
 
ilog::IMessageConsumerm_slaveConsumerPtr
 
int m_maxMessagesCount
 
int m_worstCategory
 
- Protected Attributes inherited from istd::THierarchicalBase< IHierarchicalMessageContainer >
typename Base::InterfaceType * m_parentPtr
 

Detailed Description

Complete logging component with message storage and container interface.

CLogComp is a full-featured logging component that combines thread-safe message reception (via CLogCompBase) with message storage (via CMessageContainer). It's one of the most commonly used logging components in the ACF framework.

This component stores received messages and provides the IMessageContainer interface for retrieving, serializing, and managing the stored messages. It supports a configurable maximum message count with automatic pruning when the limit is exceeded.

Features
  • Thread-safe message addition via signals/slots
  • Message storage with IMessageContainer interface
  • Configurable maximum message count
  • Automatic old message removal when limit reached
  • Serialization of all stored messages
  • Message retrieval and clearing
  • Worst category tracking
  • Hierarchical container support (via CMessageContainer)
Configuration
Component attributes:
  • MaxMessageCount: Maximum number of messages to store (default: 1000)
    • Set to -1 for unlimited storage (use with caution)
    • When limit reached, oldest messages are removed
Usage Example
// Create log component
// Configure maximum messages
// In .acc: MaxMessageCount: 5000
// Add messages (thread-safe)
1001, "Application started", "Main")));
// Retrieve all messages
ilog::IMessageContainer::Messages messages = log->GetMessages();
// Check severity
if (log->GetWorstCategory() >= istd::IInformationProvider::IC_ERROR) {
// Errors occurred
}
// Clear messages
log->ClearMessages();
// Serialize to file
iser::CFileWriteArchive archive("log.dat");
log->Serialize(archive);
Complete logging component with message storage and container interface.
Definition CLogComp.h:86
Basic implementation of the istd::IInformationProvider interface for log messages.
Definition CMessage.h:80
std::list< IMessageConsumer::MessagePtr > Messages
List type for storing message shared pointers.
@ IC_ERROR
Information about error, processing could not be done correctly.
@ IC_INFO
Normal information level.
Shared ownership smart pointer for interface types.
Component Integration
In ACF component configuration (.acc files):
<Component Id="ApplicationLog" Class="ilog::CLogComp">
<Attribute Id="MaxMessageCount" Value="10000"/>
</Component>
See also
ilog::CLogCompBase, ilog::CMessageContainer, ilog::IMessageContainer

Definition at line 83 of file CLogComp.h.

Member Typedef Documentation

◆ BaseClass

Base class typedef for component functionality.

Definition at line 89 of file CLogComp.h.

◆ BaseClass2

Base class typedef for container functionality.

Definition at line 92 of file CLogComp.h.

Member Function Documentation

◆ AddMessage()

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

Add a message to the log.

Thread-safe method that stores the message in the container. If the maximum message count is exceeded, the oldest message is removed first.

Parameters
messagePtrShared pointer to message to add
Note
This method is asynchronous. The message is queued and processed on the component's thread.

Reimplemented from ilog::CLogCompBase.

◆ IsMessageSupported()

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

Check if a message is supported.

Delegates to CMessageContainer's implementation which typically accepts all messages.

Parameters
messageCategoryMessage category to check (or -1 for any)
messageIdMessage ID to check (or -1 for any)
messagePtrComplete message to check (or NULL)
Returns
true if message would be accepted

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

◆ OnComponentCreated()

virtual void ilog::CLogComp::OnComponentCreated ( )
overrideprotectedvirtual

Called when component is created.

Initializes the maximum message count from the component attribute.

Reimplemented from icomp::CComponentBase.

◆ WriteMessageToLog()

virtual void ilog::CLogComp::WriteMessageToLog ( const MessagePtr messagePtr)
overrideprotectedvirtual

Process a message by storing it in the container.

Called on the component's thread when a message arrives. Adds the message to the internal container (CMessageContainer base class).

Parameters
messagePtrShared pointer to message to store

Implements ilog::CLogCompBase.


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