2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #if defined(_DEBUG) || defined(DOXYGEN)
26 namespace ExampleMemberCaller
28 // MemberCaller example
34 void printValue() const
36 // print this->value here;
43 // a typedef to make things more readable
44 typedef MemberCaller<Integer, &Integer::setValue> SetValueCaller;
52 Callback bar = ConstMemberCaller<Integer, &Integer::printValue>(foo);
54 // invoke the callback
55 bar(); // foo.printValue()
60 // use the typedef to improve readability
61 Callback bar = Integer::SetValueCaller(foo);
63 // invoke the callback
64 bar(); // foo.setValue()
70 namespace ExampleReferenceCaller
72 // ReferenceCaller example
73 void Int_printValue(const int& value)
78 void Int_setValue(int& value)
83 // a typedef to make things more readable
84 typedef ReferenceCaller<int, Int_setValue> IntSetValueCaller;
91 Callback bar = ConstReferenceCaller<int, Int_printValue>(foo);
93 // invoke the callback
94 bar(); // Int_printValue(foo)
99 // use the typedef to improve readability
100 Callback bar = IntSetValueCaller(foo);
102 // invoke the callback
103 bar(); // Int_setValue(foo)
132 typedef Member<Test, void, &Test::test0> Test0;
133 typedef MemberCaller<Test, &Test::test0> Test0Caller;
134 void test0const() const
137 typedef ConstMember<Test, void, &Test::test0const> Test0Const;
138 typedef ConstMemberCaller<Test, &Test::test0const> Test0ConstCaller;
142 typedef Member1<Test, A1, void, &Test::test1> Test1;
143 typedef MemberCaller1<Test, A1, &Test::test1> Test1Caller;
144 void test1const(A1) const
147 typedef ConstMember1<Test, A1, void, &Test::test1const> Test1Const;
148 typedef ConstMemberCaller1<Test, A1, &Test::test1const> Test1ConstCaller;
152 typedef Member2<Test, A1, A2, void, &Test::test2> Test2;
153 void test2const(A1, A2) const
156 typedef ConstMember2<Test, A1, A2, void, &Test::test2const> Test2Const;
157 void test3(A1, A2, A3)
160 typedef Member3<Test, A1, A2, A3, void, &Test::test3> Test3;
161 void test3const(A1, A2, A3) const
164 typedef ConstMember3<Test, A1, A2, A3, void, &Test::test3const> Test3Const;
170 typedef FreeCaller<&test0free> Test0FreeCaller;
174 typedef FreeCaller1<A1, &test1free> Test1FreeCaller;
175 void test2free(A1, A2)
178 typedef Function2<A1, A2, void, &test2free> Test2Free;
179 void test3free(A1, A2, A3)
182 typedef Function3<A1, A2, A3, void, &test3free> Test3Free;
185 void test0(Test& test)
188 typedef ReferenceCaller<Test, &test0> Test0Caller;
190 void test0const(const Test& test)
193 typedef ConstReferenceCaller<Test, &test0const> Test0ConstCaller;
195 void test0p(Test* test)
198 typedef PointerCaller<Test, &test0p> Test0PCaller;
200 void test0constp(const Test* test)
203 typedef ConstPointerCaller<Test, &test0constp> Test0ConstPCaller;
205 void test1(Test& test, A1)
208 typedef ReferenceCaller1<Test, A1, &test1> Test1Caller;
210 void test1const(const Test& test, A1)
213 typedef ConstReferenceCaller1<Test, A1, &test1const> Test1ConstCaller;
215 void test1p(Test* test, A1)
218 typedef PointerCaller1<Test, A1, &test1p> Test1PCaller;
220 void test1constp(const Test* test, A1)
223 typedef ConstPointerCaller1<Test, A1, &test1constp> Test1ConstPCaller;
225 void test2(Test& test, A1, A2)
228 typedef Function3<Test&, A1, A2, void, &test2> Test2;
230 void test3(Test& test, A1, A2, A3)
233 typedef Function4<Test&, A1, A2, A3, void, &test3> Test3;
238 const Test& testconst = test;
240 Callback a = Test0FreeCaller();
241 Callback b = Test::Test0Caller(test);
242 b = makeCallback0(Test::Test0(), test);
243 Callback c = Test::Test0ConstCaller(testconst);
244 c = makeCallback0(Test::Test0Const(), test);
245 Callback d = Test0Caller(test);
246 Callback e = Test0ConstCaller(testconst);
247 Callback f = Test0PCaller(&test);
248 Callback g = Test0ConstPCaller(&testconst);
253 typedef Callback1<A1> TestCallback1;
254 TestCallback1 a = Test1FreeCaller();
255 TestCallback1 b = Test::Test1Caller(test);
256 b = makeCallback1(Test::Test1(), test);
257 TestCallback1 c = Test::Test1ConstCaller(testconst);
258 c = makeCallback1(Test::Test1Const(), test);
259 TestCallback1 d = Test1Caller(test);
260 TestCallback1 e = Test1ConstCaller(testconst);
261 TestCallback1 f = Test1PCaller(&test);
262 TestCallback1 g = Test1ConstPCaller(&testconst);
267 typedef Callback2<A1, A2> TestCallback2;
268 TestCallback2 a = makeStatelessCallback2(Test2Free());
269 TestCallback2 b = makeCallback2(Test2(), test);
270 TestCallback2 c = makeCallback2(Test::Test2(), test);
271 TestCallback2 d = makeCallback2(Test::Test2Const(), test);
276 typedef Callback3<A1, A2, A3> TestCallback3;
277 TestCallback3 a = makeStatelessCallback3(Test3Free());
278 TestCallback3 b = makeCallback3(Test3(), test);
279 TestCallback3 c = makeCallback3(Test::Test3(), test);
280 TestCallback3 d = makeCallback3(Test::Test3Const(), test);