THierarchicalBase.h
Go to the documentation of this file.
1 #ifndef istd_THierarchicalBase_included
2 #define istd_THierarchicalBase_included
3 
4 
5 #include <istd/TIHierarchical.h>
7 
8 
9 namespace istd
10 {
11 
12 
17 template <class Base, class Interface = typename Base::InterfaceType>
19 {
20 public:
22 
24 
25  virtual void SetParentPtr(Interface* parentPtr);
26 
27  // pseudo-reimplemented (istd::TIHierarchical<Interface>)
28  virtual int GetHierarchicalFlags() const;
29  virtual int GetChildsCount() const;
30  virtual Interface* GetChild(int index) const;
31  virtual Interface* GetParent() const;
32 
33 protected:
34  Interface* m_parentPtr;
35 };
36 
37 
38 // public methods
39 
40 template <class Base, class Interface>
42 {
43  m_parentPtr = NULL;
44 }
45 
46 
47 template <class Base, class Interface>
49 {
50  m_parentPtr = parentPtr;
51 
52  istd::IChangeable* changeablePtr = dynamic_cast<istd::IChangeable*>(parentPtr);
53  if (changeablePtr){
54  BaseClass::SetSlavePtr(changeablePtr);
55  }
56 }
57 
58 
59 // pseudo-reimplemented (istd::TIHierarchical<Interface>)
60 
61 template <class Base, class Interface>
63 {
64  return BaseClass::HF_CHILDS_SUPPORTED | BaseClass::HF_PARENT_SUPPORTED;
65 }
66 
67 
68 template <class Base, class Interface>
70 {
71  return 0;
72 }
73 
74 
75 template <class Base, class Interface>
76 Interface* THierarchicalBase<Base, Interface>::GetChild(int /*index*/) const
77 {
78  return NULL;
79 }
80 
81 
82 template <class Base, class Interface>
84 {
85  return m_parentPtr;
86 }
87 
88 
89 } // namespace istd
90 
91 
92 #endif // istd_THierarchicalBase_included
93 
94 
Binder of some istd::IChangeable implementation and changing delegator.
virtual int GetChildsCount() const
Template based implementation of a hierarchical object.
virtual Interface * GetChild(int index) const
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual void SetParentPtr(Interface *parentPtr)
virtual Interface * GetParent() const
#define NULL
Definition: istd.h:64
virtual int GetHierarchicalFlags() const
istd::TChangeDelegator< Base > BaseClass

© 2007-2017 Witold Gantzke and Kirill Lepskiy