mFrame
載入中...
搜尋中...
無符合項目
FunctionEvent.h
1
7#ifndef MFRAME_F730676C_6AFB_43FF_A269_0F8D00511C5D
8#define MFRAME_F730676C_6AFB_43FF_A269_0F8D00511C5D
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 FunctionEvent;
25} // namespace ufm::func
26
27/* ***************************************************************************************
28 * Class/struct/Struct
29 */
30
40class ufm::func::FunctionEvent final : public Object, public ufm::func::Function<> {
41 /* *************************************************************************************
42 * Variable
43 */
44 private:
49 Interface& (*vFunction)(Interface&);
50
51 /* *************************************************************************************
52 * Abstract Method
53 */
54
55 /* *************************************************************************************
56 * Construct Method
57 */
58 public:
70 template <typename T, typename R>
71 FunctionEvent(R& (*function)(T&)) {
72 this->vFunction = reinterpret_cast<Interface& (*)(Interface&)>(function);
73 return;
74 }
75
82 virtual ~FunctionEvent(void) override;
83
84 /* *************************************************************************************
85 * Operator Method
86 */
87 public:
99 template <typename T, typename R>
100 inline operator const Function<T, R>&(void) const {
101 const Function<>* src = this;
102 return *reinterpret_cast<const Function<T, R>*>(src);
103 }
104
116 template <typename T, typename R>
117 inline operator Function<T, R>&(void) {
118 Function<>* src = this;
119 return *reinterpret_cast<Function<T, R>*>(src);
120 }
121
122 /* *************************************************************************************
123 * Override Method - ufm::func::Function<Interface, Interface>
124 */
125 public:
136 virtual Interface& apply(Interface& t) override;
137
138 /* *************************************************************************************
139 * Public Method
140 */
141
142 /* *************************************************************************************
143 * Protected Method
144 */
145
146 /* *************************************************************************************
147 * Private Method
148 */
149
150 /* *************************************************************************************
151 * Static Variable
152 */
153
154 /* *************************************************************************************
155 * Static Method
156 */
157};
158
159/* ***************************************************************************************
160 * End of file
161 */
162
163#endif /* MFRAME_F730676C_6AFB_43FF_A269_0F8D00511C5D */
函數事件包裝類,將普通函數轉換為標準 Function 介面
Definition FunctionEvent.h:40
virtual Interface & apply(Interface &t) override
實現 Function 介面的 apply 方法
FunctionEvent(R &(*function)(T &))
構造一個新的函數事件對象
Definition FunctionEvent.h:71
virtual ~FunctionEvent(void) override
解構函數事件對象
物件基底類別
Definition Object.h:63
Definition BiConsumer.h:22
[Interface] 函數介面,提供接收單個參數並產生回傳值的功能
Definition Function.h:43
類別共用基礎介面
Definition Interface.h:152