mFrame
載入中...
搜尋中...
無符合項目
ConsumerEvent.h
1
7#ifndef MFRAME_536D123C_E7F9_4D81_9400_5A6BE022F590
8#define MFRAME_536D123C_E7F9_4D81_9400_5A6BE022F590
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 ConsumerEvent;
25} // namespace ufm::func
26
27/* ***************************************************************************************
28 * Class/Interface/Struct/Enum
29 */
30
40class ufm::func::ConsumerEvent final : public Object, public ufm::func::Consumer<> {
41 /* *************************************************************************************
42 * Variable
43 */
44 private:
49 void (*vFunction)(Interface&);
50
51 /* *************************************************************************************
52 * Abstract Method
53 */
54
55 /* *************************************************************************************
56 * Construct Method
57 */
58 public:
65 template <typename T>
66 ConsumerEvent(void (*function)(T&)) {
67 this->vFunction = reinterpret_cast<void (*)(Interface&)>(function);
68 return;
69 }
70
74 virtual ~ConsumerEvent(void) override;
75
76 /* *************************************************************************************
77 * Operator Method
78 */
79 public:
86 template <typename T>
87 inline operator const Consumer<T>&(void) const {
88 const Consumer<>* src = this;
89 return *reinterpret_cast<const Consumer<T>*>(src);
90 }
91
98 template <typename T>
99 inline operator Consumer<T>&(void) {
100 Consumer<>* src = this;
101 return *reinterpret_cast<Consumer<T>*>(src);
102 }
103
104 /* *************************************************************************************
105 * Override Method - ufm::func::Consumer<void*>
106 */
107 public:
108 virtual void accept(Interface& t) override;
109
110 /* *************************************************************************************
111 * Public Method
112 */
113
114 /* *************************************************************************************
115 * Protected Method
116 */
117
118 /* *************************************************************************************
119 * Private Method
120 */
121
122 /* *************************************************************************************
123 * Static Variable
124 */
125
126 /* *************************************************************************************
127 * Static Method
128 */
129};
130
131/* ***************************************************************************************
132 * End of file
133 */
134
135#endif /* MFRAME_536D123C_E7F9_4D81_9400_5A6BE022F590 */
消費者事件包裝類,將普通函數轉換為標準 Consumer 介面
Definition ConsumerEvent.h:40
ConsumerEvent(void(*function)(T &))
構造函數,接受一個函數指針並儲存它
Definition ConsumerEvent.h:66
virtual ~ConsumerEvent(void) override
析構函數
物件基底類別
Definition Object.h:63
Definition BiConsumer.h:22
[Interface] 消費者函數式介面模板
Definition Consumer.h:43
類別共用基礎介面
Definition Interface.h:152