ACF $AcfVersion:0$
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ilog::CExtMessage Class Reference

Extended message supporting attached list of serializable objects. More...

#include <CExtMessage.h>

Inheritance diagram for ilog::CExtMessage:
ilog::CMessage istd::IInformationProvider iser::IObject istd::IChangeable iser::ISerializable istd::IPolymorphic istd::IChangeable istd::IPolymorphic

Classes

struct  AttachedObject
 Structure holding an attached object and its description. More...
 

Public Types

typedef CMessage BaseClass
 
- 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

 CExtMessage (const iser::IObjectFactory *factoryPtr=NULL)
 Default constructor.
 
 CExtMessage (istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL, const iser::IObjectFactory *factoryPtr=NULL)
 Construct extended message with all properties.
 
const iser::IObjectFactoryGetObjectFactory () const
 Get the object factory used for deserialization.
 
void SetObjectFactory (const iser::IObjectFactory *factoryPtr)
 Set the object factory for deserialization.
 
void ResetAttachedObjects ()
 Remove all attached objects from the message.
 
int GetAttachedObjectsCount () const
 Get the number of attached objects.
 
const iser::IObjectGetAttachedObject (int index) const
 Get a specific attached object by index.
 
const QString & GetAttachedObjectDescription (int index) const
 Get the description of an attached object.
 
void InsertAttachedObject (iser::IObject *objectPtr, const QString &description="")
 Add an object to this message.
 
virtual QByteArray GetFactoryId () const override
 Get the factory identifier for serialization.
 
virtual bool Serialize (iser::IArchive &archive) override
 Serialize or deserialize the message and attached objects.
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_STRICT) override
 Copy message and attached objects from another message.
 
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.
 

Protected Attributes

const iser::IObjectFactorym_factoryPtr
 Object factory for deserializing attached objects.
 
QList< AttachedObjectm_attachedObjects
 List of attached objects with descriptions.
 
- 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.
 

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.
 

Detailed Description

Extended message supporting attached list of serializable objects.

CExtMessage extends CMessage to allow attachment of custom objects that provide additional context or data related to the message. Each attached object can have an associated description.

This is particularly useful for error messages where you want to include the problematic data, validation results, or other context objects for detailed analysis or debugging.

The class uses an object factory for deserialization, allowing attached objects to be properly reconstructed when loading from archives.

Attached Objects
Attached objects must implement iser::IObject interface for serialization. The message takes ownership of attached objects and manages their lifetime.
Thread Safety
Like CMessage, CExtMessage objects should be treated as immutable after creation and attachment of objects. Modifications are not thread-safe.
Usage Example
// Create extended message
3001,
"Data validation failed",
"Validator",
0,
nullptr,
myObjectFactory
)
);
// Attach invalid data object
istd::TSharedInterfacePtr<MyDataObject> dataObj(new MyDataObject);
dataObj->SetValue(invalidValue);
msg->InsertAttachedObject(dataObj.PopRootPtr(), "Invalid data sample");
// Attach validation context
istd::TSharedInterfacePtr<ValidationContext> context(new ValidationContext);
msg->InsertAttachedObject(context.PopRootPtr(), "Validation context");
// Send to logger
logger->AddMessage(msg);
// Later, retrieve attached objects
int count = msg->GetAttachedObjectsCount();
for (int i = 0; i < count; ++i) {
const iser::IObject* obj = msg->GetAttachedObject(i);
const QString& desc = msg->GetAttachedObjectDescription(i);
// Analyze object...
}
Extended message supporting attached list of serializable objects.
Definition CExtMessage.h:83
Common interface for factorisable model objects.
Definition IObject.h:23
@ IC_ERROR
Information about error, processing could not be done correctly.
Shared ownership smart pointer for interface types.
See also
ilog::CMessage, ilog::TExtMessage, iser::IObject, iser::IObjectFactory

Definition at line 82 of file CExtMessage.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 85 of file CExtMessage.h.

Constructor & Destructor Documentation

◆ CExtMessage() [1/2]

ilog::CExtMessage::CExtMessage ( const iser::IObjectFactory factoryPtr = NULL)
explicit

Default constructor.

Creates an empty extended message with no object factory.

Parameters
factoryPtrOptional object factory for deserialization of attached objects

◆ CExtMessage() [2/2]

ilog::CExtMessage::CExtMessage ( istd::IInformationProvider::InformationCategory  category,
int  id,
const QString &  text,
const QString &  source,
int  flags = 0,
const QDateTime *  timeStampPtr = NULL,
const iser::IObjectFactory factoryPtr = NULL 
)

Construct extended message with all properties.

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
factoryPtrOptional object factory for deserializing attached objects
Example
5001,
"Processing failed",
"Processor",
0,
nullptr,
);
const iser::IObjectFactory * GetObjectFactory() const
Get the object factory used for deserialization.

Member Function Documentation

