MyGUI  3.2.0
MyGUI_EventPair.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_EVENT_PAIR_H__
00023 #define __MYGUI_EVENT_PAIR_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 
00027 namespace MyGUI
00028 {
00029 
00030     template <typename EventObsolete, typename Event>
00031     class EventPair
00032     {
00033     public:
00034 
00035         template <typename T>
00036         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00037         void operator = (T* _delegate)
00038         {
00039             m_eventObsolete = _delegate;
00040             m_event = nullptr;
00041         }
00042 
00043         MYGUI_OBSOLETE("use : operator += ")
00044         void operator = (typename Event::IDelegate* _delegate)
00045         {
00046             m_eventObsolete = nullptr;
00047             m_event = _delegate;
00048         }
00049 
00050         template <typename T>
00051         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00052         void operator += (T* _delegate)
00053         {
00054             m_eventObsolete += _delegate;
00055             m_event.clear();
00056         }
00057 
00058         void operator += (typename Event::IDelegate* _delegate)
00059         {
00060             m_eventObsolete.clear();
00061             m_event += _delegate;
00062         }
00063 
00064         template <typename T>
00065         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00066         void operator -= (T* _delegate)
00067         {
00068             m_eventObsolete -= _delegate;
00069             m_event.clear();
00070         }
00071 
00072         void operator -= (typename Event::IDelegate* _delegate)
00073         {
00074             m_eventObsolete.clear();
00075             m_event -= _delegate;
00076         }
00077 
00078         template <typename TP1>
00079         void operator()( TP1 p1 )
00080         {
00081             m_eventObsolete(p1);
00082             m_event(p1);
00083         }
00084 
00085         template <typename TP1, typename TP2>
00086         void operator()( TP1 p1, TP2 p2 )
00087         {
00088             m_eventObsolete(p1, p2);
00089             m_event(p1, p2);
00090         }
00091 
00092         template <typename TP1, typename TP2, typename TP3>
00093         void operator()( TP1 p1, TP2 p2, TP3 p3 )
00094         {
00095             m_eventObsolete(p1, p2, p3);
00096             m_event(p1, p2, p3);
00097         }
00098 
00099         template <typename TP1, typename TP2, typename TP3, typename TP4>
00100         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
00101         {
00102             m_eventObsolete(p1, p2, p3, p4);
00103             m_event(p1, p2, p3, p4);
00104         }
00105 
00106         template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
00107         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5 )
00108         {
00109             m_eventObsolete(p1, p2, p3, p4, p5);
00110             m_event(p1, p2, p3, p4, p5);
00111         }
00112 
00113         template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
00114         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6 )
00115         {
00116             m_eventObsolete(p1, p2, p3, p4, p5, p6);
00117             m_event(p1, p2, p3, p4, p5, p6);
00118         }
00119 
00120         template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7>
00121         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7 )
00122         {
00123             m_eventObsolete(p1, p2, p3, p4, p5, p6, p7);
00124             m_event(p1, p2, p3, p4, p5, p6, p7);
00125         }
00126 
00127         template <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6, typename TP7, typename TP8>
00128         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8 )
00129         {
00130             m_eventObsolete(p1, p2, p3, p4, p5, p6, p7, p8);
00131             m_event(p1, p2, p3, p4, p5, p6, p7, p8);
00132         }
00133 
00134         bool empty() const
00135         {
00136             return m_eventObsolete.empty() && m_event.empty();
00137         }
00138 
00139     public:
00140         EventObsolete m_eventObsolete;
00141         Event m_event;
00142     };
00143 
00144     template <typename EventObsolete, typename Event>
00145     class EventPair3to4
00146     {
00147     public:
00148 
00149         template <typename T>
00150         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00151         void operator = (T* _delegate)
00152         {
00153             m_eventObsolete = _delegate;
00154             m_event = nullptr;
00155         }
00156 
00157         MYGUI_OBSOLETE("use : operator += ")
00158         void operator = (typename Event::IDelegate* _delegate)
00159         {
00160             m_eventObsolete = nullptr;
00161             m_event = _delegate;
00162         }
00163 
00164         template <typename T>
00165         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00166         void operator += (T* _delegate)
00167         {
00168             m_eventObsolete += _delegate;
00169             m_event.clear();
00170         }
00171 
00172         void operator += (typename Event::IDelegate* _delegate)
00173         {
00174             m_eventObsolete.clear();
00175             m_event += _delegate;
00176         }
00177 
00178         template <typename T>
00179         MYGUI_OBSOLETE("use : signature : Event::IDelegate * _delegate")
00180         void operator -= (T* _delegate)
00181         {
00182             m_eventObsolete -= _delegate;
00183             m_event.clear();
00184         }
00185 
00186         void operator -= (typename Event::IDelegate* _delegate)
00187         {
00188             m_eventObsolete.clear();
00189             m_event -= _delegate;
00190         }
00191 
00192         template <typename TP1, typename TP2, typename TP3, typename TP4>
00193         void operator()( TP1 p1, TP2 p2, TP3 p3, TP4 p4 )
00194         {
00195             m_eventObsolete(p1, p2, p3);
00196             m_event(p1, p2, p3, p4);
00197         }
00198 
00199         bool empty() const
00200         {
00201             return m_eventObsolete.empty() && m_event.empty();
00202         }
00203 
00204     public:
00205         EventObsolete m_eventObsolete;
00206         Event m_event;
00207     };
00208 
00209 } // namespace MyGUI
00210 
00211 #endif // __MYGUI_EVENT_PAIR_H__