MyGUI  3.2.0
MyGUI_Delegate.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_DELEGATE_H__
00023 #define __MYGUI_DELEGATE_H__
00024 
00025 #include "MyGUI_Diagnostic.h"
00026 #include <list>
00027 
00028 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
00029 #include <typeinfo>
00030 #endif
00031 
00032 // source
00033 // http://rsdn.ru/article/cpp/delegates.xml
00034 
00035 // генерация делегатов для различного колличества параметров
00036 namespace MyGUI
00037 {
00038 
00039     namespace delegates
00040     {
00041         // базовый класс для тех классов, что хотят себя отвязывать от мульти делегатов
00042         class MYGUI_EXPORT IDelegateUnlink
00043         {
00044         public:
00045             virtual ~IDelegateUnlink() { }
00046 
00047             IDelegateUnlink()
00048             {
00049                 m_baseDelegateUnlink = this;
00050             }
00051             bool compare(IDelegateUnlink* _unlink) const
00052             {
00053                 return m_baseDelegateUnlink == _unlink->m_baseDelegateUnlink;
00054             }
00055 
00056         private:
00057             IDelegateUnlink* m_baseDelegateUnlink;
00058         };
00059 
00060         inline IDelegateUnlink* GetDelegateUnlink(void* _base)
00061         {
00062             return 0;
00063         }
00064         inline IDelegateUnlink* GetDelegateUnlink(IDelegateUnlink* _base)
00065         {
00066             return _base;
00067         }
00068     }
00069 
00070     // без параметров
00071     #define MYGUI_SUFFIX       0
00072     #define MYGUI_TEMPLATE
00073     #define MYGUI_TEMPLATE_PARAMS
00074     #define MYGUI_TEMPLATE_ARGS
00075     #define MYGUI_T_TEMPLATE_PARAMS  <typename T>
00076     #define MYGUI_T_TEMPLATE_ARGS <T>
00077     #define MYGUI_PARAMS
00078     #define MYGUI_ARGS
00079     #define MYGUI_TYPENAME
00080 
00081     #include "MyGUI_DelegateImplement.h"
00082 
00083     // один параметр
00084     #define MYGUI_SUFFIX       1
00085     #define MYGUI_TEMPLATE  template
00086     #define MYGUI_TEMPLATE_PARAMS  <typename TP1>
00087     #define MYGUI_TEMPLATE_ARGS    <TP1>
00088     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1>
00089     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1>
00090     #define MYGUI_PARAMS       TP1 p1
00091     #define MYGUI_ARGS         p1
00092     #define MYGUI_TYPENAME     typename
00093 
00094     #include "MyGUI_DelegateImplement.h"
00095 
00096     // два параметра
00097     #define MYGUI_SUFFIX       2
00098     #define MYGUI_TEMPLATE  template
00099     #define MYGUI_TEMPLATE_PARAMS  <typename TP1, typename TP2>
00100     #define MYGUI_TEMPLATE_ARGS    <TP1, TP2>
00101     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1, typename TP2>
00102     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1, TP2>
00103     #define MYGUI_PARAMS       TP1 p1, TP2 p2
00104     #define MYGUI_ARGS         p1, p2
00105     #define MYGUI_TYPENAME     typename
00106 
00107     #include "MyGUI_DelegateImplement.h"
00108 
00109     // три параметра
00110     #define MYGUI_SUFFIX       3
00111     #define MYGUI_TEMPLATE  template
00112     #define MYGUI_TEMPLATE_PARAMS  <typename TP1, typename TP2, typename TP3>
00113     #define MYGUI_TEMPLATE_ARGS    <TP1, TP2, TP3>
00114     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1, typename TP2, typename TP3>
00115     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1, TP2, TP3>
00116     #define MYGUI_PARAMS       TP1 p1, TP2 p2, TP3 p3
00117     #define MYGUI_ARGS         p1, p2, p3
00118     #define MYGUI_TYPENAME     typename
00119 
00120     #include "MyGUI_DelegateImplement.h"
00121 
00122     // четыре параметра
00123     #define MYGUI_SUFFIX       4
00124     #define MYGUI_TEMPLATE  template
00125     #define MYGUI_TEMPLATE_PARAMS  <typename TP1, typename TP2, typename TP3, typename TP4>
00126     #define MYGUI_TEMPLATE_ARGS    <TP1, TP2, TP3, TP4>
00127     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
00128     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1, TP2, TP3, TP4>
00129     #define MYGUI_PARAMS       TP1 p1, TP2 p2, TP3 p3, TP4 p4
00130     #define MYGUI_ARGS         p1, p2, p3, p4
00131     #define MYGUI_TYPENAME     typename
00132 
00133     #include "MyGUI_DelegateImplement.h"
00134 
00135     // пять параметров
00136     #define MYGUI_SUFFIX       5
00137     #define MYGUI_TEMPLATE  template
00138     #define MYGUI_TEMPLATE_PARAMS  <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
00139     #define MYGUI_TEMPLATE_ARGS    <TP1, TP2, TP3, TP4, TP5>
00140     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
00141     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1, TP2, TP3, TP4, TP5>
00142     #define MYGUI_PARAMS       TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5
00143     #define MYGUI_ARGS         p1, p2, p3, p4, p5
00144     #define MYGUI_TYPENAME     typename
00145 
00146     #include "MyGUI_DelegateImplement.h"
00147 
00148     // пять параметров
00149     #define MYGUI_SUFFIX       6
00150     #define MYGUI_TEMPLATE  template
00151     #define MYGUI_TEMPLATE_PARAMS  <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
00152     #define MYGUI_TEMPLATE_ARGS    <TP1, TP2, TP3, TP4, TP5, TP6>
00153     #define MYGUI_T_TEMPLATE_PARAMS  <typename T, typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
00154     #define MYGUI_T_TEMPLATE_ARGS    <T, TP1, TP2, TP3, TP4, TP5, TP6>
00155     #define MYGUI_PARAMS       TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6
00156     #define MYGUI_ARGS         p1, p2, p3, p4, p5, p6
00157     #define MYGUI_TYPENAME     typename
00158 
00159     #include "MyGUI_DelegateImplement.h"
00160 
00161 
00162 } // namespace MyGUI
00163 
00164 #endif // __MYGUI_DELEGATE_H__