~ubuntu-branches/ubuntu/wily/cxxtools/wily-proposed

« back to all changes in this revision

Viewing changes to include/cxxtools/method.tpp

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2008-06-16 12:24:28 UTC
  • mfrom: (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616122428-7bllgyt1358u779r
Tags: 1.4.8-2
Made libcxxtools-dev depend on libcxxtools6, not libcxxtools5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// BEGIN_Method 10
 
2
/**
 
3
The Method class wraps member functions for use with the signals/slots framework.
 
4
*/
 
5
template < typename R,typename ClassT,class A1 = Void, class A2 = Void, class A3 = Void, class A4 = Void, class A5 = Void, class A6 = Void, class A7 = Void, class A8 = Void, class A9 = Void, class A10 = Void>
 
6
class Method : public Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>
 
7
{
 
8
    public:
 
9
        /** Convenience typedef of the wrapped member function signature. */
 
10
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10);
 
11
 
 
12
        /** Wraps the given object/member pair. */
 
13
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
14
        : _object(&object), _memFunc(ptr)
 
15
        { }
 
16
 
 
17
        /** Deeply copies rhs. */
 
18
        Method(const Method& rhs) throw()
 
19
        : Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>()
 
20
        { this->operator=(rhs); }
 
21
 
 
22
 
 
23
        /** Returns a reference to this object's wrapped ClassT object. */
 
24
        ClassT& object()
 
25
        { return *_object;}
 
26
 
 
27
        /** Returns a const reference to this object's wrapped ClassT object. */
 
28
        const ClassT& object() const
 
29
        { return *_object;}
 
30
 
 
31
        /** Returns a reference to this object's wrapped MemFuncT. */
 
32
        const MemFuncT& method() const
 
33
        { return _memFunc;}
 
34
 
 
35
        /**
 
36
          Passes on all arguments to the wrapped object/member pair and returns
 
37
          the result of that member.
 
38
        */
 
39
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
 
40
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); }
 
41
 
 
42
        /**
 
43
        Creates a copy of this object and returns it. The caller
 
44
        owns the returned object.
 
45
        */
 
46
        Method<R, ClassT, A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>* clone() const
 
47
        { return new Method(*this); }
 
48
 
 
49
        /** Deeply copies rhs. */
 
50
        Method& operator=(const Method& rhs)
 
51
        {
 
52
            if( this != &rhs ) {
 
53
                _object = rhs._object;
 
54
                _memFunc = rhs._memFunc;
 
55
            }
 
56
            return (*this);
 
57
        }
 
58
 
 
59
    private:
 
60
        ClassT* _object;
 
61
        MemFuncT _memFunc;
 
62
};
 
63
 
 
64
/**
 
65
Creates and returns a Method object for the given object/method pair.
 
66
*/
 
67
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
 
68
Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)) throw()
 
69
{
 
70
    return Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>(obj,ptr);
 
71
}
 
72
/**
 
73
  MethodSlot wraps Method objects so that they can act as Slots.
 
74
*/
 
75
template < typename R, typename ClassT,class A1 = Void, class A2 = Void, class A3 = Void, class A4 = Void, class A5 = Void, class A6 = Void, class A7 = Void, class A8 = Void, class A9 = Void, class A10 = Void>
 
76
class MethodSlot : public BasicSlot<R, A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>
 
77
{
 
78
    public:
 
79
        /** Wraps the given Method object. */
 
80
        MethodSlot(const Method<R, ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>& method)
 
81
        : _method( method )
 
82
        {}
 
83
 
 
84
        /**
 
85
        Creates a copy of this object and returns it. The caller
 
86
        owns the returned object.
 
87
        */
 
88
        Slot* clone() const
 
89
        { return new MethodSlot(*this); }
 
90
 
 
91
        /** Returns a pointer to this object's internal Callable. */
 
92
        virtual const void* callable() const
 
93
        { return &_method; }
 
94
 
 
95
        virtual bool opened(const Connection& c)
 
96
        {
 
97
            Connectable& connectable = _method.object();
 
98
            return connectable.opened(c);
 
99
        }
 
100
 
 
101
        virtual void closed(const Connection& c) 
 
102
        {
 
103
            Connectable& connectable = _method.object();
 
104
            connectable.closed(c);
 
105
        }
 
106
 
 
107
    private:
 
108
        Method<R, ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10> _method;
 
109
};
 
110
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
111
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
 
112
MethodSlot<R,BaseT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) ) throw()
 
