CSelectedDocModelBinderComp.h
Go to the documentation of this file.
1 #ifndef idoc_CSelectedDocModelBinderComp_included
2 #define idoc_CSelectedDocModelBinderComp_included
3 
4 
5 // ACF includes
7 #include <imod/TModelWrap.h>
8 #include <icomp/CComponentBase.h>
9 #include <iprm/INameParam.h>
10 #include <ifile/IFileNameParam.h>
11 #include <idoc/IDocumentManager.h>
12 
13 
14 namespace idoc
15 {
16 
17 
25  public icomp::CComponentBase,
26  protected imod::TSingleModelObserverBase<IDocumentManager>
27 {
28 public:
31 
32  I_BEGIN_COMPONENT(CSelectedDocModelBinderComp);
33  I_REGISTER_SUBELEMENT(SelectedDocumentInfo);
34  I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, iprm::INameParam, ExtractSelectedDocumentInfo);
35  I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, ifile::IFileNameParam, ExtractSelectedDocumentInfo);
36  I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, imod::IModel, ExtractSelectedDocumentInfo);
37  I_REGISTER_SUBELEMENT_INTERFACE(SelectedDocumentInfo, istd::IChangeable, ExtractSelectedDocumentInfo);
38  I_ASSIGN(m_observedObjectCompPtr, "ActivationObject", "Object will be observed if it is active", true, "ActivationObject");
39  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager used to check which object is active", true, "DocumentManager");
40  I_ASSIGN_TO(m_documentManagerModelCompPtr, m_documentManagerCompPtr, true);
41  I_ASSIGN(m_modelCompPtr, "Model", "Model to be connected", true, "Model");
42  I_ASSIGN_MULTI_0(m_observersCompPtr, "Observers", "Observers for the model", true);
43  I_END_COMPONENT;
44 
46 
47 protected:
48  void TryConnectObservers();
50 
51  // reimplemented (imod::IObserver)
52  virtual void BeforeUpdate(imod::IModel* modelPtr);
53  virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
54 
55  // reimplemented (icomp::CComponentBase)
56  virtual void OnComponentCreated();
57  virtual void OnComponentDestroyed();
58 
59 private:
60  I_REF(icomp::IComponent, m_observedObjectCompPtr);
61  I_REF(IDocumentManager, m_documentManagerCompPtr);
62  I_REF(imod::IModel, m_documentManagerModelCompPtr);
63  I_REF(imod::IModel, m_modelCompPtr);
64  I_MULTIREF(imod::IObserver, m_observersCompPtr);
65 
66  // static template methods for subelement access
67  template <class InterfaceType>
68  static InterfaceType* ExtractSelectedDocumentInfo(CSelectedDocModelBinderComp& component)
69  {
70  return &component.m_selectedDocumentInfo;
71  }
72 
73  class DocumentInfo:
74  virtual public iprm::INameParam,
75  virtual public ifile::IFileNameParam
76  {
77  public:
78  // reimplemented (iprm::INameParam)
79  virtual const QString& GetName() const;
80  virtual void SetName(const QString& name);
81  virtual bool IsNameFixed() const;
82 
83  // reimplemented (ifile::IFileNameParam)
84  virtual int GetPathType() const;
85  virtual const QString& GetPath() const;
86  virtual void SetPath(const QString& path);
87 
88  // reimplemented (iser::ISerializable)
89  virtual bool Serialize(iser::IArchive& archive);
90 
91  QString name;
92  QString filePath;
93  };
94 
95  bool m_isActive;
96 
97  typedef QMap<imod::IObserver*, imod::IModel*> ModelObserverMap;
98  ModelObserverMap m_connectedMap;
99 
100  imod::TModelWrap<DocumentInfo> m_selectedDocumentInfo;
101 };
102 
103 
104 } // namespace idoc
105 
106 
107 #endif // !idoc_CSelectedDocModelBinderComp_included
108 
109 
Interface for a object containing simple text.
Definition: INameParam.h:20
Base class for component implementation.
Main component interface.
Definition: IComponent.h:31
Basic implementation for a single model observer with binding to concrete data object interface...
Common interface for any file system item name (e.g directory, file or URL path)
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
This function will be called after update of the observer contents occures.
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept...
imod::TSingleModelObserverBase< IDocumentManager > BaseClass2
virtual void BeforeUpdate(imod::IModel *modelPtr)
This function will be called before update of the observer contents occures.
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition: IObserver.h:24
Conditional model-observer binder depending on actual selection.
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