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 mframe::func {
24 class ConsumerMethod;
25} // namespace mframe::func
26
27/* ***************************************************************************************
28 * Class/Interface/Struct/Enum
29 */
31 public mframe::func::Consumer<> {
32 /* *************************************************************************************
33 * Variable
34 */
35 private:
36 Interface& vClass;
37 void (Interface::*vMethod)(Interface&);
38
39 /* *************************************************************************************
40 * Abstract Method
41 */
42
43 /* *************************************************************************************
44 * Construct Method
45 */
46 public:
55 template <typename T = Interface, typename C = Interface>
56 ConsumerMethod(Interface& c, void (C::*method)(T&)) : vClass(c) {
57 this->vMethod = reinterpret_cast<void (Interface::*)(Interface&)>(method);
58 return;
59 }
60
67 template <typename T = Interface>
68 ConsumerMethod(Consumer<T>& cousumer) : ConsumerMethod(cousumer, Consumer<T>::accept) {
69 return;
70 }
71
76 virtual ~ConsumerMethod(void) override;
77
78 /* *************************************************************************************
79 * Operator Method
80 */
81 public:
88 template <typename T>
89 inline operator const Consumer<T>&(void) const {
90 const Consumer<>* src = this;
91 return *reinterpret_cast<const Consumer<T>*>(src);
92 }
93
99 template <typename T>
100 inline operator Consumer<T>&(void) {
101 Consumer<>* src = this;
102 return *reinterpret_cast<Consumer<T>*>(src);
103 }
104
105 /* *************************************************************************************
106 * Public Method <Override> mframe::func::Consumer<void*>
107 */
108 public:
109 virtual void accept(Interface& t) override;
110
111 /* *************************************************************************************
112 * Public Method
113 */
114
115 /* *************************************************************************************
116 * Protected Method
117 */
118
119 /* *************************************************************************************
120 * Private Method
121 */
122
123 /* *************************************************************************************
124 * Static Variable
125 */
126
127 /* *************************************************************************************
128 * Static Method
129 */
130};
131
132/* ***************************************************************************************
133 * End of file
134 */
135
136#endif /* MFRAME_D5355CD0_350F_40E5_83B7_6F237FF47EBA */
Definition ConsumerMethod.h:31
virtual ~ConsumerMethod(void) override
Destroy the object.
ConsumerMethod(Consumer< T > &cousumer)
Construct a new Consumer Method object.
Definition ConsumerMethod.h:68
ConsumerMethod(Interface &c, void(C::*method)(T &))
Construct a new Consumer Method object.
Definition ConsumerMethod.h:56
Definition Object.h:34
Definition BiConsumer.h:22
Definition Consumer.h:31
Definition Interface.h:134