113
{
 
114
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10>( callable( obj, memFunc ) );
 
115
}
 
116
 
 
117
// END_Method 10
 
118
// BEGIN_Method 9
 
119
template < typename R, typename ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
 
120
class Method<R,ClassT, A1,A2,A3,A4,A5,A6,A7,A8,A9,Void> : public Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,A9,Void>
 
121
{
 
122
    public:
 
123
        /** Convenience typedef of the wrapped member function signature. */
 
124
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5,A6,A7,A8,A9);
 
125
 
 
126
        /** Wraps the given object/member pair. */
 
127
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
128
        : _object(&object), _memFunc(ptr)
 
129
        { }
 
130
 
 
131
        /** Deeply copies rhs. */
 
132
        Method(const Method& rhs) throw()
 
133
        : Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,A9,Void>()
 
134
        { this->operator=(rhs); }
 
135
 
 
136
 
 
137
        /** Returns a reference to this object's wrapped ClassT object. */
 
138
        ClassT& object()
 
139
        { return *_object;}
 
140
 
 
141
        /** Returns a const reference to this object's wrapped ClassT object. */
 
142
        const ClassT& object() const
 
143
        { return *_object;}
 
144
 
 
145
        /** Returns a reference to this object's wrapped MemFuncT. */
 
146
        const MemFuncT& method() const
 
147
        { return _memFunc;}
 
148
 
 
149
        /**
 
150
          Passes on all arguments to the wrapped object/member pair and returns
 
151
          the result of that member.
 
152
        */
 
153
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
 
154
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5,a6,a7,a8,a9); }
 
155
 
 
156
        /**
 
157
        Creates a copy of this object and returns it. The caller
 
158
        owns the returned object.
 
159
        */
 
160
        Method<R, ClassT, A1,A2,A3,A4,A5,A6,A7,A8,A9,Void>* clone() const
 
161
        { return new Method(*this); }
 
162
 
 
163
        /** Deeply copies rhs. */
 
164
        Method& operator=(const Method& rhs)
 
165
        {
 
166
            if( this != &rhs ) {
 
167
                _object = rhs._object;
 
168
                _memFunc = rhs._memFunc;
 
169
            }
 
170
            return (*this);
 
171
        }
 
172
 
 
173
    private:
 
174
        ClassT* _object;
 
175
        MemFuncT _memFunc;
 
176
};
 
177
 
 
178
/**
 
179
Creates and returns a Method object for the given object/method pair.
 
180
*/
 
181
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
 
182
Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)) throw()
 
183
{
 
184
    return Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9>(obj,ptr);
 
185
}
 
186
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
187
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
 
188
MethodSlot<R,BaseT,A1,A2,A3,A4,A5,A6,A7,A8,A9> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5,A6,A7,A8,A9) ) throw()
 
189
{
 
190
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8,A9>( callable( obj, memFunc ) );
 
191
}
 
192
 
 
193
// END_Method 9
 
194
// BEGIN_Method 8
 
195
template < typename R, typename ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
 
196
class Method<R,ClassT, A1,A2,A3,A4,A5,A6,A7,A8,Void,Void> : public Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,Void,Void>
 
197
{
 
198
    public:
 
199
        /** Convenience typedef of the wrapped member function signature. */
 
200
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5,A6,A7,A8);
 
201
 
 
202
        /** Wraps the given object/member pair. */
 
203
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
204
        : _object(&object), _memFunc(ptr)
 
205
        { }
 
206
 
 
207
        /** Deeply copies rhs. */
 
208
        Method(const Method& rhs) throw()
 
209
        : Callable<R, A1,A2,A3,A4,A5,A6,A7,A8,Void,Void>()
 
210
        { this->operator=(rhs); }
 
211
 
 
212
 
 
213
        /** Returns a reference to this object's wrapped ClassT object. */
 
214
        ClassT& object()
 
215
        { return *_object;}
 
216
 
 
217
        /** Returns a const reference to this object's wrapped ClassT object. */
 
218
        const ClassT& object() const
 
219
        { return *_object;}
 
220
 
 
221
        /** Returns a reference to this object's wrapped MemFuncT. */
 
222
        const MemFuncT& method() const
 
223
        { return _memFunc;}
 
224
 
 
225
        /**
 
226
          Passes on all arguments to the wrapped object/member pair and returns
 
227
          the result of that member.
 
228
        */
 
229
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
 
230
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5,a6,a7,a8); }
 
231
 
 
232
        /**
 
233
        Creates a copy of this object and returns it. The caller
 
234
        owns the returned object.
 
235
        */
 
