TExtMessage.h
Go to the documentation of this file.
1 #ifndef ilog_TExtMessage_included
2 #define ilog_TExtMessage_included
3 
4 
5 // ACF includes
6 #include <istd/CChangeNotifier.h>
7 #include <istd/CClassInfo.h>
8 #include <imod/TModelWrap.h>
9 #include <ilog/CMessage.h>
10 
11 
12 namespace ilog
13 {
14 
15 
19 template<class Element>
21  public CMessage,
22  public Element
23 {
24 public:
26  typedef Element BaseClass2;
27 
28  TExtMessage();
30  int id,
31  const QString& text,
32  const QString& source,
33  int flags = 0,
34  const QDateTime* timeStampPtr = NULL);
35 
36  // reimplemented (iser::IObject)
37  virtual QByteArray GetFactoryId() const;
38 
39  // reimplemented (iser::ISerializable)
40  virtual bool Serialize(iser::IArchive& archive);
41 
42  // reimplemented (iser::IChangeable)
43  virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_STRICT);
45 
46  // static methods
47  static QByteArray GetTypeName();
48 };
49 
50 
51 // public methods
52 
53 template<class Element>
55 : BaseClass(),
56  Element()
57 {
58 }
59 
60 
61 template<class Element>
64  int id,
65  const QString& text,
66  const QString& source,
67  int flags,
68  const QDateTime* timeStampPtr)
69 : CMessage(category, id, text, source, flags, timeStampPtr),
70  Element()
71 {
72 }
73 
74 
75 // reimplemented (iser::IObject)
76 
77 template<class Element>
79 {
80  return GetTypeName();
81 }
82 
83 
84 // reimplemented (iser::ISerializable)
85 
86 template<class Element>
88 {
89  static const iser::CArchiveTag elementTag("Element", "Element part", iser::CArchiveTag::TT_GROUP);
90 
91  quint32 versionNumber = 0;
92  bool isOldFormat = archive.GetVersionInfo().GetVersionNumber(iser::IVersionInfo::AcfVersionId, versionNumber) && (versionNumber < 4279);
93 
94  bool retVal = BaseClass::Serialize(archive);
95 
96  if (!isOldFormat){
97  retVal = retVal && archive.BeginTag(elementTag);
98  }
99  retVal = retVal && BaseClass2::Serialize(archive);
100  if (!isOldFormat){
101  retVal = retVal && archive.EndTag(elementTag);
102  }
103 
104  return retVal;
105 }
106 
107 
108 // reimplemented (iser::IChangeable)
109 
110 template<class Element>
112 {
113  istd::CChangeNotifier notifier(this);
114 
115  return BaseClass::CopyFrom(object, mode) && BaseClass2::CopyFrom(object, mode);
116 }
117 
118 
119 template<class Element>
121 {
123  if (clonedPtr->CopyFrom(*this, mode)){
124  return clonedPtr.PopPtr();
125  }
126 
127  return NULL;
128 }
129 
130 
131 // static methods
132 
133 template<class Element>
135 {
136  return istd::CClassInfo::GetName<TExtMessage<Element> >();
137 }
138 
139 
140 template<class Element>
141 class TExtMessageModel: public imod::TModelWrap<TExtMessage<Element> >
142 {
143 public:
145 
148  int id,
149  const QString& text,
150  const QString& source,
151  int flags = 0,
152  const QDateTime* timeStampPtr = NULL);
153 };
154 
155 
156 template<class Element>
159  int id,
160  const QString& text,
161  const QString& source,
162  int flags,
163  const QDateTime* timeStampPtr)
164 {
165  BaseClass::SetMessageValues(category, id, text, source, flags, timeStampPtr);
166 }
167 
168 
169 } // namespace ilog
170 
171 
172 #endif // ilog_TExtMessage_included
173 
174 
Element BaseClass2
Definition: TExtMessage.h:26
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
static QByteArray GetTypeName()
Definition: TExtMessage.h:134
TExtMessageModel(istd::IInformationProvider::InformationCategory category, int id, const QString &text, const QString &source, int flags=0, const QDateTime *timeStampPtr=NULL)
Definition: TExtMessage.h:157
Type * PopPtr()
Reset internal pointer value without deleting instance and return previos value.
Definition: TDelPtr.h:149
virtual bool BeginTag(const CArchiveTag &tag)=0
Begin of archive tag.
imod::TModelWrap< TExtMessage< Element > > BaseClass
Definition: TExtMessage.h:144
If external references are different this object are not compatible and cannot be compared or copied...
Definition: IChangeable.h:192
Normal tag used for grouping of tags or processed elements.
Definition: CArchiveTag.h:37
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual QByteArray GetFactoryId() const
Definition: TExtMessage.h:78
Help class which provides the automatic update mechanism of the model.
InformationCategory
Category of information.
virtual const IVersionInfo & GetVersionInfo() const =0
Get version of archived stream for specific versioning type.
#define NULL
Definition: istd.h:64
virtual bool GetVersionNumber(int versionId, quint32 &result) const =0
Get version of archived stream for specific versioning type.
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition: TModelWrap.h:24
CMessage BaseClass
Definition: TExtMessage.h:25
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_STRICT)
Copy this object from another one.
Definition: TExtMessage.h:111
Process tag used to group data in archive stream.
Definition: CArchiveTag.h:21
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
Definition: TExtMessage.h:87
virtual bool EndTag(const CArchiveTag &tag)=0
End of archive tag.
Extended message with attached some object.
Definition: TExtMessage.h:20
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition: TDelPtr.h:20
Basic implementation of the istd::IInformationProvider interface.
Definition: CMessage.h:22
virtual istd::IChangeable * CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const
Make a copy of this object.
Definition: TExtMessage.h:120

© 2007-2017 Witold Gantzke and Kirill Lepskiy