ImagingTools Core SDK
CDocumentManagerCompBase.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// ACF includes
6#include <idoc/IDocumentManager.h>
7#include <idoc/IUndoManager.h>
8#include <ilog/TLoggerCompWrap.h>
9
10// ImtCore includes
11#include <imtdoc/CDocumentManagerBase.h>
12#include <imtdoc/IDocumentNameProvider.h>
13#include <imtdoc/IDocumentValidator.h>
14
15
16namespace imtdoc
17{
18
19
20class CDocumentManagerCompBase: public ilog::CLoggerComponentBase, virtual public imtdoc::CDocumentManagerBase
21{
22public:
23 typedef ilog::CLoggerComponentBase BaseClass;
24 typedef imtdoc::CDocumentManagerBase BaseClass2;
25
26 I_BEGIN_BASE_COMPONENT(CDocumentManagerCompBase)
27 I_ASSIGN_MULTI_0(m_handlerCompPtr, "DocumentManagerEventHandler", "Document manager event handler", false);
28 I_ASSIGN_MULTI_0(m_objectTypeIdsAttrPtr, "ObjectTypeIdList", "List of the object type-IDs according to the list of factories ('ObjectFactories')", true);
29 I_ASSIGN(m_undoManagerFactPtr, "UndoManager", "Factory of the undo manager", false, "UndoManager");
30 I_ASSIGN_MULTI_0(m_documentNameProviderCompPtr, "DocumentNameProviders", "List of document name providers related to registered type-IDs ('ObjectTypeIdList')", false);
31 I_ASSIGN_MULTI_0(m_objectFactListCompPtr, "ObjectFactories", "List of object factories related to registered type-IDs ('ObjectTypeIdList')", true);
32 I_ASSIGN_MULTI_0(m_documentValidatorCompPtr, "DocumentValidators", "List of document data validators related to registered type-IDs ('ObjectTypeIdList')", false);
33 I_END_COMPONENT
34
35protected:
36 // reimplemented (imtdoc::CDocumentManagerBase)
37 virtual QList<imtdoc::IDocumentManagerEventHandler*> GetDocumentManagerEventHandlers() const override;
38 virtual istd::IChangeableSharedPtr CreateObject(const QByteArray& typeId) const override;
39 virtual idoc::IUndoManagerSharedPtr CreateUndoManager() const override;
40 virtual QString GetDefaultDocumentName(const WorkingDocument& document) const override;
41 virtual bool HasDocumentNameProvider(const QByteArray& typeId) const override;
42 virtual bool ValidateDocumentData(
43 const WorkingDocument& document,
44 OperationStatus& status,
45 QString* errorMessage = nullptr) const override;
46
47private:
48 // Reserve 170000000-170000099 for imtdoc validation warnings to avoid collisions with other message IDs.
49 static constexpr int kValidationFailureWarningId = 170000000;
50 static constexpr int kValidationFailureWithoutMessageWarningId = 170000001;
51
52 int GetObjectFactoryIndex(const QByteArray& typeId) const;
53 const imtdoc::IDocumentNameProvider* GetDocumentNameProvider(const QByteArray& typeId) const;
54 const imtdoc::IDocumentValidator* GetDocumentValidator(const QByteArray& typeId) const;
55
56protected:
57 I_MULTIREF(imtdoc::IDocumentManagerEventHandler, m_handlerCompPtr);
58 I_MULTIATTR(QByteArray, m_objectTypeIdsAttrPtr);
59 I_FACT(idoc::IUndoManager, m_undoManagerFactPtr);
60 I_MULTIREF(imtdoc::IDocumentNameProvider, m_documentNameProviderCompPtr);
61 I_MULTIFACT(istd::IChangeable, m_objectFactListCompPtr);
62 I_MULTIREF(imtdoc::IDocumentValidator, m_documentValidatorCompPtr);
63};
64
65
66} // namespace imtdoc