236
        Method<R, ClassT, A1,A2,A3,A4,A5,A6,A7,A8,Void,Void>* clone() const
 
237
        { return new Method(*this); }
 
238
 
 
239
        /** Deeply copies rhs. */
 
240
        Method& operator=(const Method& rhs)
 
241
        {
 
242
            if( this != &rhs ) {
 
243
                _object = rhs._object;
 
244
                _memFunc = rhs._memFunc;
 
245
            }
 
246
            return (*this);
 
247
        }
 
248
 
 
249
    private:
 
250
        ClassT* _object;
 
251
        MemFuncT _memFunc;
 
252
};
 
253
 
 
254
/**
 
255
Creates and returns a Method object for the given object/method pair.
 
256
*/
 
257
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
 
258
Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)) throw()
 
259
{
 
260
    return Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8>(obj,ptr);
 
261
}
 
262
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
263
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
 
264
MethodSlot<R,BaseT,A1,A2,A3,A4,A5,A6,A7,A8> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5,A6,A7,A8) ) throw()
 
265
{
 
266
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5,A6,A7,A8>( callable( obj, memFunc ) );
 
267
}
 
268
 
 
269
// END_Method 8
 
270
// BEGIN_Method 7
 
271
template < typename R, typename ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7>
 
272
class Method<R,ClassT, A1,A2,A3,A4,A5,A6,A7,Void,Void,Void> : public Callable<R, A1,A2,A3,A4,A5,A6,A7,Void,Void,Void>
 
273
{
 
274
    public:
 
275
        /** Convenience typedef of the wrapped member function signature. */
 
276
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5,A6,A7);
 
277
 
 
278
        /** Wraps the given object/member pair. */
 
279
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
280
        : _object(&object), _memFunc(ptr)
 
281
        { }
 
282
 
 
283
        /** Deeply copies rhs. */
 
284
        Method(const Method& rhs) throw()
 
285
        : Callable<R, A1,A2,A3,A4,A5,A6,A7,Void,Void,Void>()
 
286
        { this->operator=(rhs); }
 
287
 
 
288
 
 
289
        /** Returns a reference to this object's wrapped ClassT object. */
 
290
        ClassT& object()
 
291
        { return *_object;}
 
292
 
 
293
        /** Returns a const reference to this object's wrapped ClassT object. */
 
294
        const ClassT& object() const
 
295
        { return *_object;}
 
296
 
 
297
        /** Returns a reference to this object's wrapped MemFuncT. */
 
298
        const MemFuncT& method() const
 
299
        { return _memFunc;}
 
300
 
 
301
        /**
 
302
          Passes on all arguments to the wrapped object/member pair and returns
 
303
          the result of that member.
 
304
        */
 
305
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
 
306
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5,a6,a7); }
 
307
 
 
308
        /**
 
309
        Creates a copy of this object and returns it. The caller
 
310
        owns the returned object.
 
311
        */
 
312
        Method<R, ClassT, A1,A2,A3,A4,A5,A6,A7,Void,Void,Void>* clone() const
 
313
        { return new Method(*this); }
 
314
 
 
315
        /** Deeply copies rhs. */
 
316
        Method& operator=(const Method& rhs)
 
317
        {
 
318
            if( this != &rhs ) {
 
319
                _object = rhs._object;
 
320
                _memFunc = rhs._memFunc;
 
321
            }
 
322
            return (*this);
 
323
        }
 
324
 
 
325
    private:
 
326
        ClassT* _object;
 
327
        MemFuncT _memFunc;
 
328
};
 
329
 
 
330
/**
 
331
Creates and returns a Method object for the given object/method pair.
 
332
*/
 
333
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7>
 
334
Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)) throw()
 
335
{
 
336
    return Method<R,ClassT,A1,A2,A3,A4,A5,A6,A7>(obj,ptr);
 
337
}
 
338
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
339
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6, class A7>
 
340
MethodSlot<R,BaseT,A1,A2,A3,A4,A5,A6,A7> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5,A6,A7) ) throw()
 
341
{
 
342
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5,A6,A7>( callable( obj, memFunc ) );
 
343
}
 
344
 
 
345
// END_Method 7
 
346
// BEGIN_Method 6
 
347
template < typename R, typename ClassT,class A1, class A2, class A3, class A4, class A5, class A6>
 
348
class Method<R,ClassT, A1,A2,A3,A4,A5,A6,Void,Void,Void,Void> : public Callable<R, A1,A2,A3,A4,A5,A6,Void,Void,Void,Void>
 
