ACF $AcfVersion:0$
TExtMessage.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
7#include <istd/CClassInfo.h>
8#include <imod/TModelWrap.h>
9#include <ilog/CMessage.h>
10
11
12namespace ilog
13{
14
15
93template<class Element>
95 public CMessage,
96 public Element
97{
98public:
101
103 typedef Element BaseClass2;
104
110 TExtMessage();
111
138 int id,
139 const QString& text,
140 const QString& source,
141 int flags = 0,
142 const QDateTime* timeStampPtr = NULL);
143
144 // reimplemented (iser::IObject)
145
153 virtual QByteArray GetFactoryId() const override;
154
155 // reimplemented (iser::ISerializable)
156
170 virtual bool Serialize(iser::IArchive& archive) override;
171
172 // reimplemented (iser::IChangeable)
173
183 virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_STRICT) override;
184
196
197 // static methods
198
206 static QByteArray GetTypeName();
207};
208
209
210// public methods
211
212template<class Element>
214: BaseClass(),
215 Element()
216{
217}
218
219
220template<class Element>
223 int id,
224 const QString& text,
225 const QString& source,
226 int flags,
227 const QDateTime* timeStampPtr)
228: CMessage(category, id, text, source, flags, timeStampPtr),
229 Element()
230{
231}
232
233
234// reimplemented (iser::IObject)
235
236template<class Element>
238{
239 return GetTypeName();
240}
241
242
243// reimplemented (iser::ISerializable)
244
245template<class Element>
247{
248 static const iser::CArchiveTag elementTag("Element", "Element part", iser::CArchiveTag::TT_GROUP);
249
250 quint32 versionNumber = 0;
251 bool isOldFormat = archive.GetVersionInfo().GetVersionNumber(iser::IVersionInfo::AcfVersionId, versionNumber) && (versionNumber < 4279);
252
253 bool retVal = BaseClass::Serialize(archive);
254
255 if (!isOldFormat){
256 retVal = retVal && archive.BeginTag(elementTag);
257 }
258 retVal = retVal && BaseClass2::Serialize(archive);
259 if (!isOldFormat){
260 retVal = retVal && archive.EndTag(elementTag);
261 }
262
263 return retVal;
264}
265
266
267// reimplemented (iser::IChangeable)
268
269template<class Element>
271{
272 istd::CChangeNotifier notifier(this);
273
274 return BaseClass::CopyFrom(object, mode) && BaseClass2::CopyFrom(object, mode);
275}
276
277
278template<class Element>
280{
282 if (clonedPtr->CopyFrom(*this, mode)){
283 return clonedPtr.PopPtr();
284 }
285
286 return NULL;
287}
288
289
290// static methods
291
292template<class Element>
294{
295 return istd::CClassInfo::GetName<TExtMessage<Element> >();
296}
297
298
337template<class Element>
338class TExtMessageModel: public imod::TModelWrap<TExtMessage<Element> >
339{
340public:
343
356 int id,
357 const QString& text,
358 const QString& source,
359 int flags = 0,
360 const QDateTime* timeStampPtr = NULL);
361};
362
363
364template<class Element>
367 int id,
368 const QString& text,
369 const QString& source,
370 int flags,
371 const QDateTime* timeStampPtr)
372{
373 BaseClass::SetMessageValues(category, id, text, source, flags, timeStampPtr);
374}
375
376
377} // namespace ilog
378
379
380
381
Basic implementation of the istd::IInformationProvider interface for log messages.
Definition CMessage.h:80
Template for creating extended messages with custom embedded data.
Definition TExtMessage.h:97
virtual QByteArray GetFactoryId() const override
Get the factory identifier for serialization.
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Create a deep copy of this extended message.
Element BaseClass2
Base element class typedef.
static QByteArray GetTypeName()
Get the extended message type identifier.
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_STRICT) override
Copy message and element data from another object.
TExtMessage()
Default constructor.
CMessage BaseClass
Base message class typedef.
virtual bool Serialize(iser::IArchive &archive) override
Serialize or deserialize the message and element data.
Model wrapper for TExtMessage.
TExtMessageModel(istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL)
Construct message model with all properties.
imod::TModelWrap< TExtMessage< Element > > BaseClass
Base class typedef.
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
Process tag used to group data in archive stream.
Definition CArchiveTag.h:22
@ TT_GROUP
Normal tag used for grouping of tags or processed elements.
Definition CArchiveTag.h:37
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
virtual const IVersionInfo & GetVersionInfo() const =0
Gets version information for the archived stream.
virtual bool EndTag(const CArchiveTag &tag)=0
Ends a tagged section in the archive.
virtual bool BeginTag(const CArchiveTag &tag)=0
Begins a tagged section in the archive.
virtual bool GetVersionNumber(int versionId, quint32 &result) const =0
Get version of archived stream for specific versioning type.
Help class which provides the automatic update mechanism of the model.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
@ CM_STRICT
If external references are different this object are not compatible and cannot be compared or copied.
InformationCategory
Category of information.
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Type * PopPtr()
Reset internal pointer value without deleting instance and return previos value.
Definition TDelPtr.h:170
Unique ownership smart pointer for interface types.
#define NULL
Definition istd.h:74
This namespace contains implementations for the logging functionality.