MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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