ACF $AcfVersion:0$
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ilog::TExtMessage< Element > Class Template Reference

Template for creating extended messages with custom embedded data. More...

#include <TExtMessage.h>

Inheritance diagram for ilog::TExtMessage< Element >:
ilog::CMessage istd::IInformationProvider iser::IObject istd::IChangeable iser::ISerializable istd::IPolymorphic istd::IChangeable istd::IPolymorphic

Public Types

typedef CMessage BaseClass
 Base message class typedef.
 
typedef Element BaseClass2
 Base element class typedef.
 
- Public Types inherited from istd::IInformationProvider
enum  InformationCategory {
  IC_NONE = 0 , IC_INFO , IC_WARNING , IC_ERROR ,
  IC_CRITICAL
}
 Category of information. More...
 
enum  InformationTypeFlags { ITF_DEBUG = 0x1 , ITF_SYSTEM = 0x2 , ITF_USER = 0x4 }
 Additionally information flags. More...
 
- 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

 TExtMessage ()
 Default constructor.
 
 TExtMessage (istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL)
 Construct message with all standard properties.
 
virtual QByteArray GetFactoryId () const override
 Get the factory identifier for serialization.
 
virtual bool Serialize (iser::IArchive &archive) override
 Serialize or deserialize the message and element data.
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_STRICT) override
 Copy message and element data from another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const override
 Create a deep copy of this extended message.
 
- Public Member Functions inherited from ilog::CMessage
 CMessage ()
 Default constructor.
 
 CMessage (istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL)
 Construct a message with all properties.
 
void SetMessageValues (istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL)
 Set all message properties at once.
 
virtual void SetCategory (istd::IInformationProvider::InformationCategory category)
 Set the message category (severity level).
 
virtual void SetText (const QString &text)
 Set the message text.
 
virtual void SetSource (const QString &source)
 Set the message source.
 
virtual QDateTime GetInformationTimeStamp () const override
 Get the message timestamp.
 
virtual InformationCategory GetInformationCategory () const override
 Get the message category (severity level).
 
virtual int GetInformationId () const override
 Get the numeric message identifier.
 
virtual QString GetInformationDescription () const override
 Get the human-readable message text.
 
virtual QString GetInformationSource () const override
 Get the message source identifier.
 
virtual int GetInformationFlags () const override
 Get application-defined flags.
 
- Public Member Functions inherited from istd::IInformationProvider
 I_DECLARE_ENUM (InformationCategory, IC_NONE, IC_INFO, IC_WARNING, IC_ERROR, IC_CRITICAL)
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
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.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data.
 

Static Public Member Functions

static QByteArray GetTypeName ()
 Get the extended message type identifier.
 
- Static Public Member Functions inherited from ilog::CMessage
static QByteArray GetMessageTypeId ()
 Get the message type identifier for serialization.
 
- 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.
 

Additional Inherited Members

- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 
- Protected Attributes inherited from ilog::CMessage
istd::IInformationProvider::InformationCategory m_category
 Message category (severity level)
 
int m_id
 Numeric message identifier.
 
QString m_text
 Human-readable message text.
 
QString m_source
 Message source identifier.
 
int m_flags
 Application-defined flags.
 
QDateTime m_timeStamp
 Message creation timestamp.
 

Detailed Description

template<class Element>
class ilog::TExtMessage< Element >

Template for creating extended messages with custom embedded data.

TExtMessage combines CMessage with a user-defined Element type to create specialized message types that carry both standard message properties and custom structured data in a single object.

This is an alternative to CExtMessage's attached objects approach. Instead of attaching separate objects, the custom data is embedded directly in the message type through multiple inheritance.

The Element type must implement iser::ISerializable and istd::IChangeable for proper serialization and cloning support.

Template Parameters
ElementUser-defined class to embed in the message. Must implement iser::ISerializable and istd::IChangeable interfaces.
Advantages over CExtMessage
  • Type-safe access to custom data (no casting needed)
  • More efficient (no indirection through attached object list)
  • Simpler usage for single custom data type
  • Direct member access to Element's properties
