CCompositeComponent.h
Go to the documentation of this file.
1 #ifndef icomp_CCompositeComponent_included
2 #define icomp_CCompositeComponent_included
3 
4 
5 // Qt includes
6 #include <QtCore/QByteArray>
7 #include <QtCore/QMap>
8 
9 // ACF includes
10 #include <istd/CClassInfo.h>
11 
13 #include <icomp/IRegistry.h>
16 
17 
18 namespace icomp
19 {
20 
21 
22 class IMetaInfoManager;
23 
24 
26  public CInterfaceManipBase,
27  virtual public ICompositeComponent
28 {
29 public:
30  CCompositeComponent(bool manualAutoInit);
31  virtual ~CCompositeComponent();
32 
36  template <class InterfaceType>
37  InterfaceType* GetComponentInterface(const QByteArray& subId = "");
38 
44 
45  // reimplemented (icomp::ICompositeComponent)
46  virtual IComponent* GetSubcomponent(const QByteArray& componentId) const;
47  virtual const IComponentContext* GetSubcomponentContext(const QByteArray& componentId) const;
48  virtual IComponent* CreateSubcomponent(const QByteArray& componentId) const;
49  virtual void OnSubcomponentDeleted(const IComponent* subcomponentPtr);
50 
51  // reimplemented (icomp::IComponent)
52  virtual const ICompositeComponent* GetParentComponent(bool ownerOnly = false) const;
53  virtual void* GetInterface(const istd::CClassInfo& interfaceType, const QByteArray& subId = "");
54  virtual const IComponentContext* GetComponentContext() const;
55  virtual void SetComponentContext(
56  const icomp::IComponentContext* contextPtr,
57  const ICompositeComponent* parentPtr,
58  bool isParentOwner);
59 
60 protected:
63 
73  const QByteArray& componentId,
74  ContextPtr& subContextPtr,
75  ComponentPtr* subComponentPtr,
76  bool isOwned) const;
77 
78 private:
79  struct ComponentInfo
80  {
81  ComponentInfo(): isComponentInitialized(false), isContextInitialized(false){}
85  ComponentPtr componentPtr;
90  bool isComponentInitialized;
94  ContextPtr contextPtr;
99  bool isContextInitialized;
100  };
101 
102  typedef QMap< QByteArray, ComponentInfo > ComponentMap;
103 
104  mutable ComponentMap m_componentMap;
105 
106  const CCompositeComponentContext* m_contextPtr;
107  const ICompositeComponent* m_parentPtr;
108  bool m_isParentOwner;
109 
110  bool m_manualAutoInit;
111 
112  mutable bool m_autoInitialized;
113  mutable IRegistry::Ids m_autoInitComponentIds;
114 };
115 
116 
117 // inline methods
118 
119 template <class InterfaceType>
120 inline InterfaceType* CCompositeComponent::GetComponentInterface(const QByteArray& subId)
121 {
122  static istd::CClassInfo info(typeid(InterfaceType));
123 
124  return static_cast<InterfaceType*>(GetInterface(info, subId));
125 }
126 
127 
128 } // namespace icomp
129 
130 
131 #endif // !icomp_CCompositeComponent_included
132 
133 
CCompositeComponent(bool manualAutoInit)
Main component interface.
Definition: IComponent.h:31
virtual IComponent * CreateSubcomponent(const QByteArray &componentId) const
Create instance of subcomponent using its ID.
Provide session context of component.
virtual void * GetInterface(const istd::CClassInfo &interfaceType, const QByteArray &subId="")
Get access to specified component interface.
istd::TDelPtr< icomp::IComponentContext > ContextPtr
virtual const IComponentContext * GetComponentContext() const
Get access to component context describing all application-specified component information loaded fro...
virtual const ICompositeComponent * GetParentComponent(bool ownerOnly=false) const
Get parent of this component.
virtual void OnSubcomponentDeleted(const IComponent *subcomponentPtr)
Called if subcomponent is removed from memory.
virtual void SetComponentContext(const icomp::IComponentContext *contextPtr, const ICompositeComponent *parentPtr, bool isParentOwner)
Set component context of this component.
istd::TDelPtr< icomp::IComponent > ComponentPtr
bool CreateSubcomponentInfo(const QByteArray &componentId, ContextPtr &subContextPtr, ComponentPtr *subComponentPtr, bool isOwned) const
Create information objects and subcomponent.
InterfaceType * GetComponentInterface(const QByteArray &subId="")
Get interface implemented by this composite component.
QSet< QByteArray > Ids
Definition: IRegistry.h:33
Represents platform independent type info and provide set of static class manipulation functions...
Definition: CClassInfo.h:22
virtual IComponent * GetSubcomponent(const QByteArray &componentId) const
Get access to subcomponent using its ID.
Composite component interface.
bool EnsureAutoInitComponentsCreated() const
Make sure, all components with flag 'AutoInit' are initialized.
virtual const IComponentContext * GetSubcomponentContext(const QByteArray &componentId) const
Get access to context of subcomponent using its ID.

© 2007-2017 Witold Gantzke and Kirill Lepskiy