MyGUI 3.2.2

MyGUI_EventPair.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_EVENT_PAIR_H_
8 #define MYGUI_EVENT_PAIR_H_
9
10 #include "MyGUI_Prerequest.h"
11
12 namespace MyGUI
13 {
14
15 template <typename EventObsolete, typename Event>
16 class EventPair
17 {
18 public:
19
20 template <typename T>
21 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
22 void operator = (T* _delegate)
23 {
24 m_eventObsolete = _delegate;
25 m_event = nullptr;
26 }
27
28 MYGUI_OBSOLETE("use : operator += ")
29 void operator = (typename Event::IDelegate* _delegate)
30 {
31 m_eventObsolete = nullptr;
32 m_event = _delegate;
33 }
34
35 template <typename T>
36 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
37 void operator += (T* _delegate)
38 {
39 m_eventObsolete += _delegate;
40 m_event.clear();
41 }
42
43 void operator += (typename Event::IDelegate* _delegate)
44 {
45 m_eventObsolete.clear();
46 m_event += _delegate;
47 }
48
49 template <typename T>
50 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
51 void operator -= (T* _delegate)
52 {
53 m_eventObsolete -= _delegate;
54 m_event.clear();
55 }
56
57 void operator -= (typename Event::IDelegate* _delegate)
58 {
59 m_eventObsolete.clear();
60 m_event -= _delegate;
61 }
62
63 template <typename TP1>
64 void operator()( TP1 p1 )
65 {
66 m_eventObsolete(p1);
67 m_event(p1);
68 }
69
70 template <typename TP1, typename TP2>
71 void operator()( TP1 p1, TP2 p2 )
72 {
73 m_eventObsolete(p1, p2);
74 m_event(p1, p2);
75 }
76
77 template <typename TP1, typename TP2, typename TP3>
78 void operator()( TP1 p1, TP2 p2, TP3 p3 )
79 {
80 m_eventObsolete(p1, p2, p3);
81 m_event(p1, p2, p3);
82 }
83
84 template <typename TP1, typename TP2, typename TP3, typename TP4>
85 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
86 {
87 m_eventObsolete(p1, p2, p3, p4);
88 m_event(p1, p2, p3, p4);
89 }
90
91 template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
92 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5 )
93 {
94 m_eventObsolete(p1, p2, p3, p4, p5);
95 m_event(p1, p2, p3, p4, p5);
96 }
97
98 template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
99 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6 )
100 {
101 m_eventObsolete(p1, p2, p3, p4, p5, p6);
102 m_event(p1, p2, p3, p4, p5, p6);
103 }
104
105 template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7>
106 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7 )
107 {
108 m_eventObsolete(p1, p2, p3, p4, p5, p6, p7);
109 m_event(p1, p2, p3, p4, p5, p6, p7);
110 }
111
112 template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7, typename TP8>
113 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8 )
114 {
115 m_eventObsolete(p1, p2, p3, p4, p5, p6, p7, p8);
116 m_event(p1, p2, p3, p4, p5, p6, p7, p8);
117 }
118
119 bool empty() const
120 {
121 return m_eventObsolete.empty() && m_event.empty();
122 }
123
124 public:
125 EventObsolete m_eventObsolete;
126 Event m_event;
127 };
128
129 template <typename EventObsolete, typename Event>
130 class EventPairAddParameter
131 {
132 public:
133
134 template <typename T>
135 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
136 void operator = (T* _delegate)
137 {
138 m_eventObsolete = _delegate;
139 m_event = nullptr;
140 }
141
142 MYGUI_OBSOLETE("use : operator += ")
143 void operator = (typename Event::IDelegate* _delegate)
144 {
145 m_eventObsolete = nullptr;
146 m_event = _delegate;
147 }
148
149 template <typename T>
150 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
151 void operator += (T* _delegate)
152 {
153 m_eventObsolete += _delegate;
154 m_event.clear();
155 }
156
157 void operator += (typename Event::IDelegate* _delegate)
158 {
159 m_eventObsolete.clear();
160 m_event += _delegate;
161 }
162
163 template <typename T>
164 MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
165 void operator -= (T* _delegate)
166 {
167 m_eventObsolete -= _delegate;
168 m_event.clear();
169 }
170
171 void operator -= (typename Event::IDelegate* _delegate)
172 {
173 m_eventObsolete.clear();
174 m_event -= _delegate;
175 }
176
177 // 1 to 2
178 template <typename TP1, typename TP2>
179 void operator()( TP1 p1, TP2 p2 )
180 {
181 m_eventObsolete(p1);
182 m_event(p1, p2);
183 }
184
185 // 2 to 3
186 template <typename TP1, typename TP2, typename TP3, typename TP4>
187 void operator()( TP1 p1, TP2 p2, TP3 p3 )
188 {
189 m_eventObsolete(p1, p2);
190 m_event(p1, p2, p3);
191 }
192
193 // 3 to 4
194 template <typename TP1, typename TP2, typename TP3, typename TP4>
195 void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
196 {
197 m_eventObsolete(p1, p2, p3);
198 m_event(p1, p2, p3, p4);
199 }
200
201 bool empty() const
202 {
203 return m_eventObsolete.empty() && m_event.empty();
204 }
205
206 public:
207 EventObsolete m_eventObsolete;
208 Event m_event;
209 };
210
211 } // namespace MyGUI
212
213 #endif // MYGUI_EVENT_PAIR_H_
MyGUI::EventPairAddParameter::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3)
Definition: MyGUI_EventPair.h:187
MyGUI::EventPairAddParameter::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4)
Definition: MyGUI_EventPair.h:195
MyGUI::EventPairAddParameter::operator()
void operator()(TP1 p1, TP2 p2)
Definition: MyGUI_EventPair.h:179
MyGUI_Prerequest.h
MyGUI::EventPair::operator+=
void operator+=(T *_delegate)
Definition: MyGUI_EventPair.h:37
MyGUI::EventPair::empty
bool empty() const
Definition: MyGUI_EventPair.h:119
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5)
Definition: MyGUI_EventPair.h:92
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6)
Definition: MyGUI_EventPair.h:99
MyGUI::EventPairAddParameter::m_eventObsolete
EventObsolete m_eventObsolete
Definition: MyGUI_EventPair.h:207
MyGUI::EventPairAddParameter::empty
bool empty() const
Definition: MyGUI_EventPair.h:201
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::EventPair::operator-=
void operator-=(T *_delegate)
Definition: MyGUI_EventPair.h:51
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7)
Definition: MyGUI_EventPair.h:106
MyGUI::EventPair
Definition: MyGUI_EventPair.h:16
MyGUI::EventPair::m_event
Event m_event
Definition: MyGUI_EventPair.h:126
MyGUI::EventPair::operator()
void operator()(TP1 p1)
Definition: MyGUI_EventPair.h:64
MyGUI::EventPairAddParameter
Definition: MyGUI_EventPair.h:130
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3)
Definition: MyGUI_EventPair.h:78
MyGUI::EventPair::m_eventObsolete
EventObsolete m_eventObsolete
Definition: MyGUI_EventPair.h:125
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4)
Definition: MyGUI_EventPair.h:85
MYGUI_OBSOLETE
#define MYGUI_OBSOLETE(text)
Definition: MyGUI_Diagnostic.h:95
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2)
Definition: MyGUI_EventPair.h:71
MyGUI::EventPair::operator()
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8)
Definition: MyGUI_EventPair.h:113
MyGUI::EventPairAddParameter::m_event
Event m_event
Definition: MyGUI_EventPair.h:208