Usage Example
// Define custom data structure
struct DiagnosticData : public iser::ISerializable, public istd::IChangeable
{
double cpuUsage;
qint64 memoryUsed;
QString componentName;
virtual bool Serialize(iser::IArchive& archive) override {
return archive.Process(cpuUsage, "cpu") &&
archive.Process(memoryUsed, "memory") &&
archive.Process(componentName, "component");
}
virtual bool CopyFrom(const istd::IChangeable& obj, CompatibilityMode mode) {
const DiagnosticData* other = dynamic_cast<const DiagnosticData*>(&obj);
if (!other) return false;
cpuUsage = other->cpuUsage;
memoryUsed = other->memoryUsed;
componentName = other->componentName;
return true;
}
};
// Create message type
typedef ilog::TExtMessage<DiagnosticData> DiagnosticMessage;
// Register for serialization
I_REGISTER_MESSAGE_TYPE(DiagnosticMessage, "com.myapp.DiagnosticMessage");
// Use the message
new DiagnosticMessage(
1001,
"System diagnostics",
"Monitor"
)
);
// Set custom data directly
msg->cpuUsage = 65.5;
msg->memoryUsed = 1024*1024*800; // 800 MB
msg->componentName = "MainProcessor";
// Send to logger
logger->AddMessage(msg);
#define I_REGISTER_MESSAGE_TYPE(messageType, messageTypeId)
Template for creating extended messages with custom embedded data.
Definition TExtMessage.h:97
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
virtual bool Process(bool &value)=0
Processes (reads or writes) a boolean value.
Common class for all classes which objects can be archived or restored from archive.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
@ IC_INFO
Normal information level.
Shared ownership smart pointer for interface types.
See also
ilog::CExtMessage, ilog::CMessage, ilog::TExtMessageModel

Definition at line 94 of file TExtMessage.h.

Member Typedef Documentation

◆ BaseClass

template<class Element >
typedef CMessage ilog::TExtMessage< Element >::BaseClass

Base message class typedef.

Definition at line 100 of file TExtMessage.h.

◆ BaseClass2

template<class Element >
typedef Element ilog::TExtMessage< Element >::BaseClass2

Base element class typedef.

Definition at line 103 of file TExtMessage.h.

Constructor & Destructor Documentation

◆ TExtMessage() [1/2]

template<class Element >
TExtMessage::TExtMessage ( )

Default constructor.

Initializes both the message and element parts with default values.

Definition at line 213 of file TExtMessage.h.

◆ TExtMessage() [2/2]

template<class Element >
TExtMessage::TExtMessage ( istd::IInformationProvider::InformationCategory  category,
int  id,
const QString &  text,
const QString &  source,
int  flags = 0,
const QDateTime *  timeStampPtr = NULL 
)

Construct message with all standard properties.

Creates a message with the specified properties. The Element part is default-constructed and can be set afterwards.

Parameters
categoryMessage severity level
idNumeric message identifier
textHuman-readable message description
sourceMessage origin
flagsOptional application-defined flags (default: 0)
timeStampPtrOptional pointer to timestamp, or NULL for current time
Example
2001,
"Performance metrics",
"Monitor"
);
msg.cpuUsage = 45.2;
msg.memoryUsed = 512*1024*1024;

Definition at line 221 of file TExtMessage.h.

Member Function Documentation

◆ CloneMe()

template<class Element >
istd::IChangeable * TExtMessage::CloneMe ( CompatibilityMode  mode = CM_WITHOUT_REFS) const
overridevirtual

Create a deep copy of this extended message.

Creates a new message with both message and element data copied.

Parameters
modeCompatibility mode for cloning
Returns
New extended message with copied data, or NULL on error
Note
Caller takes ownership of returned pointer

Reimplemented from ilog::CMessage.

Definition at line 279 of file TExtMessage.h.

References NULL, and istd::TDelPtr< Type, Accessor >::PopPtr().

◆ CopyFrom()

template<class Element >
bool TExtMessage::CopyFrom ( const istd::IChangeable object,
CompatibilityMode  mode = CM_STRICT 
)
overridevirtual

Copy message and element data from another object.

Copies both message properties and element data from a compatible object.

Parameters
objectSource object to copy from
modeCompatibility mode for copying
Returns
true if copy succeeded, false if incompatible

Reimplemented from ilog::CMessage.

Definition at line 270 of file TExtMessage.h.

◆ GetFactoryId()

template<class Element >
QByteArray TExtMessage::GetFactoryId ( ) const
overridevirtual

Get the factory identifier for serialization.

Returns
Type identifier combining message and element types
See also
GetTypeName()

Reimplemented from ilog::CMessage.

Definition at line 237 of file TExtMessage.h.

◆ GetTypeName()

template<class Element >
QByteArray TExtMessage::GetTypeName ( )
static

Get the extended message type identifier.

Returns a unique type name combining the template parameter's type.

Returns
Type identifier string

Definition at line 293 of file TExtMessage.h.

◆ Serialize()

template<class Element >
bool TExtMessage::Serialize ( iser::IArchive archive)
overridevirtual

Serialize or deserialize the message and element data.

Stores/loads both the base message properties and the Element data to/from the archive. The Element part is serialized in a tagged section.

Parameters
archiveArchive for reading or writing
Returns
true if serialization succeeded, false on error
Note
Handles version compatibility for old ACF formats (version < 4279)
See also
iser::IArchive

Reimplemented from ilog::CMessage.

Definition at line 246 of file TExtMessage.h.

References iser::IVersionInfo::AcfVersionId, iser::IArchive::BeginTag(), iser::IArchive::EndTag(), iser::IArchive::GetVersionInfo(), iser::IVersionInfo::GetVersionNumber(), and iser::CArchiveTag::TT_GROUP.


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