CMessageContainer.h
Go to the documentation of this file.
1 #ifndef ilog_CMessageContainer_included
2 #define ilog_CMessageContainer_included
3 
4 
5 // Qt includes
6 #include <QtCore/QList>
7 #include <QtCore/QMutex>
8 
9 // ACF includes
11 #include <istd/THierarchicalBase.h>
12 #include <istd/TComposedFactory.h>
13 #include <istd/TSingleFactory.h>
14 #include <istd/CClassInfo.h>
15 #include <iser/IObject.h>
16 #include <ilog/IMessageContainer.h>
17 #include <ilog/IMessageConsumer.h>
18 
19 
20 namespace ilog
21 {
22 
23 
30  public istd::THierarchicalBase<IHierarchicalMessageContainer>,
31  virtual public IMessageConsumer
32 {
33 public:
35  CMessageContainer(const CMessageContainer& container);
36 
41  template <typename MessageType>
42  static bool RegisterMessageType(const QByteArray& messageTypeId = QByteArray());
43 
48  int GetMessagesCount() const;
49 
54  virtual void AddChildContainer(IHierarchicalMessageContainer* childContainerPtr);
55 
59  void SetSlaveConsumer(ilog::IMessageConsumer* consumerPtr);
60 
67  void SetMaxMessageCount(int maxMessageCount = -1);
68 
69  // reimplemented (iser::ISerializable)
70  virtual bool Serialize(iser::IArchive& archive);
71 
72  // reimplemented (ilog::IMessageContainer)
73  virtual int GetWorstCategory() const;
74  virtual Messages GetMessages() const;
75  virtual void ClearMessages();
76 
77  // reimplemented (ilog::IMessageConsumer)
78  virtual bool IsMessageSupported(
79  int messageCategory = -1,
80  int messageId = -1,
81  const istd::IInformationProvider* messagePtr = NULL) const;
82  virtual void AddMessage(const IMessageConsumer::MessagePtr& messagePtr);
83 
84  // reimplemented (ilog::IHierarchicalMessageContainer)
85  virtual int GetChildsCount() const;
86  virtual IHierarchicalMessageContainer* GetChild(int index) const;
87 
88  // reimplemented (istd::IChangeable)
89  virtual int GetSupportedOperations() const;
90  virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS);
91  virtual bool IsEqual(const istd::IChangeable& object) const;
93  virtual bool ResetData(CompatibilityMode mode);
94 
95 private:
97 
98  static MessageFactory& GetMessageFactory();
99 
100 protected:
101  Messages m_messages;
102 
103  typedef QVector<IHierarchicalMessageContainer*> Childs;
105 
108  mutable int m_worstCategory;
109 };
110 
111 
112 // public static methods
113 
114 template <typename MessageType>
115 bool CMessageContainer::RegisterMessageType(const QByteArray& messageTypeId)
116 {
117  QByteArray realTypeId = messageTypeId;
118 
119  if (realTypeId.isEmpty()){
120  realTypeId = istd::CClassInfo::GetName<MessageType>();
121  }
122 
123  return GetMessageFactory().RegisterFactory(new istd::TSingleFactory<iser::IObject, MessageType>(realTypeId), true);
124 }
125 
126 
127 #define I_REGISTER_MESSAGE_TYPE(messageType, messageTypeId)\
128  static struct DefaultMessageTypesRegistrator_##messageType\
129 {\
130  DefaultMessageTypesRegistrator_##messageType()\
131 {\
132  ilog::CMessageContainer::RegisterMessageType<messageType>(messageTypeId);\
133 }\
134 } s_defaultMessageTypesRegistrator_##messageType;
135 
136 
137 } // namespace ilog
138 
139 
140 #endif // !ilog_CMessageContainer_included
141 
142 
virtual int GetChildsCount() const
void SetMaxMessageCount(int maxMessageCount=-1)
Set maximal number of messages in the container.
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
Copy this object from another one.
ilog::IMessageConsumer * m_slaveConsumerPtr
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
virtual void ClearMessages()
void SetSlaveConsumer(ilog::IMessageConsumer *consumerPtr)
Set slave message consumer.
Template based implementation of a hierarchical object.
virtual bool Serialize(iser::IArchive &archive)
virtual bool IsEqual(const istd::IChangeable &object) const
Compare this object with another object.
static bool RegisterMessageType(const QByteArray &messageTypeId=QByteArray())
Register a new message type.
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual Messages GetMessages() const
Implementation of a smart pointer.
Definition: TSmartPtr.h:24
Template based object factory interface.
bool RegisterFactory(FactoryInterface *factoryPtr, bool releaseFlag=false)
Registers object factory factoryPtr that will be mapped to the keyId.
Common interface to define the hierarchical graph structures.
virtual int GetWorstCategory() const
int GetMessagesCount() const
Get the number of messages in the container.
#define NULL
Definition: istd.h:64
virtual void AddMessage(const IMessageConsumer::MessagePtr &messagePtr)
Adds a message item to the container.
virtual bool ResetData(CompatibilityMode mode)
Reset data to its default state.
virtual istd::IChangeable * CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const
Make a copy of this object.
Common interface for a message container consuming information objects (messages).
virtual IHierarchicalMessageContainer * GetChild(int index) const
virtual bool IsMessageSupported(int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const
Check if some messge is supported.
Common interface for class providing some basic information object.
virtual int GetSupportedOperations() const
Get set of flags for supported operations.
Standard generic implementation of the composed factory.
virtual void AddChildContainer(IHierarchicalMessageContainer *childContainerPtr)
Add a child message container to this object.
QVector< IHierarchicalMessageContainer * > Childs
Basic implementation of a message container.

© 2007-2017 Witold Gantzke and Kirill Lepskiy