◆ CloneMe()

virtual istd::TUniqueInterfacePtr< istd::IChangeable > ilog::CExtMessage::CloneMe ( CompatibilityMode  mode = CM_WITHOUT_REFS) const
overridevirtual

Create a deep copy of this extended message.

Creates a new message with all properties and attached objects 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.

◆ CopyFrom()

virtual bool ilog::CExtMessage::CopyFrom ( const istd::IChangeable object,
CompatibilityMode  mode = CM_STRICT 
)
overridevirtual

Copy message and attached objects from another message.

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

Reimplemented from ilog::CMessage.

◆ GetAttachedObject()

const iser::IObject * ilog::CExtMessage::GetAttachedObject ( int  index) const

Get a specific attached object by index.

Parameters
indexZero-based index of object to retrieve
Returns
Pointer to the attached object, or NULL if index invalid
Note
The returned pointer is owned by the message. Don't delete it.
Example
const iser::IObject* obj = msg->GetAttachedObject(0);
if (obj) {
// Try to cast to expected type
const MyDataObject* dataObj =
dynamic_cast<const MyDataObject*>(obj);
if (dataObj) {
// Use dataObj
}
}
See also
GetAttachedObjectsCount(), GetAttachedObjectDescription()

◆ GetAttachedObjectDescription()

const QString & ilog::CExtMessage::GetAttachedObjectDescription ( int  index) const

Get the description of an attached object.

Parameters
indexZero-based index of object
Returns
Description string provided when object was attached
Example
QString desc = msg->GetAttachedObjectDescription(0);
qDebug() << "Object 0:" << desc;
See also
GetAttachedObject(), InsertAttachedObject()

◆ GetAttachedObjectsCount()

int ilog::CExtMessage::GetAttachedObjectsCount ( ) const

Get the number of attached objects.

Returns
Count of objects currently attached to this message
Example
int count = msg->GetAttachedObjectsCount();
for (int i = 0; i < count; ++i) {
// Process object i
}
See also
GetAttachedObject()

◆ GetFactoryId()

virtual QByteArray ilog::CExtMessage::GetFactoryId ( ) const
overridevirtual

Get the factory identifier for serialization.

Returns
Type identifier for object factory
See also
GetTypeName()

Reimplemented from ilog::CMessage.

◆ GetObjectFactory()

const iser::IObjectFactory * ilog::CExtMessage::GetObjectFactory ( ) const

Get the object factory used for deserialization.

Returns
Pointer to object factory, or NULL if none set

◆ GetTypeName()

static QByteArray ilog::CExtMessage::GetTypeName ( )
static

Get the extended message type identifier.

Returns
Type identifier string

◆ InsertAttachedObject()

void ilog::CExtMessage::InsertAttachedObject ( iser::IObject objectPtr,
const QString &  description = "" 
)

Add an object to this message.

Attaches a serializable object to the message with an optional description. The message takes ownership of the object and will delete it when the message is destroyed.

Parameters
objectPtrPointer to object to attach. Message takes ownership. Must implement iser::IObject interface.
descriptionOptional human-readable description of the object
Note
After calling this method, don't delete or modify objectPtr. The message owns it now.
Example
// Create object to attach
MyDataObject* dataObj = new MyDataObject;
dataObj->Initialize();
// Attach to message (message takes ownership)
msg->InsertAttachedObject(dataObj, "Problematic data");
// Don't use dataObj after this point
See also
GetAttachedObject(), ResetAttachedObjects()

◆ ResetAttachedObjects()

void ilog::CExtMessage::ResetAttachedObjects ( )

Remove all attached objects from the message.

Clears the attached objects list, releasing all owned objects.

Example
msg->ResetAttachedObjects();
// msg now has no attached objects

◆ Serialize()

virtual bool ilog::CExtMessage::Serialize ( iser::IArchive archive)
overridevirtual

Serialize or deserialize the message and attached objects.

Stores/loads all message properties plus all attached objects to/from the archive. Uses the object factory to recreate attached objects during deserialization.

Parameters
archiveArchive for reading or writing
Returns
true if serialization succeeded, false on error
See also
iser::IArchive, GetObjectFactory()

Reimplemented from ilog::CMessage.

◆ SetObjectFactory()

void ilog::CExtMessage::SetObjectFactory ( const iser::IObjectFactory factoryPtr)

Set the object factory for deserialization.

Parameters
factoryPtrObject factory to use when deserializing attached objects

Member Data Documentation

◆ m_attachedObjects

QList<AttachedObject> ilog::CExtMessage::m_attachedObjects
protected

List of attached objects with descriptions.

Definition at line 317 of file CExtMessage.h.

◆ m_factoryPtr

const iser::IObjectFactory* ilog::CExtMessage::m_factoryPtr
protected

Object factory for deserializing attached objects.

Definition at line 314 of file CExtMessage.h.


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