TSupplierCompWrap.h
Go to the documentation of this file.
1 #ifndef iproc_TSupplierCompWrap_included
2 #define iproc_TSupplierCompWrap_included
3 
4 
5 // ACF-Solutions includes
7 
8 
9 namespace iproc
10 {
11 
12 
17 template <class Product>
19 {
20 public:
22  typedef Product ProductType;
23 
24  I_BEGIN_BASE_COMPONENT(TSupplierCompWrap);
25  I_END_COMPONENT;
26 
27  // reimplemented (iproc::ISupplier)
28  virtual void EnsureWorkFinished();
29  virtual void ClearWorkResults();
30 
31 protected:
35  const Product* GetWorkProduct() const;
36 
37  // abstract methods
42  virtual int ProduceObject(Product& result) const = 0;
43 
44 protected:
46 };
47 
48 
49 // public methods
50 
51 // reimplemented (iproc::ISupplier)
52 
53 template <class Product>
55 {
56  if (m_workStatus == WS_INIT){
57  m_workStatus = WS_LOCKED;
58 
59  if (!m_productPtr.IsValid()){
60  m_productPtr.SetPtr(new Product());
61  }
62 
63  m_workStatus = ProduceObject(*m_productPtr);
64  Q_ASSERT(m_workStatus >= WS_OK); // No initial states are possible
65 
66  m_productChangeNotifier.Reset();
67  }
68 }
69 
70 
71 template <class Product>
73 {
74  if (m_workStatus == WS_LOCKED){
75  return;
76  }
77 
78  m_productPtr.Reset();
79 
80  BaseClass::ClearWorkResults();
81 
82  m_productChangeNotifier.Reset();
83 }
84 
85 
86 // protected methods
87 
88 template <class Product>
90 {
91  const_cast< TSupplierCompWrap<Product>* >(this)->EnsureWorkFinished();
92 
93  if (m_workStatus <= WS_OK){
94  return m_productPtr.GetPtr();
95  }
96  else{
97  return NULL;
98  }
99 }
100 
101 
102 } // namespace iproc
103 
104 
105 #endif // !iproc_TSupplierCompWrap_included
106 
107 
Base implementation of interface iproc::ISupplier for iproc::TSupplierCompWrap.
CSupplierCompBase BaseClass
virtual int ProduceObject(Product &result) const =0
Produce single object.
istd::TDelPtr< Product > m_productPtr
#define NULL
virtual void ClearWorkResults()
Remove all stored work results.
virtual void EnsureWorkFinished()
Ensure that all objects are produced.
Standard implementation of interface iproc::ISupplier with preparation for component implementation...
const Product * GetWorkProduct() const
Get current work product, if work was done correctly.

© 2007-2011 Witold Gantzke and Kirill Lepskiy