mFrame
載入中...
搜尋中...
無符合項目
FunctionMethod.h
1
7#ifndef MFRAME_F6D62182_CA3A_4CCA_82D2_44B456A08840
8#define MFRAME_F6D62182_CA3A_4CCA_82D2_44B456A08840
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15
16//----------------------------------------------------------------------------------------
17#include "./../func/Function.h"
18#include "./../lang/Object.h"
19
20/* ***************************************************************************************
21 * Namespace
22 */
23namespace ufm::func {
24 class FunctionMethod;
25} // namespace ufm::func
26
27/* ***************************************************************************************
28 * Class/Interface/Struct/Enum
29 */
30
41 /* *************************************************************************************
42 * Variable
43 */
44 private:
49 Interface& vClass;
50
55 Interface& (Interface::*vMethod)(Interface&);
56
57 /* *************************************************************************************
58 * Abstract Method
59 */
60
61 /* *************************************************************************************
62 * Construct Method
63 */
64 public:
78 template <typename T = Interface, typename R = Interface, typename C = Interface>
79 FunctionMethod(Interface& c, Interface& (C::*method)(Interface&)) : vClass(c) {
80 this->vMethod = reinterpret_cast<Interface& (Interface::*)(Interface&)>(method);
81 return;
82 }
83
95 template <typename T = Interface, typename R = Interface>
97 : FunctionMethod(function, Function<T, R>::apply) {
98 return;
99 }
100
107 virtual ~FunctionMethod(void) override;
108
109 /* *************************************************************************************
110 * Operator Method
111 */
112 public:
124 template <typename T, typename R>
125 inline operator const Function<T, R>&(void) const {
126 const Function<>* src = this;
127 return *reinterpret_cast<const Function<T, R>*>(src);
128 }
129
141 template <typename T, typename R>
142 inline operator Function<T, R>&(void) {
143 Function<>* src = this;
144 return *reinterpret_cast<Function<T, R>*>(src);
145 }
146
147 /* *************************************************************************************
148 * Override Method - ufm::func::Function<Interface, Interface>
149 */
150 public:
161 virtual Interface& apply(Interface& t) override;
162
163 /* *************************************************************************************
164 * Public Method
165 */
166
167 /* *************************************************************************************
168 * Protected Method
169 */
170
171 /* *************************************************************************************
172 * Private Method
173 */
174
175 /* *************************************************************************************
176 * Static Variable
177 */
178
179 /* *************************************************************************************
180 * Static Method
181 */
182};
183
184/* ***************************************************************************************
185 * End of file
186 */
187
188#endif /* MFRAME_F6D62182_CA3A_4CCA_82D2_44B456A08840 */
函數方法包裝類,用於將類別方法轉換為標準 Function 介面
Definition FunctionMethod.h:40
virtual Interface & apply(Interface &t) override
實現 Function 介面的 apply 方法
FunctionMethod(Interface &c, Interface &(C::*method)(Interface &))
構造一個新的函數方法對象
Definition FunctionMethod.h:79
FunctionMethod(Function< T, R > &function)
從現有的函數對象構造函數方法對象
Definition FunctionMethod.h:96
virtual ~FunctionMethod(void) override
解構函數方法對象
物件基底類別
Definition Object.h:63
Definition BiConsumer.h:22
[Interface] 函數介面,提供接收單個參數並產生回傳值的功能
Definition Function.h:43
類別共用基礎介面
Definition Interface.h:152