CMultiObserverBinderComp.h
Go to the documentation of this file.
1 #ifndef ibase_CMultiObserverBinderComp_included
2 #define ibase_CMultiObserverBinderComp_included
3 
4 
5 // ACF includes
6 #include <icomp/CComponentBase.h>
7 #include <imod/IModelEditor.h>
8 #include <imod/IObserver.h>
9 #include <imod/IModel.h>
10 
11 
12 namespace ibase
13 {
14 
15 
26  public icomp::CComponentBase,
27  virtual public imod::IModelEditor,
28  virtual public imod::IObserver
29 {
30 public:
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;
44  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
45  virtual bool OnModelDetached(imod::IModel* modelPtr);
46  virtual void BeforeUpdate(imod::IModel* modelPtr);
47  virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
48 
49  // reimplemented (imod::IModelEditor)
50  virtual void UpdateEditor(const istd::IChangeable::ChangeSet& changeSet);
51  virtual void UpdateModelFromEditor() const;
52  virtual bool IsReadOnly() const;
53  virtual void SetReadOnly(bool state);
54 
55 protected:
56  // reimplemented (icomp::CComponentBase)
57  virtual void OnComponentDestroyed();
58 
59 private:
60  void EnsureModelDetached();
61 
62 private:
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 #endif // !ibase_CMultiObserverBinderComp_included
74 
75 
76 
virtual void SetReadOnly(bool state)
Set flag that the model data can be changed.
Component for binding of more observers to a data model.
Base class for component implementation.
virtual bool IsModelAttached(const imod::IModel *modelPtr=NULL) const
Check if specified model is attached.
Common interface for an model editor.
Definition: IModelEditor.h:19
virtual void BeforeUpdate(imod::IModel *modelPtr)
This function will be called before update of the observer contents occures.
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.
virtual bool IsReadOnly() const
Returns true if the model data can be changed.
virtual void UpdateModelFromEditor() const
Updates model from editor.
#define NULL
Definition: istd.h:64
virtual bool OnModelDetached(imod::IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
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
virtual void UpdateEditor(const istd::IChangeable::ChangeSet &changeSet)
Updates editor with model data.
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
This function will be called after update of the observer contents occures.

© 2007-2017 Witold Gantzke and Kirill Lepskiy