CModelUpdateBridge.h
Go to the documentation of this file.
1 #ifndef imod_CModelUpdateBridge_included
2 #define imod_CModelUpdateBridge_included
3 
4 
5 // Qt includes
6 #include <QtCore/QVector>
7 
8 // ACF includes
9 #include <istd/IChangeable.h>
10 #include <imod/IModel.h>
11 #include <imod/IObserver.h>
12 
13 
14 namespace imod
15 {
16 
17 
26 class CModelUpdateBridge: virtual public IObserver
27 {
28 public:
33  {
37  UF_DELEGATED = 0x1,
38 
42  UF_SOURCE = 0x2
43  };
44 
45  explicit CModelUpdateBridge(istd::IChangeable* changeablePtr, int updateFlags = UF_DELEGATED);
46 
47  virtual ~CModelUpdateBridge();
48 
52  imod::IModel* GetObservedModel(int modelIndex) const;
53 
57  int GetModelCount() const;
58 
62  void EnsureModelsDetached();
63 
64  // reimplemented (imod::IObserver)
65  virtual bool IsModelAttached(const imod::IModel* modelPtr) const;
66  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
67  virtual bool OnModelDetached(imod::IModel* modelPtr);
68  virtual void BeforeUpdate(imod::IModel* modelPtr);
69  virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
70 
71 private:
72  typedef QVector<imod::IModel*> Models;
73  Models m_models;
74 
75  istd::IChangeable* m_changeablePtr;
76 
77  int m_updateFlags;
78 };
79 
80 
81 } // namespace imod
82 
83 
84 #endif // !imod_CModelUpdateBridge_included
85 
void EnsureModelsDetached()
Remove all observed models from this bridge.
virtual bool IsModelAttached(const imod::IModel *modelPtr) const
Check if specified model is attached.
int GetModelCount() const
Gets the number of connected models.
Change notification of the target object will be done using change set containing CF_DELEGATED flag o...
UpdateFlags
Flags to control the change set using for the change notification of the target object.
Change notification of the target object will be done using change set of observered object...
imod::IModel * GetObservedModel(int modelIndex) const
Get access to connected model with the index index.
virtual bool OnModelDetached(imod::IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
This call back function will be called, if an observable object is about to be attached.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual void BeforeUpdate(imod::IModel *modelPtr)
This function will be called before update of the observer contents occures.
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
This function will be called after update of the observer contents occures.
Reflects the changes of observed objects as changes of some other object (over istd::IChangeable), typically delegated to itself.
CModelUpdateBridge(istd::IChangeable *changeablePtr, int updateFlags=UF_DELEGATED)
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition: IObserver.h:24
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30

© 2007-2017 Witold Gantzke and Kirill Lepskiy