ACF $AcfVersion:0$
CSelectedDocModelBinderComp.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 <imod/TModelWrap.h>
9#include <iprm/INameParam.h>
12
13
14namespace idoc
15{
16
17
26 protected imod::TSingleModelObserverBase<IDocumentManager>
27{
28public:
31
32 I_BEGIN_COMPONENT(CSelectedDocModelBinderComp);
33 I_REGISTER_SUBELEMENT(SelectedDocumentInfo);
34 I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, iprm::INameParam, ExtractSelectedDocumentInfo);
35 I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, ifile::IFileNameParam, ExtractSelectedDocumentInfo);
36 I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, imod::IModel, ExtractSelectedDocumentInfo);
37 I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, istd::IChangeable, ExtractSelectedDocumentInfo);
38 I_ASSIGN(m_observedObjectCompPtr, "ActivationObject", "Object will be observed if it is active", true, "ActivationObject");
39 I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager used to check which object is active", true, "DocumentManager");
40 I_ASSIGN_TO(m_documentManagerModelCompPtr, m_documentManagerCompPtr, true);
41 I_ASSIGN(m_modelCompPtr, "Model", "Model to be connected", true, "Model");
42 I_ASSIGN_MULTI_0(m_observersCompPtr, "Observers", "Observers for the model", true);
43 I_END_COMPONENT;
44
46
47protected:
50
51 // reimplemented (imod::IObserver)
52 virtual void BeforeUpdate(imod::IModel* modelPtr) override;
53 virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet) override;
54
55 // reimplemented (icomp::CComponentBase)
56 virtual void OnComponentCreated() override;
57 virtual void OnComponentDestroyed() override;
58
59private:
60 I_REF(icomp::IComponent, m_observedObjectCompPtr);
61 I_REF(IDocumentManager, m_documentManagerCompPtr);
62 I_REF(imod::IModel, m_documentManagerModelCompPtr);
63 I_REF(imod::IModel, m_modelCompPtr);
64 I_MULTIREF(imod::IObserver, m_observersCompPtr);
65
66 // static template methods for subelement access
67 template <class InterfaceType>
68 static InterfaceType* ExtractSelectedDocumentInfo(CSelectedDocModelBinderComp& component)
69 {
70 return &component.m_selectedDocumentInfo;
71 }
72
73 class DocumentInfo:
74 virtual public iprm::INameParam,
75 virtual public ifile::IFileNameParam
76 {
77 public:
78 // reimplemented (iprm::INameParam)
79 virtual const QString& GetName() const override;
80 virtual void SetName(const QString& name) override;
81 virtual bool IsNameFixed() const override;
82
83 // reimplemented (ifile::IFileNameParam)
84 virtual int GetPathType() const override;
85 virtual const QString& GetPath() const override;
86 virtual void SetPath(const QString& path) override;
87
88 // reimplemented (iser::ISerializable)
89 virtual bool Serialize(iser::IArchive& archive) override;
90
91 QString name;
92 QString filePath;
93 };
94
95 bool m_isActive;
96
97 typedef QMap<imod::IObserver*, imod::IModel*> ModelObserverMap;
98 ModelObserverMap m_connectedMap;
99
100 imod::TModelWrap<DocumentInfo> m_selectedDocumentInfo;
101};
102
103
104} // namespace idoc
105
106
107
108
Base class for component implementation.
Main component interface.
Definition IComponent.h:32
Conditional model-observer binder depending on actual selection.
virtual void OnComponentCreated() override
imod::TSingleModelObserverBase< IDocumentManager > BaseClass2
virtual void BeforeUpdate(imod::IModel *modelPtr) override
Callback invoked before an update of the observer's content occurs.
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
Callback invoked after an update of the observer's content occurs.
virtual void OnComponentDestroyed() override
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept.
Common interface for any file system item name (e.g directory, file or URL path)
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition IObserver.h:156
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
Basic implementation for a single model observer with binding to concrete data object interface.
Interface for an object containing a name.
Definition INameParam.h:67
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
Contains the system independent basic implementations of Document/View design pattern.