ACF $AcfVersion:0$
CMessageContainer.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// Qt includes
6#include <QtCore/QVector>
7#include <QtCore/QList>
8#include <QtCore/QMutex>
9
10// ACF includes
14#include <istd/TSingleFactory.h>
15#include <istd/CClassInfo.h>
16#include <iser/IObject.h>
19
20
21namespace ilog
22{
23
24
31 public istd::THierarchicalBase<IHierarchicalMessageContainer>,
32 virtual public IMessageConsumer
33{
34public:
37
39
44 template <typename MessageType>
45 static bool RegisterMessageType(const QByteArray& messageTypeId = QByteArray());
46
51 int GetMessagesCount() const;
52
57 virtual void AddChildContainer(IHierarchicalMessageContainer* childContainerPtr);
58
63
70 void SetMaxMessageCount(int maxMessageCount = -1);
71
72 // reimplemented (iser::ISerializable)
73 virtual bool Serialize(iser::IArchive& archive) override;
74
75 // reimplemented (ilog::IMessageContainer)
77 virtual Messages GetMessages() const override;
78 virtual void ClearMessages() override;
79
80 // reimplemented (ilog::IMessageConsumer)
81 virtual bool IsMessageSupported(
82 int messageCategory = -1,
83 int messageId = -1,
84 const istd::IInformationProvider* messagePtr = NULL) const override;
85 virtual void AddMessage(const IMessageConsumer::MessagePtr& messagePtr) override;
86
87 // reimplemented (ilog::IHierarchicalMessageContainer)
88 virtual int GetChildsCount() const override;
89 virtual IHierarchicalMessageContainer* GetChild(int index) const override;
90
91 // reimplemented (istd::IChangeable)
92 virtual int GetSupportedOperations() const override;
93 virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
94 virtual bool IsEqual(const istd::IChangeable& object) const override;
96 virtual bool ResetData(CompatibilityMode mode) override;
97
98private:
100
101 static MessageFactory& GetMessageFactory();
102
103protected:
104 Messages m_messages;
105
106 typedef QVector<IHierarchicalMessageContainer*> Childs;
108
111 mutable int m_worstCategory;
112};
113
114
115// public static methods
116
117template <typename MessageType>
118bool CMessageContainer::RegisterMessageType(const QByteArray& messageTypeId)
119{
120 QByteArray realTypeId = messageTypeId;
121
122 if (realTypeId.isEmpty()){
123 realTypeId = istd::CClassInfo::GetName<MessageType>();
124 }
125
127
128 return GetMessageFactory().RegisterFactory<FactoryImpl>(realTypeId);
129}
130
131
132#define I_REGISTER_MESSAGE_TYPE(messageType, messageTypeId)\
133 static struct DefaultMessageTypesRegistrator_##messageType\
134{\
135 DefaultMessageTypesRegistrator_##messageType()\
136{\
137 ilog::CMessageContainer::RegisterMessageType<messageType>(messageTypeId);\
138}\
139} s_defaultMessageTypesRegistrator_##messageType;
140
141
142} // namespace ilog
143
144
145
146
Basic implementation of a message container.
int GetMessagesCount() const
Get the number of messages in the container.
virtual bool IsMessageSupported(int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
Check if a message is supported by this consumer.
void SetSlaveConsumer(ilog::IMessageConsumer *consumerPtr)
Set slave message consumer.
virtual bool ResetData(CompatibilityMode mode) override
Reset data to its default state.
virtual istd::IInformationProvider::InformationCategory GetWorstCategory() const override
virtual bool Serialize(iser::IArchive &archive) override
virtual void AddChildContainer(IHierarchicalMessageContainer *childContainerPtr)
Add a child message container to this object.
static bool RegisterMessageType(const QByteArray &messageTypeId=QByteArray())
Register a new message type.
CMessageContainer & operator=(const CMessageContainer &container)
virtual int GetSupportedOperations() const override
Get set of flags for supported operations.
virtual IHierarchicalMessageContainer * GetChild(int index) const override
ilog::IMessageConsumer * m_slaveConsumerPtr
void SetMaxMessageCount(int maxMessageCount=-1)
Set maximal number of messages in the container.
virtual void AddMessage(const IMessageConsumer::MessagePtr &messagePtr) override
Adds a message to this consumer.
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
virtual int GetChildsCount() const override
QVector< IHierarchicalMessageContainer * > Childs
CMessageContainer(const CMessageContainer &container)
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
virtual Messages GetMessages() const override
virtual bool IsEqual(const istd::IChangeable &object) const override
Compare this object with another object.
virtual void ClearMessages() override
Common interface for a message container consuming information objects (messages).
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
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.
Common interface for class providing some basic information object.
InformationCategory
Category of information.
Standard generic implementation of the composed factory.
bool RegisterFactory(const QByteArray &typeId)
Template based implementation of a hierarchical object.
Common interface to define the hierarchical graph structures.
Shared ownership smart pointer for interface types.
Template based object factory interface.
Unique ownership smart pointer for interface types.
#define NULL
Definition istd.h:74
This namespace contains implementations for the logging functionality.