TModelWrap.h
Go to the documentation of this file.
1 #ifndef imod_TModelWrap_included
2 #define imod_TModelWrap_included
3 
4 
5 #include <istd/TDelPtr.h>
6 #include <istd/IChangeable.h>
7 
9 
10 #include <imod/CModelBase.h>
11 
12 
13 namespace imod
14 {
15 
16 
23 template <class Base>
25 {
26 public:
29 
30  TModelWrap();
31 
32  void SetBaseObject(const Base& baseObject);
33 
34  // pseudo-reimplemented (istd::IChangeable)
35  virtual int GetSupportedOperations() const;
37  virtual void BeginChanges(const istd::IChangeable::ChangeSet& changeSet);
38  virtual void EndChanges(const istd::IChangeable::ChangeSet& changeSet);
39  virtual void BeginChangeGroup(const istd::IChangeable::ChangeSet& changeSet);
40  virtual void EndChangeGroup(const istd::IChangeable::ChangeSet& changeSet);
41 
42 protected:
43  // reimplemented (imod::CModelBase)
44  virtual void OnBeginGlobalChanges();
45  virtual void OnEndGlobalChanges(const istd::IChangeable::ChangeSet& changeSet);
46 
47 private:
48  Q_DISABLE_COPY(TModelWrap);
49 };
50 
51 
52 // public methods
53 
54 template <class Base>
56 {
57 }
58 
59 
60 template <class Base>
61 void TModelWrap<Base>::SetBaseObject(const Base& baseObject)
62 {
63  Base::operator=(baseObject);
64 }
65 
66 
67 // pseudo-reimplemented (istd::IChangeable)
68 
69 template <class Base>
71 {
72  int baseOperations = Base::GetSupportedOperations();
73 
75 }
76 
77 
78 template <class Base>
80 {
82 
83  if (clonePtr->CopyFrom(*this, mode)){
84  return clonePtr.PopPtr();
85  }
86 
87  return NULL;
88 }
89 
90 
91 template <class Base>
93 {
94  BaseClass2::NotifyBeforeChange(changeSet, false);
95 }
96 
97 
98 template <class Base>
100 {
101  BaseClass2::NotifyAfterChange(changeSet);
102 }
103 
104 
105 template <class Base>
107 {
108  BaseClass2::NotifyBeforeChange(changeSet, true);
109 }
110 
111 
112 template <class Base>
114 {
115  BaseClass2::NotifyAfterChange(changeSet);
116 }
117 
118 
119 // protected methods
120 
121 // reimplemented (imod::CModelBase)
122 
123 template <class Base>
125 {
126  this->OnBeginChanges();
127 }
128 
129 
130 template <class Base>
132 {
133  this->OnEndChanges(changeSet);
134 }
135 
136 
137 } // namespace imod
138 
139 
140 #endif // !imod_TModelWrap_included
141 
142 
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
virtual int GetSupportedOperations() const
Definition: TModelWrap.h:70
Basic implementation of a model.
Definition: CModelBase.h:23
virtual void BeginChangeGroup(const istd::IChangeable::ChangeSet &changeSet)
Definition: TModelWrap.h:106
iser::TCopySerializedWrap< Base > BaseClass
Definition: TModelWrap.h:27
virtual void OnEndGlobalChanges(const istd::IChangeable::ChangeSet &changeSet)
Called after global changes are finished.
Definition: TModelWrap.h:131
Type * PopPtr()
Reset internal pointer value without deleting instance and return previos value.
Definition: TDelPtr.h:149
virtual void OnBeginGlobalChanges()
Called before global changes will be started.
Definition: TModelWrap.h:124
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
imod::CModelBase BaseClass2
Definition: TModelWrap.h:28
virtual istd::IChangeable * CloneMe(istd::IChangeable::CompatibilityMode mode=istd::IChangeable::CM_WITHOUT_REFS) const
Definition: TModelWrap.h:79
#define NULL
Definition: istd.h:64
virtual void EndChangeGroup(const istd::IChangeable::ChangeSet &changeSet)
Definition: TModelWrap.h:113
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition: TModelWrap.h:24
virtual void BeginChanges(const istd::IChangeable::ChangeSet &changeSet)
Definition: TModelWrap.h:92
Observing of this object via observer-observable pattern.
Definition: IChangeable.h:159
Set of change flags (its IDs).
Definition: IChangeable.h:30
Creating of copy of this object.
Definition: IChangeable.h:169
void SetBaseObject(const Base &baseObject)
Definition: TModelWrap.h:61
virtual void EndChanges(const istd::IChangeable::ChangeSet &changeSet)
Definition: TModelWrap.h:99
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition: TDelPtr.h:20

© 2007-2017 Witold Gantzke and Kirill Lepskiy