349
{
 
350
    public:
 
351
        /** Convenience typedef of the wrapped member function signature. */
 
352
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5,A6);
 
353
 
 
354
        /** Wraps the given object/member pair. */
 
355
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
356
        : _object(&object), _memFunc(ptr)
 
357
        { }
 
358
 
 
359
        /** Deeply copies rhs. */
 
360
        Method(const Method& rhs) throw()
 
361
        : Callable<R, A1,A2,A3,A4,A5,A6,Void,Void,Void,Void>()
 
362
        { this->operator=(rhs); }
 
363
 
 
364
 
 
365
        /** Returns a reference to this object's wrapped ClassT object. */
 
366
        ClassT& object()
 
367
        { return *_object;}
 
368
 
 
369
        /** Returns a const reference to this object's wrapped ClassT object. */
 
370
        const ClassT& object() const
 
371
        { return *_object;}
 
372
 
 
373
        /** Returns a reference to this object's wrapped MemFuncT. */
 
374
        const MemFuncT& method() const
 
375
        { return _memFunc;}
 
376
 
 
377
        /**
 
378
          Passes on all arguments to the wrapped object/member pair and returns
 
379
          the result of that member.
 
380
        */
 
381
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
 
382
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5,a6); }
 
383
 
 
384
        /**
 
385
        Creates a copy of this object and returns it. The caller
 
386
        owns the returned object.
 
387
        */
 
388
        Method<R, ClassT, A1,A2,A3,A4,A5,A6,Void,Void,Void,Void>* clone() const
 
389
        { return new Method(*this); }
 
390
 
 
391
        /** Deeply copies rhs. */
 
392
        Method& operator=(const Method& rhs)
 
393
        {
 
394
            if( this != &rhs ) {
 
395
                _object = rhs._object;
 
396
                _memFunc = rhs._memFunc;
 
397
            }
 
398
            return (*this);
 
399
        }
 
400
 
 
401
    private:
 
402
        ClassT* _object;
 
403
        MemFuncT _memFunc;
 
404
};
 
405
 
 
406
/**
 
407
Creates and returns a Method object for the given object/method pair.
 
408
*/
 
409
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6>
 
410
Method<R,ClassT,A1,A2,A3,A4,A5,A6> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)) throw()
 
411
{
 
412
    return Method<R,ClassT,A1,A2,A3,A4,A5,A6>(obj,ptr);
 
413
}
 
414
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
415
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5, class A6>
 
416
MethodSlot<R,BaseT,A1,A2,A3,A4,A5,A6> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5,A6) ) throw()
 
417
{
 
418
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5,A6>( callable( obj, memFunc ) );
 
419
}
 
420
 
 
421
// END_Method 6
 
422
// BEGIN_Method 5
 
423
template < typename R, typename ClassT,class A1, class A2, class A3, class A4, class A5>
 
424
class Method<R,ClassT, A1,A2,A3,A4,A5,Void,Void,Void,Void,Void> : public Callable<R, A1,A2,A3,A4,A5,Void,Void,Void,Void,Void>
 
425
{
 
426
    public:
 
427
        /** Convenience typedef of the wrapped member function signature. */
 
428
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4,A5);
 
429
 
 
430
        /** Wraps the given object/member pair. */
 
431
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
432
        : _object(&object), _memFunc(ptr)
 
433
        { }
 
434
 
 
435
        /** Deeply copies rhs. */
 
436
        Method(const Method& rhs) throw()
 
437
        : Callable<R, A1,A2,A3,A4,A5,Void,Void,Void,Void,Void>()
 
438
        { this->operator=(rhs); }
 
439
 
 
440
 
 
441
        /** Returns a reference to this object's wrapped ClassT object. */
 
442
        ClassT& object()
 
443
        { return *_object;}
 
444
 
 
445
        /** Returns a const reference to this object's wrapped ClassT object. */
 
446
        const ClassT& object() const
 
447
        { return *_object;}
 
448
 
 
449
        /** Returns a reference to this object's wrapped MemFuncT. */
 
450
        const MemFuncT& method() const
 
451
        { return _memFunc;}
 
452
 
 
453
        /**
 
454
          Passes on all arguments to the wrapped object/member pair and returns
 
455
          the result of that member.
 
456
        */
 
457
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
 
458
        { return (_object->*_memFunc)(a1,a2,a3,a4,a5); }
 
