MyGUI  3.2.1
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>
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__