TSupplierCompWrap.h
Go to the documentation of this file.
1 #ifndef iinsp_TSupplierCompWrap_included
2 #define iinsp_TSupplierCompWrap_included
3 
4 
5 // ACF-Solutions includes
7 
8 
9 namespace iinsp
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 (iinsp::CSupplierCompBase)
28  virtual int ProcessWorkOutput();
29 
30  // reimplemented (iinsp::ISupplier)
31  virtual void ClearWorkResults();
32 
33 protected:
37  const Product* GetWorkProduct() const;
38 
39  // abstract methods
44  virtual int ProduceObject(Product& result) const = 0;
45 
46 protected:
48 };
49 
50 
51 // public methods
52 
53 // reimplemented (iinsp::CSupplierCompBase)
54 template <class Product>
56 {
57  if (!m_productPtr.IsValid()){
58  m_productPtr.SetPtr(new Product());
59  }
60 
61  return ProduceObject(*m_productPtr);
62 }
63 
64 
65 // reimplemented (iinsp::ISupplier)
66 
67 template <class Product>
69 {
70  if (BaseClass::GetWorkStatus() == WS_LOCKED){
71  return;
72  }
73 
75  istd::CChangeNotifier changeNotifier(this, &changes);
76 
77  m_productPtr.Reset();
78 
79  BaseClass::ClearWorkResults();
80 }
81 
82 
83 // protected methods
84 
85 template <class Product>
87 {
88  const_cast< TSupplierCompWrap<Product>* >(this)->EnsureWorkFinished();
89 
90  if (BaseClass::GetWorkStatus() <= WS_OK){
91  return m_productPtr.GetPtr();
92  }
93  else{
94  return NULL;
95  }
96 }
97 
98 
99 } // namespace iinsp
100 
101 
102 #endif // !iinsp_TSupplierCompWrap_included
103 
104 
virtual void ClearWorkResults()
Remove all stored work results.
virtual int ProduceObject(Product &result) const =0
Produce single object.
Base implementation of interface iinsp::ISupplier for iinsp::TSupplierCompWrap.
Standard implementation of interface iinsp::ISupplier with preparation for component implementation...
CSupplierCompBase BaseClass
Supplier result changed.
Definition: ISupplier.h:61
#define NULL
const Product * GetWorkProduct() const
Get current work product, if work was done correctly.
istd::TDelPtr< Product > m_productPtr

© 2007-2017 Witold Gantzke and Kirill Lepskiy