ICF 3.1.1.10
Technical documentation of ICF Libraries
CMultiObserverBinderComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// ICF includes
11#include <imod/IModelEditor.h>
12#include <imod/IObserver.h>
13#include <imod/IModel.h>
14
15
16namespace ibase
17{
18
19
31 virtual public imod::IModelEditor,
32 virtual public imod::IObserver
33{
34public:
36
37 I_BEGIN_COMPONENT(CMultiObserverBinderComp);
38 I_REGISTER_INTERFACE(IModelEditor);
39 I_REGISTER_INTERFACE(IObserver);
40 I_ASSIGN_MULTI_0(m_observersCompPtr, "SlaveObservers", "List of components that observe the model", true);
41 I_ASSIGN_TO(m_modelEditorsCompPtr, m_observersCompPtr, false);
42 I_END_COMPONENT;
43
45
46 // reimplemented (imod::IObserver)
47 bool IsModelAttached(const imod::IModel* modelPtr = nullptr) const override;
48 bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
49 bool OnModelDetached(imod::IModel* modelPtr) override;
50 void BeforeModelChange(imod::IModel* modelPtr) override;
51 void AfterModelChange(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet) override;
52
53 // reimplemented (imod::IModelEditor)
54 void UpdateEditor(const istd::IChangeable::ChangeSet& changeSet) override;
55 void UpdateModelFromEditor() const override;
56 bool IsReadOnly() const override;
57 void SetReadOnly(bool state) override;
58
59protected:
60 // reimplemented (icomp::CComponentBase)
61 void OnComponentDestroyed() override;
62
63private:
64 void EnsureModelDetached();
65
66private:
67 I_MULTIREF(imod::IModelEditor, m_modelEditorsCompPtr);
68 I_MULTIREF(imod::IObserver, m_observersCompPtr);
69
70 imod::IModel* m_attachedModelPtr;
71};
72
73
74} // namespace ibase
75
76
Component for binding of more observers to a data model.
bool IsModelAttached(const imod::IModel *modelPtr=nullptr) const override
Check if specified model is attached.
bool IsReadOnly() const override
Returns true if the model data can be changed.
bool OnModelDetached(imod::IModel *modelPtr) override
This call back function will be called, if an observable object is about to be detached.
void UpdateEditor(const istd::IChangeable::ChangeSet &changeSet) override
Updates editor with model data.
void AfterModelChange(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
This function will be called after update of the observer contents occures.
void OnComponentDestroyed() override
void UpdateModelFromEditor() const override
Updates model from editor.
bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
This call back function will be called, if an observable object is about to be attached.
void BeforeModelChange(imod::IModel *modelPtr) override
This function will be called before update of the observer contents occures.
void SetReadOnly(bool state) override
Set flag that the model data can be changed.
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:29
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition IObserver.h:30
Set of change flags (its IDs).
Definition IChangeable.h:38
This namespace contains standard classes based on Qt.

© Witold Gantzke and Kirill Lepskiy