ICF 3.0.5.47
Technical documentation of ICF Libraries
CModelUpdateBridge.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#ifndef imod_CModelUpdateBridge_included
7#define imod_CModelUpdateBridge_included
8
9
10// Qt includes
11#include <QtCore/QVector>
12#include <QtCore/QReadWriteLock>
13
14// ICF includes
15#include <istd/IChangeable.h>
16#include <imod/IModel.h>
17#include <imod/IObserver.h>
18
19
20namespace imod
21{
22
23
32class CModelUpdateBridge: virtual public IObserver
33{
34public:
39 {
44
48 UF_SOURCE = 0x2
49 };
50
52 explicit CModelUpdateBridge(istd::IChangeable* changeablePtr, int updateFlags = UF_DELEGATED);
53
55
59 imod::IModel* GetObservedModel(int modelIndex) const;
60
64 int GetModelCount() const;
65
70
71 // reimplemented (imod::IObserver)
72 bool IsModelAttached(const imod::IModel* modelPtr) const override;
73 bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
74 bool OnModelDetached(imod::IModel* modelPtr) override;
75 void BeforeModelChange(imod::IModel* modelPtr) override;
76 void AfterModelChange(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet) override;
77
78private:
79 bool IsAttached(const imod::IModel* modelPtr) const;
80
81private:
82 typedef QVector<imod::IModel*> Models;
83 Models m_models;
84
85 istd::IChangeable* m_changeablePtr;
86
87 int m_updateFlags;
88
89 mutable QReadWriteLock m_modelListMutex;
90};
91
92
93} // namespace imod
94
95
96#endif // !imod_CModelUpdateBridge_included
97
Reflects the changes of observed objects as changes of some other object (over istd::IChangeable),...
CModelUpdateBridge(istd::IChangeable *changeablePtr, int updateFlags=UF_DELEGATED)
CModelUpdateBridge(CModelUpdateBridge &&bridge) noexcept
void AfterModelChange(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
This function will be called after update of the observer contents occures.
void EnsureModelsDetached()
Remove all observed models from this bridge.
UpdateFlags
Flags to control the change set using for the change notification of the target object.
@ UF_DELEGATED
Change notification of the target object will be done using change set containing CF_DELEGATED flag o...
@ UF_SOURCE
Change notification of the target object will be done using change set of observered object.
void BeforeModelChange(imod::IModel *modelPtr) override
This function will be called before update of the observer contents occures.
imod::IModel * GetObservedModel(int modelIndex) const
Get access to connected model with the index index.
int GetModelCount() const
Gets the number of connected models.
bool OnModelDetached(imod::IModel *modelPtr) override
This call back function will be called, if an observable object is about to be detached.
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.
bool IsModelAttached(const imod::IModel *modelPtr) const override
Check if specified model is attached.
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
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
This namespace containes basic implementation of Model/Observer design pattern This package is system...
Definition CModelBase.h:20

© Witold Gantzke and Kirill Lepskiy