ICF 3.1.1.10
Technical documentation of ICF Libraries
TSupplierCompWrap.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iinsp_TSupplierCompWrap_included
7#define iinsp_TSupplierCompWrap_included
8
9
10// ICF includes
12
13
14namespace iinsp
15{
16
17
22template <class Product>
24{
25public:
27 typedef Product ProductType;
28
29 I_BEGIN_BASE_COMPONENT(TSupplierCompWrap);
30 I_END_COMPONENT;
31
32 // reimplemented (iinsp::CSupplierCompBase)
33 int ProcessWorkOutput() override;
34
35 // reimplemented (iinsp::ISupplier)
36 void ClearWorkResults() override;
37
38protected:
42 const Product* GetWorkProduct() const;
43
44 // abstract methods
49 virtual int ProduceObject(Product& result) const = 0;
50
51protected:
52 std::unique_ptr<Product> m_productPtr;
53};
54
55
56// public methods
57
58// reimplemented (iinsp::CSupplierCompBase)
59template <class Product>
61{
62 if (m_productPtr == nullptr){
63 m_productPtr = std::make_unique<Product>();
64 }
65
66 return ProduceObject(*m_productPtr);
67}
68
69
70// reimplemented (iinsp::ISupplier)
71
72template <class Product>
74{
75 if (BaseClass::GetWorkStatus() == WS_LOCKED){
76 return;
77 }
78
80 istd::CChangeNotifier changeNotifier(this, &changes);
81
82 m_productPtr = nullptr;
83
84 BaseClass::ClearWorkResults();
85}
86
87
88// protected methods
89
90template <class Product>
92{
93 const_cast< TSupplierCompWrap<Product>* >(this)->EnsureWorkFinished();
94
95 if (BaseClass::GetWorkStatus() <= WS_OK){
96 return m_productPtr.get();
97 }
98 else{
99 return nullptr;
100 }
101}
102
103
104} // namespace iinsp
105
106
107#endif // !iinsp_TSupplierCompWrap_included
108
109
Base implementation of interface iinsp::ISupplier for iinsp::TSupplierCompWrap.
@ CF_SUPPLIER_RESULTS
Supplier result changed.
Definition ISupplier.h:66
Standard implementation of interface iinsp::ISupplier with preparation for component implementation.
const Product * GetWorkProduct() const
Get current work product, if work was done correctly.
CSupplierCompBase BaseClass
std::unique_ptr< Product > m_productPtr
virtual int ProduceObject(Product &result) const =0
Produce single object.
void ClearWorkResults() override
Remove all stored work results.
Help class which provides the automatic update mechanism of the model.
Set of change flags (its IDs).
Definition IChangeable.h:38
Library containing inspection related classes and components.

© Witold Gantzke and Kirill Lepskiy