459
 
 
460
        /**
 
461
        Creates a copy of this object and returns it. The caller
 
462
        owns the returned object.
 
463
        */
 
464
        Method<R, ClassT, A1,A2,A3,A4,A5,Void,Void,Void,Void,Void>* clone() const
 
465
        { return new Method(*this); }
 
466
 
 
467
        /** Deeply copies rhs. */
 
468
        Method& operator=(const Method& rhs)
 
469
        {
 
470
            if( this != &rhs ) {
 
471
                _object = rhs._object;
 
472
                _memFunc = rhs._memFunc;
 
473
            }
 
474
            return (*this);
 
475
        }
 
476
 
 
477
    private:
 
478
        ClassT* _object;
 
479
        MemFuncT _memFunc;
 
480
};
 
481
 
 
482
/**
 
483
Creates and returns a Method object for the given object/method pair.
 
484
*/
 
485
template <class R, class ClassT,class A1, class A2, class A3, class A4, class A5>
 
486
Method<R,ClassT,A1,A2,A3,A4,A5> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)) throw()
 
487
{
 
488
    return Method<R,ClassT,A1,A2,A3,A4,A5>(obj,ptr);
 
489
}
 
490
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
491
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4, class A5>
 
492
MethodSlot<R,BaseT,A1,A2,A3,A4,A5> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4,A5) ) throw()
 
493
{
 
494
    return MethodSlot<R,ClassT,A1,A2,A3,A4,A5>( callable( obj, memFunc ) );
 
495
}
 
496
 
 
497
// END_Method 5
 
498
// BEGIN_Method 4
 
499
template < typename R, typename ClassT,class A1, class A2, class A3, class A4>
 
500
class Method<R,ClassT, A1,A2,A3,A4,Void,Void,Void,Void,Void,Void> : public Callable<R, A1,A2,A3,A4,Void,Void,Void,Void,Void,Void>
 
501
{
 
502
    public:
 
503
        /** Convenience typedef of the wrapped member function signature. */
 
504
        typedef R (ClassT::*MemFuncT)(A1,A2,A3,A4);
 
505
 
 
506
        /** Wraps the given object/member pair. */
 
507
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
508
        : _object(&object), _memFunc(ptr)
 
509
        { }
 
510
 
 
511
        /** Deeply copies rhs. */
 
512
        Method(const Method& rhs) throw()
 
513
        : Callable<R, A1,A2,A3,A4,Void,Void,Void,Void,Void,Void>()
 
514
        { this->operator=(rhs); }
 
515
 
 
516
 
 
517
        /** Returns a reference to this object's wrapped ClassT object. */
 
518
        ClassT& object()
 
519
        { return *_object;}
 
520
 
 
521
        /** Returns a const reference to this object's wrapped ClassT object. */
 
522
        const ClassT& object() const
 
523
        { return *_object;}
 
524
 
 
525
        /** Returns a reference to this object's wrapped MemFuncT. */
 
526
        const MemFuncT& method() const
 
527
        { return _memFunc;}
 
528
 
 
529
        /**
 
530
          Passes on all arguments to the wrapped object/member pair and returns
 
531
          the result of that member.
 
532
        */
 
533
        inline R operator()(A1 a1, A2 a2, A3 a3, A4 a4) const
 
534
        { return (_object->*_memFunc)(a1,a2,a3,a4); }
 
535
 
 
536
        /**
 
537
        Creates a copy of this object and returns it. The caller
 
538
        owns the returned object.
 
539
        */
 
540
        Method<R, ClassT, A1,A2,A3,A4,Void,Void,Void,Void,Void,Void>* clone() const
 
541
        { return new Method(*this); }
 
542
 
 
543
        /** Deeply copies rhs. */
 
544
        Method& operator=(const Method& rhs)
 
545
        {
 
546
            if( this != &rhs ) {
 
547
                _object = rhs._object;
 
548
                _memFunc = rhs._memFunc;
 
549
            }
 
550
            return (*this);
 
551
        }
 
552
 
 
553
    private:
 
554
        ClassT* _object;
 
555
        MemFuncT _memFunc;
 
556
};
 
557
 
 
558
/**
 
559
Creates and returns a Method object for the given object/method pair.
 
560
*/
 
561
template <class R, class ClassT,class A1, class A2, class A3, class A4>
 
562
Method<R,ClassT,A1,A2,A3,A4> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3, A4 a4)) throw()
 
563
{
 
564
    return Method<R,ClassT,A1,A2,A3,A4>(obj,ptr);
 
565
}
 
