CMultiModelObserverBase.h
Go to the documentation of this file.
1 #ifndef imod_CMultiModelObserverBase_included
2 #define imod_CMultiModelObserverBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QVector>
7 
8 // ACF includes
9 #include <imod/IModel.h>
10 #include <imod/IObserver.h>
11 
12 
13 namespace imod
14 {
15 
16 
22 class CMultiModelObserverBase: virtual public IObserver
23 {
24 public:
26  virtual ~CMultiModelObserverBase();
27 
31  int GetModelCount() const;
32 
37  IModel* GetObservedModel(int modelIndex) const;
38 
43  IModel* GetModelPtr(int modelIndex) const;
44 
49  void EnsureModelsDetached();
50 
54  void SetObservedIds(const istd::IChangeable::ChangeSet& changeMask);
55 
56  // reimplemented (imod::IObserver)
57  virtual bool IsModelAttached(const IModel* modelPtr) const;
58  virtual bool OnModelAttached(IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
59  virtual bool OnModelDetached(IModel* modelPtr);
60  virtual void BeforeUpdate(IModel* modelPtr);
61  virtual void AfterUpdate(IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
62 
63 protected:
68  virtual void OnUpdate(IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
69 
70 private:
71  typedef QVector<IModel*> Models;
72 
73  Models m_models;
74 
75  istd::IChangeable::ChangeSet m_observedIds;
76 };
77 
78 
79 } // namespace imod
80 
81 
82 #endif // !imod_CMultiModelObserverBase_included
83 
void EnsureModelsDetached()
Ensure all attached models are detached.
virtual bool IsModelAttached(const IModel *modelPtr) const
Check if specified model is attached.
virtual bool OnModelDetached(IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
IModel * GetObservedModel(int modelIndex) const
Get access to connected model with the index index.
virtual bool OnModelAttached(IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
This call back function will be called, if an observable object is about to be attached.
virtual void OnUpdate(IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
Basic implementation of a multiple model observer.
IModel * GetModelPtr(int modelIndex) const
Get access to connected model with the index index.
void SetObservedIds(const istd::IChangeable::ChangeSet &changeMask)
Set list of ID's beeing observed.
virtual void BeforeUpdate(IModel *modelPtr)
This function will be called before update of the observer contents occures.
virtual void AfterUpdate(IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
This function will be called after update of the observer contents occures.
int GetModelCount() const
Gets the number of connected models.
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