ACF $AcfVersion:0$
CMultiObserverBinderComp.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/IModelEditor.h>
8#include <imod/IObserver.h>
9#include <imod/IModel.h>
10
11
12namespace ibase
13{
14
15
27 virtual public imod::IModelEditor,
28 virtual public imod::IObserver
29{
30public:
32
33 I_BEGIN_COMPONENT(CMultiObserverBinderComp);
34 I_REGISTER_INTERFACE(IModelEditor);
35 I_REGISTER_INTERFACE(IObserver);
36 I_ASSIGN_MULTI_0(m_observersCompPtr, "SlaveObservers", "List of components that observe the model", true);
37 I_ASSIGN_TO(m_modelEditorsCompPtr, m_observersCompPtr, false);
38 I_END_COMPONENT;
39
41
42 // reimplemented (imod::IObserver)
43 virtual bool IsModelAttached(const imod::IModel* modelPtr = NULL) const override;
44 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
45 virtual bool OnModelDetached(imod::IModel* modelPtr) override;
46 virtual void BeforeUpdate(imod::IModel* modelPtr) override;
47 virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet) override;
48
49 // reimplemented (imod::IModelEditor)
50 virtual void UpdateEditor(const istd::IChangeable::ChangeSet& changeSet) override;
51 virtual void UpdateModelFromEditor() const override;
52 virtual bool IsReadOnly() const override;
53 virtual void SetReadOnly(bool state) override;
54
55protected:
56 // reimplemented (icomp::CComponentBase)
57 virtual void OnComponentDestroyed() override;
58
59private:
60 void EnsureModelDetached();
61
62private:
63 I_MULTIREF(imod::IModelEditor, m_modelEditorsCompPtr);
64 I_MULTIREF(imod::IObserver, m_observersCompPtr);
65
66 imod::IModel* m_attachedModelPtr;
67};
68
69
70} // namespace ibase
71
72
73
74
75
Component for binding of more observers to a data model.
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
virtual void BeforeUpdate(imod::IModel *modelPtr) override
Callback invoked before an update of the observer's content occurs.
virtual void SetReadOnly(bool state) override
Set flag that the model data can be changed.
virtual bool IsReadOnly() const override
Returns true if the model data can be changed.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
Callback invoked when an observable model is about to be attached to this observer.
virtual void UpdateEditor(const istd::IChangeable::ChangeSet &changeSet) override
Updates editor with model data.
virtual bool OnModelDetached(imod::IModel *modelPtr) override
Callback invoked when an observable model is about to be detached from this observer.
virtual bool IsModelAttached(const imod::IModel *modelPtr=NULL) const override
Checks if the specified model is currently attached to this observer.
virtual void UpdateModelFromEditor() const override
Updates model from editor.
Base class for component implementation.
Common interface for an model editor.
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
Set of change flags (its IDs).
Definition IChangeable.h:36
#define NULL
Definition istd.h:74
This namespace contains basic implementations of standard primitives on the component level.