566
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
567
template <class R, class BaseT, class ClassT,class A1, class A2, class A3, class A4>
 
568
MethodSlot<R,BaseT,A1,A2,A3,A4> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3,A4) ) throw()
 
569
{
 
570
    return MethodSlot<R,ClassT,A1,A2,A3,A4>( callable( obj, memFunc ) );
 
571
}
 
572
 
 
573
// END_Method 4
 
574
// BEGIN_Method 3
 
575
template < typename R, typename ClassT,class A1, class A2, class A3>
 
576
class Method<R,ClassT, A1,A2,A3,Void,Void,Void,Void,Void,Void,Void> : public Callable<R, A1,A2,A3,Void,Void,Void,Void,Void,Void,Void>
 
577
{
 
578
    public:
 
579
        /** Convenience typedef of the wrapped member function signature. */
 
580
        typedef R (ClassT::*MemFuncT)(A1,A2,A3);
 
581
 
 
582
        /** Wraps the given object/member pair. */
 
583
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
584
        : _object(&object), _memFunc(ptr)
 
585
        { }
 
586
 
 
587
        /** Deeply copies rhs. */
 
588
        Method(const Method& rhs) throw()
 
589
        : Callable<R, A1,A2,A3,Void,Void,Void,Void,Void,Void,Void>()
 
590
        { this->operator=(rhs); }
 
591
 
 
592
 
 
593
        /** Returns a reference to this object's wrapped ClassT object. */
 
594
        ClassT& object()
 
595
        { return *_object;}
 
596
 
 
597
        /** Returns a const reference to this object's wrapped ClassT object. */
 
598
        const ClassT& object() const
 
599
        { return *_object;}
 
600
 
 
601
        /** Returns a reference to this object's wrapped MemFuncT. */
 
602
        const MemFuncT& method() const
 
603
        { return _memFunc;}
 
604
 
 
605
        /**
 
606
          Passes on all arguments to the wrapped object/member pair and returns
 
607
          the result of that member.
 
608
        */
 
609
        inline R operator()(A1 a1, A2 a2, A3 a3) const
 
610
        { return (_object->*_memFunc)(a1,a2,a3); }
 
611
 
 
612
        /**
 
613
        Creates a copy of this object and returns it. The caller
 
614
        owns the returned object.
 
615
        */
 
616
        Method<R, ClassT, A1,A2,A3,Void,Void,Void,Void,Void,Void,Void>* clone() const
 
617
        { return new Method(*this); }
 
618
 
 
619
        /** Deeply copies rhs. */
 
620
        Method& operator=(const Method& rhs)
 
621
        {
 
622
            if( this != &rhs ) {
 
623
                _object = rhs._object;
 
624
                _memFunc = rhs._memFunc;
 
625
            }
 
626
            return (*this);
 
627
        }
 
628
 
 
629
    private:
 
630
        ClassT* _object;
 
631
        MemFuncT _memFunc;
 
632
};
 
633
 
 
634
/**
 
635
Creates and returns a Method object for the given object/method pair.
 
636
*/
 
637
template <class R, class ClassT,class A1, class A2, class A3>
 
638
Method<R,ClassT,A1,A2,A3> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2, A3 a3)) throw()
 
639
{
 
640
    return Method<R,ClassT,A1,A2,A3>(obj,ptr);
 
641
}
 
642
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
643
template <class R, class BaseT, class ClassT,class A1, class A2, class A3>
 
644
MethodSlot<R,BaseT,A1,A2,A3> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2,A3) ) throw()
 
645
{
 
646
    return MethodSlot<R,ClassT,A1,A2,A3>( callable( obj, memFunc ) );
 
647
}
 
648
 
 
649
// END_Method 3
 
650
// BEGIN_Method 2
 
651
template < typename R, typename ClassT,class A1, class A2>
 
652
class Method<R,ClassT, A1,A2,Void,Void,Void,Void,Void,Void,Void,Void> : public Callable<R, A1,A2,Void,Void,Void,Void,Void,Void,Void,Void>
 
