MyGUI  3.2.0
MyGUI_EventPair.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_EVENT_PAIR_H__
23 #define __MYGUI_EVENT_PAIR_H__
24 
25 #include "MyGUI_Prerequest.h"
26 
27 namespace MyGUI
28 {
29 
30  template <typename EventObsolete, typename Event>
31  class EventPair
32  {
33  public:
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 = nullptr;
41  }
42 
43  MYGUI_OBSOLETE("use : operator += ")
44  void operator = (typename Event::IDelegate* _delegate)
45  {
46  m_eventObsolete = nullptr;
47  m_event = _delegate;
48  }
49 
50  template <typename T>
51  MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
52  void operator += (T* _delegate)
53  {
54  m_eventObsolete += _delegate;
55  m_event.clear();
56  }
57 
58  void operator += (typename Event::IDelegate* _delegate)
59  {
60  m_eventObsolete.clear();
61  m_event += _delegate;
62  }
63 
64  template <typename T>
65  MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
66  void operator -= (T* _delegate)
67  {
68  m_eventObsolete -= _delegate;
69  m_event.clear();
70  }
71 
72  void operator -= (typename Event::IDelegate* _delegate)
73  {
74  m_eventObsolete.clear();
75  m_event -= _delegate;
76  }
77 
78  template <typename TP1>
79  void operator()( TP1 p1 )
80  {
81  m_eventObsolete(p1);
82  m_event(p1);
83  }
84 
85  template <typename TP1, typename TP2>
86  void operator()( TP1 p1, TP2 p2 )
87  {
88  m_eventObsolete(p1, p2);
89  m_event(p1, p2);
90  }
91 
92  template <typename TP1, typename TP2, typename TP3>
93  void operator()( TP1 p1, TP2 p2, TP3 p3 )
94  {
95  m_eventObsolete(p1, p2, p3);
96  m_event(p1, p2, p3);
97  }
98 
99  template <typename TP1, typename TP2, typename TP3, typename TP4>
100  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
101  {
102  m_eventObsolete(p1, p2, p3, p4);
103  m_event(p1, p2, p3, p4);
104  }
105 
106  template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
107  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5 )
108  {
109  m_eventObsolete(p1, p2, p3, p4, p5);
110  m_event(p1, p2, p3, p4, p5);
111  }
112 
113  template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
114  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6 )
115  {
116  m_eventObsolete(p1, p2, p3, p4, p5, p6);
117  m_event(p1, p2, p3, p4, p5, p6);
118  }
119 
120  template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7>
121  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7 )
122  {
123  m_eventObsolete(p1, p2, p3, p4, p5, p6, p7);
124  m_event(p1, p2, p3, p4, p5, p6, p7);
125  }
126 
127  template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7, typename TP8>
128  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8 )
129  {
130  m_eventObsolete(p1, p2, p3, p4, p5, p6, p7, p8);
131  m_event(p1, p2, p3, p4, p5, p6, p7, p8);
132  }
133 
134  bool empty() const
135  {
136  return m_eventObsolete.empty() && m_event.empty();
137  }
138 
139  public:
140  EventObsolete m_eventObsolete;
141  Event m_event;
142  };
143 
144  template <typename EventObsolete, typename Event>
146  {
147  public:
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 = nullptr;
155  }
156 
157  MYGUI_OBSOLETE("use : operator += ")
158  void operator = (typename Event::IDelegate* _delegate)
159  {
160  m_eventObsolete = nullptr;
161  m_event = _delegate;
162  }
163 
164  template <typename T>
165  MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
166  void operator += (T* _delegate)
167  {
168  m_eventObsolete += _delegate;
169  m_event.clear();
170  }
171 
172  void operator += (typename Event::IDelegate* _delegate)
173  {
174  m_eventObsolete.clear();
175  m_event += _delegate;
176  }
177 
178  template <typename T>
179  MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
180  void operator -= (T* _delegate)
181  {
182  m_eventObsolete -= _delegate;
183  m_event.clear();
184  }
185 
186  void operator -= (typename Event::IDelegate* _delegate)
187  {
188  m_eventObsolete.clear();
189  m_event -= _delegate;
190  }
191 
192  template <typename TP1, typename TP2, typename TP3, typename TP4>
193  void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
194  {
195  m_eventObsolete(p1, p2, p3);
196  m_event(p1, p2, p3, p4);
197  }
198 
199  bool empty() const
200  {
201  return m_eventObsolete.empty() && m_event.empty();
202  }
203 
204  public:
205  EventObsolete m_eventObsolete;
206  Event m_event;
207  };
208 
209 } // namespace MyGUI
210 
211 #endif // __MYGUI_EVENT_PAIR_H__
void operator+=(T *_delegate)
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4)
void operator+=(T *_delegate)
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5)
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6)
void operator-=(T *_delegate)
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7)
void operator-=(T *_delegate)
void operator()(TP1 p1)
bool empty() const
void operator()(TP1 p1, TP2 p2, TP3 p3)
EventObsolete m_eventObsolete
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4)
#define MYGUI_OBSOLETE(text)
void operator()(TP1 p1, TP2 p2)
void operator()(TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8)
EventObsolete m_eventObsolete