mFrame
載入中...
搜尋中...
無符合項目
ConsumerMethod.h
1
7#ifndef MFRAME_D5355CD0_350F_40E5_83B7_6F237FF47EBA
8#define MFRAME_D5355CD0_350F_40E5_83B7_6F237FF47EBA
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15
16//----------------------------------------------------------------------------------------
17#include "./../func/Consumer.h"
18#include "./../lang/Object.h"
19
20/* ***************************************************************************************
21 * Namespace
22 */
23namespace ufm::func {
24 class ConsumerMethod;
25} // namespace ufm::func
26
27/* ***************************************************************************************
28 * Class/Interface/Struct/Enum
29 */
30
41 /* *************************************************************************************
42 * Variable
43 */
44 private:
49 Interface& vClass;
50
55 void (Interface::*vMethod)(Interface&);
56
57 /* *************************************************************************************
58 * Abstract Method
59 */
60
61 /* *************************************************************************************
62 * Construct Method
63 */
64 public:
77 template <typename T = Interface, typename C = Interface>
78 ConsumerMethod(Interface& c, void (C::*method)(T&)) : vClass(c) {
79 this->vMethod = reinterpret_cast<void (Interface::*)(Interface&)>(method);
80 return;
81 }
82
93 template <typename T = Interface>
95 return;
96 }
97
104 virtual ~ConsumerMethod(void) override;
105
106 /* *************************************************************************************
107 * Operator Method
108 */
109 public:
120 template <typename T>
121 inline operator const Consumer<T>&(void) const {
122 const Consumer<>* src = this;
123 return *reinterpret_cast<const Consumer<T>*>(src);
124 }
125
136 template <typename T>
137 inline operator Consumer<T>&(void) {
138 Consumer<>* src = this;
139 return *reinterpret_cast<Consumer<T>*>(src);
140 }
141
142 /* *************************************************************************************
143 * Override Method - ufm::func::Consumer<void*>
144 */
145 public:
155 virtual void accept(Interface& t) override;
156
157 /* *************************************************************************************
158 * Public Method
159 */
160
161 /* *************************************************************************************
162 * Protected Method
163 */
164
165 /* *************************************************************************************
166 * Private Method
167 */
168
169 /* *************************************************************************************
170 * Static Variable
171 */
172
173 /* *************************************************************************************
174 * Static Method
175 */
176};
177
178/* ***************************************************************************************
179 * End of file
180 */
181
182#endif /* MFRAME_D5355CD0_350F_40E5_83B7_6F237FF47EBA */
消費者方法包裝類,將類別方法轉換為標準 Consumer 介面
Definition ConsumerMethod.h:40
virtual ~ConsumerMethod(void) override
解構此物件
ConsumerMethod(Interface &c, void(C::*method)(T &))
構造一個新的 ConsumerMethod 物件
Definition ConsumerMethod.h:78
virtual void accept(Interface &t) override
實現 Consumer 介面的 accept 方法
ConsumerMethod(Consumer< T > &consumer)
從現有 Consumer 物件構造新的 ConsumerMethod 物件
Definition ConsumerMethod.h:94
物件基底類別
Definition Object.h:63
Definition BiConsumer.h:22
[Interface] 消費者函數式介面模板
Definition Consumer.h:43
類別共用基礎介面
Definition Interface.h:152