653
{
 
654
    public:
 
655
        /** Convenience typedef of the wrapped member function signature. */
 
656
        typedef R (ClassT::*MemFuncT)(A1,A2);
 
657
 
 
658
        /** Wraps the given object/member pair. */
 
659
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
660
        : _object(&object), _memFunc(ptr)
 
661
        { }
 
662
 
 
663
        /** Deeply copies rhs. */
 
664
        Method(const Method& rhs) throw()
 
665
        : Callable<R, A1,A2,Void,Void,Void,Void,Void,Void,Void,Void>()
 
666
        { this->operator=(rhs); }
 
667
 
 
668
 
 
669
        /** Returns a reference to this object's wrapped ClassT object. */
 
670
        ClassT& object()
 
671
        { return *_object;}
 
672
 
 
673
        /** Returns a const reference to this object's wrapped ClassT object. */
 
674
        const ClassT& object() const
 
675
        { return *_object;}
 
676
 
 
677
        /** Returns a reference to this object's wrapped MemFuncT. */
 
678
        const MemFuncT& method() const
 
679
        { return _memFunc;}
 
680
 
 
681
        /**
 
682
          Passes on all arguments to the wrapped object/member pair and returns
 
683
          the result of that member.
 
684
        */
 
685
        inline R operator()(A1 a1, A2 a2) const
 
686
        { return (_object->*_memFunc)(a1,a2); }
 
687
 
 
688
        /**
 
689
        Creates a copy of this object and returns it. The caller
 
690
        owns the returned object.
 
691
        */
 
692
        Method<R, ClassT, A1,A2,Void,Void,Void,Void,Void,Void,Void,Void>* clone() const
 
693
        { return new Method(*this); }
 
694
 
 
695
        /** Deeply copies rhs. */
 
696
        Method& operator=(const Method& rhs)
 
697
        {
 
698
            if( this != &rhs ) {
 
699
                _object = rhs._object;
 
700
                _memFunc = rhs._memFunc;
 
701
            }
 
702
            return (*this);
 
703
        }
 
704
 
 
705
    private:
 
706
        ClassT* _object;
 
707
        MemFuncT _memFunc;
 
708
};
 
709
 
 
710
/**
 
711
Creates and returns a Method object for the given object/method pair.
 
712
*/
 
713
template <class R, class ClassT,class A1, class A2>
 
714
Method<R,ClassT,A1,A2> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1, A2 a2)) throw()
 
715
{
 
716
    return Method<R,ClassT,A1,A2>(obj,ptr);
 
717
}
 
718
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
719
template <class R, class BaseT, class ClassT,class A1, class A2>
 
720
MethodSlot<R,BaseT,A1,A2> slot( ClassT & obj, R (BaseT::*memFunc)(A1,A2) ) throw()
 
721
{
 
722
    return MethodSlot<R,ClassT,A1,A2>( callable( obj, memFunc ) );
 
723
}
 
724
 
 
725
// END_Method 2
 
726
// BEGIN_Method 1
 
727
template < typename R, typename ClassT,class A1>
 
728
class Method<R,ClassT, A1,Void,Void,Void,Void,Void,Void,Void,Void,Void> : public Callable<R, A1,Void,Void,Void,Void,Void,Void,Void,Void,Void>
 
729
{
 
730
    public:
 
731
        /** Convenience typedef of the wrapped member function signature. */
 
732
        typedef R (ClassT::*MemFuncT)(A1);
 
733
 
 
734
        /** Wraps the given object/member pair. */
 
735
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
736
        : _object(&object), _memFunc(ptr)
 
737
        { }
 
738
 
 
739
        /** Deeply copies rhs. */
 
740
        Method(const Method& rhs) throw()
 
741
        : Callable<R, A1,Void,Void,Void,Void,Void,Void,Void,Void,Void>()
 
742
        { this->operator=(rhs); }
 
743
 
 
744
 
 
745
        /** Returns a reference to this object's wrapped ClassT object. */
 
746
        ClassT& object()
 
747
        { return *_object;}
 
748
 
 
749
        /** Returns a const reference to this object's wrapped ClassT object. */
 
750
        const ClassT& object() const
 
751
        { return *_object;}
 
752
 
 
753
        /** Returns a reference to this object's wrapped MemFuncT. */
 
754
        const MemFuncT& method() const
 
755
        { return _memFunc;}
 
756
 
 
757
        /**
 
758
          Passes on all arguments to the wrapped object/member pair and returns
 
759
          the result of that member.
 
760
        */
 
761
        inline R operator()(A1 a1) const
 
762
        { return (_object->*_memFunc)(a1); }
 
763
 
 
764
        /**
 
765
        Creates a copy of this object and returns it. The caller
 
766
        owns the returned object.
 
767
        */
 
768
        Method<R, ClassT, A1,Void,Void,Void,Void,Void,Void,Void,Void,Void>* clone() const
 
769
        { return new Method(*this); }
 
770
 
 
771
        /** Deeply copies rhs. */
 
772
        Method& operator=(const Method& rhs)
 
773
        {
 
774
            if( this != &rhs ) {
 
775
                _object = rhs._object;
 
776
                _memFunc = rhs._memFunc;
 
777
            }
 
778
            return (*this);
 
779
        }
 
780
 
 
781
    private:
 
782
        ClassT* _object;
 
783
        MemFuncT _memFunc;
 
784
};
 
