TComposedFactoryComp.h
Go to the documentation of this file.
1 #ifndef ibase_TComposedFactoryComp_included
2 #define ibase_TComposedFactoryComp_included
3 
4 
5 // ACF includes
7 #include <icomp/CComponentBase.h>
8 
9 
10 namespace ibase
11 {
12 
13 // TODO: check if this class should be removed from ACF project
14 template <class Interface>
16 {
17 public:
20 
21  I_BEGIN_COMPONENT(TComposedFactoryComp);
22  I_REGISTER_INTERFACE(FactoryInterface);
23  I_ASSIGN_MULTI_0(m_slaveFactoriesCompPtr, "SlaveFactories", "Slave factories", true);
24  I_END_COMPONENT;
25 
26 protected:
27  // reimplemented (icomp::CComponentBase)
28  virtual void OnComponentCreated();
29 
30 private:
31  I_MULTIREF(FactoryInterface, m_slaveFactoriesCompPtr);
32 };
33 
34 
35 // protected methods
36 
37 // reimplemented (icomp::CComponentBase)
38 
39 template <class Interface>
41 {
42  BaseClass::OnComponentCreated();
43 
44  int slaveFactoriesCount = m_slaveFactoriesCompPtr.GetCount();
45 
46  for (int factoryIndex = 0; factoryIndex < slaveFactoriesCount; ++factoryIndex){
47  Q_ASSERT(m_slaveFactoriesCompPtr.IsValid(factoryIndex)); // isObligatory was set to true
48 
49  RegisterFactory(m_slaveFactoriesCompPtr[factoryIndex]);
50  }
51 }
52 
53 
54 } // namespace ibase
55 
56 
57 #endif // !ibase_TComposedFactoryComp_included
58 
59 
icomp::CComponentBase BaseClass
Base class for component implementation.
Generic interface for a factory.
Definition: TIFactory.h:17
istd::TComposedFactory< Interface > BaseClass2
Standard generic implementation of the composed factory.

© 2007-2017 Witold Gantzke and Kirill Lepskiy