MyGUI  3.2.1
MyGUI_Delegate.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_DELEGATE_H__
8 #define __MYGUI_DELEGATE_H__
9 
10 #include "MyGUI_Diagnostic.h"
11 #include <list>
12 
13 #include <typeinfo>
14 
15 // source
16 // http://rsdn.ru/article/cpp/delegates.xml
17 
18 // генерация делегатов для различного колличества параметров
19 namespace MyGUI
20 {
21 
22  namespace delegates
23  {
24  // базовый класс для тех классов, что хотят себя отвязывать от мульти делегатов
26  {
27  public:
28  virtual ~IDelegateUnlink() { }
29 
31  {
32  m_baseDelegateUnlink = this;
33  }
34  bool compare(IDelegateUnlink* _unlink) const
35  {
36  return m_baseDelegateUnlink == _unlink->m_baseDelegateUnlink;
37  }
38 
39  private:
40  IDelegateUnlink* m_baseDelegateUnlink;
41  };
42 
43  inline IDelegateUnlink* GetDelegateUnlink(void* _base)
44  {
45  return 0;
46  }
48  {
49  return _base;
50  }
51  }
52 
53 // no parameters
54 #define MYGUI_SUFFIX 0
55 #define MYGUI_TEMPLATE
56 #define MYGUI_TEMPLATE_PARAMS
57 #define MYGUI_TEMPLATE_ARGS
58 #define MYGUI_T_TEMPLATE_PARAMS <typename T>
59 #define MYGUI_T_TEMPLATE_ARGS <T>
60 #define MYGUI_PARAMS
61 #define MYGUI_ARGS
62 #define MYGUI_TYPENAME
63 
65 
66 // one parameter
67 #define MYGUI_SUFFIX 1
68 #define MYGUI_TEMPLATE template
69 #define MYGUI_TEMPLATE_PARAMS <typename TP1>
70 #define MYGUI_TEMPLATE_ARGS <TP1>
71 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1>
72 #define MYGUI_T_TEMPLATE_ARGS <T, TP1>
73 #define MYGUI_PARAMS TP1 p1
74 #define MYGUI_ARGS p1
75 #define MYGUI_TYPENAME typename
76 
78 
79 // two parameters
80 #define MYGUI_SUFFIX 2
81 #define MYGUI_TEMPLATE template
82 #define MYGUI_TEMPLATE_PARAMS <typename TP1, typename TP2>
83 #define MYGUI_TEMPLATE_ARGS <TP1, TP2>
84 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1, typename TP2>
85 #define MYGUI_T_TEMPLATE_ARGS <T, TP1, TP2>
86 #define MYGUI_PARAMS TP1 p1, TP2 p2
87 #define MYGUI_ARGS p1, p2
88 #define MYGUI_TYPENAME typename
89 
91 
92 // three parameters
93 #define MYGUI_SUFFIX 3
94 #define MYGUI_TEMPLATE template
95 #define MYGUI_TEMPLATE_PARAMS <typename TP1, typename TP2, typename TP3>
96 #define MYGUI_TEMPLATE_ARGS <TP1, TP2, TP3>
97 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1, typename TP2, typename TP3>
98 #define MYGUI_T_TEMPLATE_ARGS <T, TP1, TP2, TP3>
99 #define MYGUI_PARAMS TP1 p1, TP2 p2, TP3 p3
100 #define MYGUI_ARGS p1, p2, p3
101 #define MYGUI_TYPENAME typename
102 
103 #include "MyGUI_DelegateImplement.h"
104 
105 // four parameters
106 #define MYGUI_SUFFIX 4
107 #define MYGUI_TEMPLATE template
108 #define MYGUI_TEMPLATE_PARAMS <typename TP1, typename TP2, typename TP3, typename TP4>
109 #define MYGUI_TEMPLATE_ARGS <TP1, TP2, TP3, TP4>
110 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
111 #define MYGUI_T_TEMPLATE_ARGS <T, TP1, TP2, TP3, TP4>
112 #define MYGUI_PARAMS TP1 p1, TP2 p2, TP3 p3, TP4 p4
113 #define MYGUI_ARGS p1, p2, p3, p4
114 #define MYGUI_TYPENAME typename
115 
116 #include "MyGUI_DelegateImplement.h"
117 
118 // five parameters
119 #define MYGUI_SUFFIX 5
120 #define MYGUI_TEMPLATE template
121 #define MYGUI_TEMPLATE_PARAMS <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
122 #define MYGUI_TEMPLATE_ARGS <TP1, TP2, TP3, TP4, TP5>
123 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1, typename TP2, typename TP3, typename TP4, typename TP5>
124 #define MYGUI_T_TEMPLATE_ARGS <T, TP1, TP2, TP3, TP4, TP5>
125 #define MYGUI_PARAMS TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5
126 #define MYGUI_ARGS p1, p2, p3, p4, p5
127 #define MYGUI_TYPENAME typename
129 #include "MyGUI_DelegateImplement.h"
130 
131 // six parameters
132 #define MYGUI_SUFFIX 6
133 #define MYGUI_TEMPLATE template
134 #define MYGUI_TEMPLATE_PARAMS <typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
135 #define MYGUI_TEMPLATE_ARGS <TP1, TP2, TP3, TP4, TP5, TP6>
136 #define MYGUI_T_TEMPLATE_PARAMS <typename T, typename TP1, typename TP2, typename TP3, typename TP4, typename TP5, typename TP6>
137 #define MYGUI_T_TEMPLATE_ARGS <T, TP1, TP2, TP3, TP4, TP5, TP6>
138 #define MYGUI_PARAMS TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6
139 #define MYGUI_ARGS p1, p2, p3, p4, p5, p6
140 #define MYGUI_TYPENAME typename
141 
144 
145 } // namespace MyGUI
146 
147 #endif // __MYGUI_DELEGATE_H__