785
 
 
786
/**
 
787
Creates and returns a Method object for the given object/method pair.
 
788
*/
 
789
template <class R, class ClassT,class A1>
 
790
Method<R,ClassT,A1> callable( ClassT & obj, R (ClassT::*ptr)(A1 a1)) throw()
 
791
{
 
792
    return Method<R,ClassT,A1>(obj,ptr);
 
793
}
 
794
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
795
template <class R, class BaseT, class ClassT,class A1>
 
796
MethodSlot<R,BaseT,A1> slot( ClassT & obj, R (BaseT::*memFunc)(A1) ) throw()
 
797
{
 
798
    return MethodSlot<R,ClassT,A1>( callable( obj, memFunc ) );
 
799
}
 
800
 
 
801
// END_Method 1
 
802
// BEGIN_Method 0
 
803
template < typename R, typename ClassT>
 
804
class Method<R,ClassT, Void,Void,Void,Void,Void,Void,Void,Void,Void,Void> : public Callable<R, Void,Void,Void,Void,Void,Void,Void,Void,Void,Void>
 
805
{
 
806
    public:
 
807
        /** Convenience typedef of the wrapped member function signature. */
 
808
        typedef R (ClassT::*MemFuncT)();
 
809
 
 
810
        /** Wraps the given object/member pair. */
 
811
        explicit Method(ClassT& object, MemFuncT ptr) throw()
 
812
        : _object(&object), _memFunc(ptr)
 
813
        { }
 
814
 
 
815
        /** Deeply copies rhs. */
 
816
        Method(const Method& rhs) throw()
 
817
        : Callable<R, Void,Void,Void,Void,Void,Void,Void,Void,Void,Void>()
 
818
        { this->operator=(rhs); }
 
819
 
 
820
 
 
821
        /** Returns a reference to this object's wrapped ClassT object. */
 
822
        ClassT& object()
 
823
        { return *_object;}
 
824
 
 
825
        /** Returns a const reference to this object's wrapped ClassT object. */
 
826
        const ClassT& object() const
 
827
        { return *_object;}
 
828
 
 
829
        /** Returns a reference to this object's wrapped MemFuncT. */
 
830
        const MemFuncT& method() const
 
831
        { return _memFunc;}
 
832
 
 
833
        /**
 
834
          Passes on all arguments to the wrapped object/member pair and returns
 
835
          the result of that member.
 
836
        */
 
837
        inline R operator()() const
 
838
        { return (_object->*_memFunc)(); }
 
839
 
 
840
        /**
 
841
        Creates a copy of this object and returns it. The caller
 
842
        owns the returned object.
 
843
        */
 
844
        Method<R, ClassT, Void,Void,Void,Void,Void,Void,Void,Void,Void,Void>* clone() const
 
845
        { return new Method(*this); }
 
846
 
 
847
        /** Deeply copies rhs. */
 
848
        Method& operator=(const Method& rhs)
 
849
        {
 
850
            if( this != &rhs ) {
 
851
                _object = rhs._object;
 
852
                _memFunc = rhs._memFunc;
 
853
            }
 
854
            return (*this);
 
855
        }
 
856
 
 
857
    private:
 
858
        ClassT* _object;
 
859
        MemFuncT _memFunc;
 
860
};
 
861
 
 
862
/**
 
863
Creates and returns a Method object for the given object/method pair.
 
864
*/
 
865
template <class R, class ClassT>
 
866
Method<R,ClassT> callable( ClassT & obj, R (ClassT::*ptr)()) throw()
 
867
{
 
868
    return Method<R,ClassT>(obj,ptr);
 
869
}
 
870
/** Creates and returns a MethodSlot object for the given object/member pair. */
 
871
template <class R, class BaseT, class ClassT>
 
872
MethodSlot<R,BaseT> slot( ClassT & obj, R (BaseT::*memFunc)() ) throw()
 
873
{
 
874
    return MethodSlot<R,ClassT>( callable( obj, memFunc ) );
 
875
}
 
876
 
 
877
// END_Method 0