TComponentWrap.h
Go to the documentation of this file.
1 #ifndef icomp_TComponentWrap_included
2 #define icomp_TComponentWrap_included
3 
4 
5 // ACF includes
6 #include <icomp/IComponent.h>
9 
10 
11 namespace icomp
12 {
13 
14 
18 template <class Component>
19 class TComponentWrap: public Component
20 {
21 public:
22  typedef Component BaseClass;
23 
25  virtual ~TComponentWrap();
26 
27  // pseudo-reimplemented (icomp::IComponent)
28  virtual void SetComponentContext(
29  const IComponentContext* contextPtr,
30  const ICompositeComponent* parentPtr,
31  bool isParentOwner);
32 };
33 
34 
35 // public methods
36 
37 template <class Component>
39 {
40 }
41 
42 
43 template <class Component>
45 {
46  ICompositeComponent* parentPtr = const_cast<ICompositeComponent*>(BaseClass::GetParentComponent(true));
47  if (parentPtr != NULL){
48  parentPtr->OnSubcomponentDeleted(this);
49  }
50 
51  this->SetComponentContext(NULL, NULL, false);
52 }
53 
54 
55 // pseudo-reimplemented (icomp::IComponent)
56 
57 template <class Component>
59  const IComponentContext* contextPtr,
60  const ICompositeComponent* parentPtr,
61  bool isParentOwner)
62 {
63  if (BaseClass::GetComponentContext() != NULL){
64  BaseClass::OnComponentDestroyed();
65  }
66 
67  BaseClass::SetComponentContext(contextPtr, parentPtr, isParentOwner);
68 
69  if (contextPtr != NULL){
70  BaseClass::InitStaticInfo(this);
71 
72  BaseClass::OnComponentCreated();
73  }
74 }
75 
76 
77 } // namespace icomp
78 
79 
80 #endif // !icomp_TComponentWrap_included
81 
82 
Wrapper of end component implementation used to correct control of component life-cycle.
Provide session context of component.
virtual void SetComponentContext(const IComponentContext *contextPtr, const ICompositeComponent *parentPtr, bool isParentOwner)
#define NULL
Definition: istd.h:64
virtual void OnSubcomponentDeleted(const IComponent *subcomponentPtr)=0
Called if subcomponent is removed from memory.
Composite component interface.

© 2007-2017 Witold Gantzke and Kirill Lepskiy