1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/signals/functor-delegate.h>
31 * @brief Callback base class to hold the data for callback function and member function calls.
33 class DALI_IMPORT_API CallbackBase
38 * @brief Default constructor
48 * @brief Resets the object pointer so that we know not to call methods of this object any more.
53 * @brief Function to call the function or member function dispatcher
55 * @param[in] callback The callback to call.
57 static void Execute( CallbackBase& callback )
59 // if we point to a function, we can call it directly
60 // otherwise call the dispatcher function that knows the real type of the object
61 // Note that this template dispatcher lives in client code so the library containing
62 // the code has to be loaded, otherwise we crash boom bang
63 if( callback.mImpl && callback.mImpl->mObjectPointer )
65 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
66 (*dispatcher)( callback );
68 // its also possible to have a member function pointer to a CallbackProvider
69 // that has been deleted, so check if we have impl still
70 else if( !callback.mImpl && callback.mFunction )
72 (*(callback.mFunction))();
77 * @brief Function to call the function or member function dispatcher.
79 * @param[in] callback The callback to call.
80 * @return value from the function
82 template< typename R >
83 static R ExecuteReturn( CallbackBase& callback )
86 // if we point to a function, we can call it directly
87 // otherwise call the dispatcher function that knows the real type of the object
88 // Note that this template dispatcher lives in client code so the library containing
89 // the code has to be loaded, otherwise we crash boom bang
90 if( callback.mImpl && callback.mImpl->mObjectPointer )
92 typedef R(*Dispatcher)(CallbackBase& base);
93 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
94 returnVal = (*dispatcher)( callback );
96 else if( !callback.mImpl && callback.mFunction )
98 typedef R(*Function1)();
99 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
106 * @brief Function to call the function or member function dispatcher.
108 * This function template gets instantiated at the call site
109 * @param[in] callback The callback to call.
110 * @param[in] param1 The first parameter to pass into the function.
112 template< typename P1 >
113 static void Execute( CallbackBase& callback, P1 param1 )
115 // if we point to a function, we can call it directly
116 // otherwise call the dispatcher function that knows the real type of the object
117 // Note that this template dispatcher lives in client code (where the callback was created)
118 // so the library containing the code has to be loaded, otherwise we crash boom bang
119 if( callback.mImpl && callback.mImpl->mObjectPointer )
121 typedef void(*Dispatcher)(CallbackBase& base,P1);
122 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
123 (*dispatcher)( callback, param1 );
125 else if( !callback.mImpl && callback.mFunction )
127 // convert function type
128 typedef void(*Function1)(P1);
129 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
134 * @brief Function to call the function or member function dispatcher.
136 * This function template gets instantiated at the call site
137 * @param[in] callback The callback to call.
138 * @param[in] param1 The first parameter to pass into the function.
139 * @return the value from the function
141 template< typename R, typename P1 >
142 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
145 // if we point to a function, we can call it directly
146 // otherwise call the dispatcher function that knows the real type of the object
147 // Note that this template dispatcher lives in client code (where the callback was created)
148 // so the library containing the code has to be loaded, otherwise we crash boom bang
149 if( callback.mImpl && callback.mImpl->mObjectPointer )
151 typedef R(*Dispatcher)(CallbackBase& base,P1);
152 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
153 returnVal = (*dispatcher)( callback, param1 );
155 else if( !callback.mImpl && callback.mFunction )
157 // convert function type
158 typedef R(*Function1)(P1);
159 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
166 * @brief Function to call the function or member function dispatcher.
168 * This function template gets instantiated at the call site.
169 * @param[in] callback The callback to call.
170 * @param[in] param1 The first parameter to pass into the function.
171 * @param[in] param2 The second parameter to pass into the function.
173 template< typename P1, typename P2 >
174 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
176 // if we point to a function, we can call it directly
177 // otherwise call the dispatcher function that knows the real type of the object
178 // Note that this template dispatcher lives in client code (where the callback was created)
179 // so the library containing the code has to be loaded, otherwise we crash boom bang
180 if( callback.mImpl && callback.mImpl->mObjectPointer )
182 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
183 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
184 (*dispatcher)( callback, param1, param2 );
186 else if( !callback.mImpl && callback.mFunction )
188 // convert function type
189 typedef void(*Function2)(P1,P2);
190 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
195 * @brief Function to call the function or member function dispatcher.
197 * This function template gets instantiated at the call site
198 * @param[in] callback The callback to call.
199 * @param[in] param1 The first parameter to pass into the function.
200 * @param[in] param2 The second parameter to pass into the function.
201 * @return The return value from the function
203 template< typename R, typename P1, typename P2 >
204 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
207 // if we point to a function, we can call it directly
208 // otherwise call the dispatcher function that knows the real type of the object
209 // Note that this template dispatcher lives in client code (where the callback was created)
210 // so the library containing the code has to be loaded, otherwise we crash boom bang
211 if( callback.mImpl && callback.mImpl->mObjectPointer )
213 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
214 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
215 returnVal = (*dispatcher)( callback, param1, param2 );
217 else if( !callback.mImpl && callback.mFunction )
219 // convert function type
220 typedef R(*Function2)(P1,P2);
221 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
228 * @brief Function to call the function or member function dispatcher.
230 * This function template gets instantiated at the call site.
231 * @param[in] callback The callback to call.
232 * @param[in] param1 The first parameter to pass into the function.
233 * @param[in] param2 The second parameter to pass into the function.
234 * @param[in] param3 The third parameter to pass into the function.
236 template< typename P1, typename P2, typename P3 >
237 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
239 // if we point to a function, we can call it directly
240 // otherwise call the dispatcher function that knows the real type of the object
241 // Note that this template dispatcher lives in client code (where the callback was created)
242 // so the library containing the code has to be loaded, otherwise we crash boom bang
243 if( callback.mImpl && callback.mImpl->mObjectPointer )
245 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
246 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
247 (*dispatcher)( callback, param1, param2, param3 );
249 else if( !callback.mImpl && callback.mFunction )
251 // convert function type
252 typedef void(*Function2)(P1,P2,P3);
253 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
258 * @brief Function to call the function or member function dispatcher.
260 * This function template gets instantiated at the call site
261 * @param[in] callback The callback to call.
262 * @param[in] param1 The first parameter to pass into the function.
263 * @param[in] param2 The second parameter to pass into the function.
264 * @param[in] param3 The third parameter to pass into the function.
265 * @return The return value from the function
267 template< typename R, typename P1, typename P2, typename P3 >
268 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
271 // if we point to a function, we can call it directly
272 // otherwise call the dispatcher function that knows the real type of the object
273 // Note that this template dispatcher lives in client code (where the callback was created)
274 // so the library containing the code has to be loaded, otherwise we crash boom bang
275 if( callback.mImpl && callback.mImpl->mObjectPointer )
277 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
278 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
279 returnVal = (*dispatcher)( callback, param1, param2, param3 );
281 else if( !callback.mImpl && callback.mFunction )
283 // convert function type
284 typedef R(*Function2)(P1,P2,P3);
285 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
291 protected: // Constructors for deriving classes
294 * @brief Function with static linkage
296 typedef void(*Function)(void);
299 * @brief Member function
301 typedef void (CallbackBase::*MemberFunction)( void );
304 * @brief Used to call the correct member function
306 typedef void (*Dispatcher)( CallbackBase& base );
309 * @brief Used to destroy mObjectPointer (null if not mObjectPointer is not owned)
311 typedef void(*Destructor)(void* object);
314 * @brief Copy constructor operator not declared.
316 CallbackBase( const CallbackBase& rhs );
318 * @brief assignment operator not declared.
320 const CallbackBase& operator=( const CallbackBase& rhs );
323 * @brief Constructor for function with static linkage.
325 * @param[in] function The function to call.
327 CallbackBase( Function function );
330 * @brief Constructor for member function.
332 * @param[in] object The object to call (not owned).
333 * @param[in] function The member function of the object.
334 * @param[in] dispatcher Used to call the actual object.
336 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
339 * @brief Constructor for member function.
341 * @param[in] object The object to call (owned).
342 * @param[in] function The member function of the object.
343 * @param dispatcher Used to call the actual object.
344 * @param destructor Used to delete the owned object.
346 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
348 public: // Data for deriving classes & Dispatchers
351 * @brief struct to hold the extra data needed for member functions.
355 Impl(); ///< Default constructor
357 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is null.
358 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
359 Destructor mDestructorDispatcher; ///< Destructor for owned objects. null if mDestructorDispatcher is not owned.
361 Impl* mImpl; ///< Implementation pointer
365 MemberFunction mMemberFunction; ///< Pointer to member function
366 Function mFunction; ///< Static function
371 * @brief Non-member equality operator
373 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
376 * @brief Dispatcher to delete an object.
382 * @brief Dispatcher to delete an object.
384 static void Delete( void* object )
386 // CallbackBase owns the object but we're the only one who knows the real type so need
387 // to delete by "downcasting" from void* to the correct type
388 delete reinterpret_cast< T* >( object );
393 * @brief Dispatcher to call the actual member function.
399 * @brief Call an actual member function.
401 * @param[in] callback The callback information.
403 static void Dispatch( CallbackBase& callback )
405 // "downcast" the object and function type back to the correct ones
406 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
407 typedef void(T::*MemberFunction)(void);
408 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
409 (object->*function)();
414 * @brief Dispatcher to call the actual member function.
416 template< class T, typename P1 >
420 * @brief Call an actual member function.
422 * @param[in] callback The callback information.
423 * @param[in] param1 The first parameter to pass to the real member function.
425 static void Dispatch( CallbackBase& callback, P1 param1 )
427 // "downcast" the object and function type back to the correct ones
428 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
429 typedef void(T::*MemberFunction)(P1);
430 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
431 (object->*function)( param1 );
436 * @brief Dispatcher to call the actual member function.
438 template< class T, typename P1, typename P2 >
442 * @brief Call an actual member function.
444 * @param[in] callback The callback information.
445 * @param[in] param1 The first parameter to pass to the real member function.
446 * @param[in] param2 The second parameter to pass to the real member function.
448 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
450 // "downcast" the object and function type back to the correct ones
451 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
452 typedef void(T::*MemberFunction)(P1, P2);
453 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
454 (object->*function)( param1, param2 );
459 * @brief Dispatcher to call the actual member function.
461 template< class T, typename P1, typename P2, typename P3 >
465 * @brief Call an actual member function.
467 * @param[in] callback The callback information.
468 * @param[in] param1 The first parameter to pass to the real member function.
469 * @param[in] param2 The second parameter to pass to the real member function.
470 * @param[in] param3 The third parameter to pass to the real member function.
472 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
474 // "downcast" the object and function type back to the correct ones
475 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
476 typedef void(T::*MemberFunction)(P1, P2, P3);
477 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
478 (object->*function)( param1, param2, param3 );
483 * @brief Dispatcher to call the actual member function.
485 template< class T, typename R >
486 struct DispatcherReturn0
489 * @brief Call an actual member function.
491 * @param[in] callback The callback information.
494 static R Dispatch( CallbackBase& callback )
496 // "downcast" the object and function type back to the correct ones
497 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
498 typedef R(T::*MemberFunction)(void);
499 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
500 return (object->*function)();
505 * @brief Dispatcher to call the actual member function.
507 template< class T, typename R, typename P1 >
508 struct DispatcherReturn1
511 * @brief Call an actual member function.
513 * @param[in] callback The callback information.
514 * @param[in] param1 The first parameter to pass to the real member function.
515 * @return The return value from the function
517 static R Dispatch( CallbackBase& callback, P1 param1 )
519 // "downcast" the object and function type back to the correct ones
520 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
521 typedef R(T::*MemberFunction)(P1);
522 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
523 return (object->*function)( param1 );
528 * @brief Dispatcher to call the actual member function.
530 template< class T, typename R, typename P1, typename P2 >
531 struct DispatcherReturn2
534 * @brief Call an actual member function.
536 * @param[in] callback The callback information.
537 * @param[in] param1 The first parameter to pass to the real member function.
538 * @param[in] param2 The second parameter to pass to the real member function.
539 * @return The return value from the function
541 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
543 // "downcast" the object and function type back to the correct ones
544 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
545 typedef R(T::*MemberFunction)(P1, P2);
546 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
547 return (object->*function)( param1, param2 );
552 * @brief Dispatcher to call the actual member function.
554 template< class T, typename R, typename P1, typename P2, typename P3 >
555 struct DispatcherReturn3
558 * @brief Call an actual member function.
560 * @param[in] callback The callback information.
561 * @param[in] param1 The first parameter to pass to the real member function.
562 * @param[in] param2 The second parameter to pass to the real member function.
563 * @param[in] param3 The third parameter to pass to the real member function.
564 * @return The return value from the function
566 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
568 // "downcast" the object and function type back to the correct ones
569 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
570 typedef R(T::*MemberFunction)(P1, P2, P3);
571 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
572 return (object->*function)( param1, param2, param3 );
577 * @brief Dispatcher to call a functor.
580 struct FunctorDispatcher0
583 * @brief Call a function object.
585 * @param[in] callback The callback information.
587 static void Dispatch( CallbackBase& callback )
589 // "downcast" the object and function type back to the correct ones
590 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
596 * @brief Dispatcher to call a functor.
598 template< class T, typename P1 >
599 struct FunctorDispatcher1
602 * @brief Call a function object.
604 * @param[in] callback The callback information.
605 * @param[in] param1 The first parameter to pass to the real member function.
607 static void Dispatch( CallbackBase& callback, P1 param1 )
609 // "downcast" the object and function type back to the correct ones
610 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
616 * @brief Dispatcher to call a functor.
618 template< class T, typename P1, typename P2 >
619 struct FunctorDispatcher2
622 * @brief Call a function object.
624 * @param[in] callback The callback information.
625 * @param[in] param1 The first parameter to pass to the real member function.
626 * @param[in] param2 The second parameter to pass to the real member function.
628 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
630 // "downcast" the object and function type back to the correct ones
631 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
632 (*object)( param1, param2 );
637 * @brief Dispatcher to call a functor.
639 template< class T, typename P1, typename P2, typename P3 >
640 struct FunctorDispatcher3
643 * @brief Call a function object.
645 * @param[in] callback The callback information.
646 * @param[in] param1 The first parameter to pass to the real member function.
647 * @param[in] param2 The second parameter to pass to the real member function.
648 * @param[in] param3 The third parameter to pass to the real member function.
650 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
652 // "downcast" the object and function type back to the correct ones
653 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
654 (*object)( param1, param2, param3 );
659 * @brief Dispatcher to call a functor.
661 template< class T, typename R >
662 struct FunctorDispatcherReturn0
665 * @brief Call a function object.
667 * @param[in] callback The callback information.
670 static R Dispatch( CallbackBase& callback )
672 // "downcast" the object and function type back to the correct ones
673 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
679 * @brief Dispatcher to call a functor.
681 template< class T, typename R, typename P1 >
682 struct FunctorDispatcherReturn1
685 * @brief Call a function object.
687 * @param[in] callback The callback information.
688 * @param[in] param1 The first parameter to pass to the real member function.
689 * @return The return value from the function
691 static R Dispatch( CallbackBase& callback, P1 param1 )
693 // "downcast" the object and function type back to the correct ones
694 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
695 return (*object)( param1 );
700 * @brief Dispatcher to call a functor.
702 template< class T, typename R, typename P1, typename P2 >
703 struct FunctorDispatcherReturn2
706 * @brief Call a function object.
708 * @param[in] callback The callback information.
709 * @param[in] param1 The first parameter to pass to the real member function.
710 * @param[in] param2 The second parameter to pass to the real member function.
711 * @return The return value from the function
713 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
715 // "downcast" the object and function type back to the correct ones
716 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
717 return (*object)( param1, param2 );
722 * @brief Dispatcher to call a functor.
724 template< class T, typename R, typename P1, typename P2, typename P3 >
725 struct FunctorDispatcherReturn3
728 * @brief Call a function object.
730 * @param[in] callback The callback information.
731 * @param[in] param1 The first parameter to pass to the real member function.
732 * @param[in] param2 The second parameter to pass to the real member function.
733 * @param[in] param3 The third parameter to pass to the real member function.
734 * @return The return value from the function
736 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
738 // "downcast" the object and function type back to the correct ones
739 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
740 return (*object)( param1, param2, param3 );
745 * @brief Dispatcher to call a functor.
746 * This variant calls a specific void() member function.
749 struct VoidFunctorDispatcher0
752 * @brief Call a function object.
754 * @param[in] callback The callback information.
756 static void Dispatch( CallbackBase& callback )
758 // "downcast" the object and function type back to the correct ones
759 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
760 typedef void(T::*MemberFunction)(void);
761 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
762 (object->*function)();
767 * @brief Dispatcher to call a functor.
769 * This variant calls a void() member, ignoring any signal parameters
771 template< class T, typename P1 >
772 struct VoidFunctorDispatcher1
775 * @brief Call a function object.
777 * @param[in] callback The callback information.
778 * @param[in] param1 The first parameter to pass to the real member function.
780 static void Dispatch( CallbackBase& callback, P1 param1 )
782 // "downcast" the object and function type back to the correct ones
783 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
784 typedef void(T::*MemberFunction)(void);
785 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
786 (object->*function)(/*ignore params*/);
791 * @brief Dispatcher to call a functor.
793 * This variant calls a void() member, ignoring any signal parameters
795 template< class T, typename P1, typename P2 >
796 struct VoidFunctorDispatcher2
799 * @brief Call a function object.
801 * @param[in] callback The callback information.
802 * @param[in] param1 The first parameter to pass to the real member function.
803 * @param[in] param2 The second parameter to pass to the real member function.
805 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
807 // "downcast" the object and function type back to the correct ones
808 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
809 typedef void(T::*MemberFunction)(void);
810 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
811 (object->*function)(/*ignore params*/);
816 * @brief Dispatcher to call a functor.
818 * This variant calls a void() member, ignoring any signal parameters
820 template< class T, typename P1, typename P2, typename P3 >
821 struct VoidFunctorDispatcher3
824 * @brief Call a function object.
826 * @param[in] callback The callback information.
827 * @param[in] param1 The first parameter to pass to the real member function.
828 * @param[in] param2 The second parameter to pass to the real member function.
829 * @param[in] param3 The third parameter to pass to the real member function.
831 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
833 // "downcast" the object and function type back to the correct ones
834 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
835 typedef void(T::*MemberFunction)(void);
836 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
837 (object->*function)(/*ignore params*/);
842 * @brief Dispatcher to call a functor.
844 * This variant calls a void() member, and returns a default-constructed value
846 template< class T, typename R >
847 struct VoidFunctorDispatcherReturn0
850 * @brief Call a function object.
852 * @param[in] callback The callback information.
855 static R Dispatch( CallbackBase& callback )
857 // "downcast" the object and function type back to the correct ones
858 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
859 typedef void(T::*MemberFunction)(void);
860 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
861 (object->*function)(/*ignore params*/);
867 * @brief Dispatcher to call a functor.
869 * This variant calls a void() member, and returns a default-constructed value
871 template< class T, typename R, typename P1 >
872 struct VoidFunctorDispatcherReturn1
875 * @brief Call a function object.
877 * @param[in] callback The callback information.
878 * @param[in] param1 The first parameter to pass to the real member function.
879 * @return The return value from the function
881 static R Dispatch( CallbackBase& callback, P1 param1 )
883 // "downcast" the object and function type back to the correct ones
884 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
885 typedef void(T::*MemberFunction)(void);
886 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
887 (object->*function)(/*ignore params*/);
893 * @brief Dispatcher to call a functor.
895 * This variant calls a void() member, and returns a default-constructed value
897 template< class T, typename R, typename P1, typename P2 >
898 struct VoidFunctorDispatcherReturn2
901 * @brief Call a function object.
903 * @param[in] callback The callback information.
904 * @param[in] param1 The first parameter to pass to the real member function.
905 * @param[in] param2 The second parameter to pass to the real member function.
906 * @return The return value from the function
908 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
910 // "downcast" the object and function type back to the correct ones
911 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
912 typedef void(T::*MemberFunction)(void);
913 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
914 (object->*function)(/*ignore params*/);
920 * @brief Dispatcher to call a functor.
922 * This variant calls a void() member, and returns a default-constructed value
924 template< class T, typename R, typename P1, typename P2, typename P3 >
925 struct VoidFunctorDispatcherReturn3
928 * @brief Call a function object.
930 * @param[in] callback The callback information.
931 * @param[in] param1 The first parameter to pass to the real member function.
932 * @param[in] param2 The second parameter to pass to the real member function.
933 * @param[in] param3 The third parameter to pass to the real member function.
934 * @return The return value from the function
936 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
938 // "downcast" the object and function type back to the correct ones
939 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
940 typedef void(T::*MemberFunction)(void);
941 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
942 (object->*function)(/*ignore params*/);
948 * @brief Thin template to provide type safety for member function callbacks.
950 * version with two parameters and return value
953 class Callback : public CallbackBase
958 * @brief Default constructor.
967 * @brief Constructor for member function.
969 * Copies the function object.
970 * @param[in] object The object to call.
971 * @param[in] memberFunction The member function of the object.
973 Callback( T* object, void(T::*memberFunction)(void) )
974 : CallbackBase( object,
975 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
976 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
977 template< typename P1 >
978 Callback( T* object, void(T::*memberFunction)(P1) )
979 : CallbackBase( object,
980 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
981 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
982 template< typename P1, typename P2 >
983 Callback( T* object, void(T::*memberFunction)(P1, P2) )
984 : CallbackBase( object,
985 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
986 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
987 template< typename P1, typename P2, typename P3 >
988 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
989 : CallbackBase( object,
990 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
991 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
992 template< typename R >
993 Callback( T* object, R(T::*memberFunction)(void) )
994 : CallbackBase( object,
995 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
996 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
997 template< typename R, typename P1 >
998 Callback( T* object, R(T::*memberFunction)(P1) )
999 : CallbackBase( object,
1000 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1001 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1002 template< typename R, typename P1, typename P2 >
1003 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1004 : CallbackBase( object,
1005 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1006 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1007 template< typename R, typename P1, typename P2, typename P3 >
1008 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1009 : CallbackBase( object,
1010 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1011 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1016 * @brief Specializations for static function callbacks.
1018 class CallbackFunction : public CallbackBase
1023 * @brief Default constructor.
1031 * @brief Constructors for functions with static linkage.
1033 * @param[in] function The function to call.
1035 CallbackFunction( void(*function)() )
1036 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1038 template< typename R >
1039 CallbackFunction( R(*function)() )
1040 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1042 template< typename P1 >
1043 CallbackFunction( void(*function)(P1) )
1044 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1046 template< typename P1, typename R >
1047 CallbackFunction( R(*function)(P1) )
1048 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1050 template< typename P1, typename P2 >
1051 CallbackFunction( void(*function)(P1,P2) )
1052 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1054 template< typename P1, typename P2, typename R >
1055 CallbackFunction( R(*function)(P1,P2) )
1056 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1058 template< typename P1, typename P2, typename P3 >
1059 CallbackFunction( void(*function)(P1,P2,P3) )
1060 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1062 template< typename P1, typename P2, typename P3, typename R >
1063 CallbackFunction( R(*function)(P1,P2,P3) )
1064 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1070 * @brief Specializations for function object callbacks.
1073 class CallbackFunctor0 : public CallbackBase
1078 * @brief Constructor which copies a function object.
1080 * @param[in] object The object to copy.
1082 CallbackFunctor0( const T& object )
1083 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1084 0, // uses operator() instead of member function
1085 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1086 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1090 * @brief Function object callback for connecting void() methods
1092 class CallbackFunctorDelegate0 : public CallbackBase
1097 * @brief Constructor which copies a function object.
1099 * This variant calls a void() member, ignoring any signal parameters.
1100 * @param[in] object A newly allocated object (ownership is transferred).
1102 CallbackFunctorDelegate0( FunctorDelegate* object )
1103 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1104 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1105 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1106 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1110 * @brief Function object callback for matching callbacks to signal signature.
1112 template< class T, typename P1 >
1113 class CallbackFunctor1 : public CallbackBase
1118 * @brief Constructor which copies a function object.
1120 * @param[in] object The object to copy.
1122 CallbackFunctor1( const T& object )
1123 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1124 0, // uses operator() instead of member function
1125 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1126 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1130 * @brief Function object callback for connecting void() methods.
1132 template< typename P1 >
1133 class CallbackFunctorDelegate1 : public CallbackBase
1138 * @brief Constructor which copies a function object.
1140 * This variant calls a void() member, ignoring any signal parameters.
1141 * @param[in] object The object to copy.
1143 CallbackFunctorDelegate1( FunctorDelegate* object )
1144 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1145 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1146 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1147 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1151 * @brief Function object callback for matching callbacks to signal signature
1153 template< class T, typename P1, typename P2 >
1154 class CallbackFunctor2 : public CallbackBase
1159 * @brief Constructor which copies a function object.
1161 * @param[in] object The object to copy.
1163 CallbackFunctor2( const T& object )
1164 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1165 0, // uses operator() instead of member function
1166 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1167 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1171 * @brief Function object callback for connecting void() methods
1173 template< typename P1, typename P2 >
1174 class CallbackFunctorDelegate2 : public CallbackBase
1179 * @brief Constructor which copies a function object.
1181 * This variant calls a void() member, ignoring any signal parameters.
1182 * @param[in] object The object to copy.
1184 CallbackFunctorDelegate2( FunctorDelegate* object )
1185 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1186 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1187 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1188 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1192 * @brief Function object callback for matching callbacks to signal signature
1194 template< class T, typename P1, typename P2, typename P3 >
1195 class CallbackFunctor3 : public CallbackBase
1200 * @brief Constructor which copies a function object.
1202 * @param[in] object The object to copy.
1204 CallbackFunctor3( const T& object )
1205 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1206 0, // uses operator() instead of member function
1207 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1208 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1212 * @brief Function object callback for connecting void() methods
1214 template< typename P1, typename P2, typename P3 >
1215 class CallbackFunctorDelegate3 : public CallbackBase
1221 * @brief Constructor which copies a function object.
1223 * This variant calls a void() member, ignoring any signal parameters.
1224 * @param[in] object The object to copy.
1226 CallbackFunctorDelegate3( FunctorDelegate* object )
1227 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1228 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1229 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1230 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1234 * @brief Function object callback for matching callbacks to signal signature
1236 template< class T, typename R >
1237 class CallbackFunctorReturn0 : public CallbackBase
1242 * @brief Constructor which copies a function object.
1244 * @param[in] object The object to copy.
1246 CallbackFunctorReturn0( const T& object )
1247 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1248 0, // uses operator() instead of member function
1249 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1250 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1254 * @brief Function object callback for connecting void() methods
1256 template< typename R >
1257 class CallbackFunctorDelegateReturn0 : public CallbackBase
1262 * @brief Constructor which copies a function object.
1264 * This variant calls a void() member, ignoring any signal parameters.
1265 * @param[in] object The object to copy.
1267 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1268 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1269 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1270 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1271 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1275 * @brief Function object callback for matching callbacks to signal signature
1277 template< class T, typename P1, typename R >
1278 class CallbackFunctorReturn1 : public CallbackBase
1283 * @brief Constructor which copies a function object.
1285 * @param[in] object The object to copy.
1287 CallbackFunctorReturn1( const T& object )
1288 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1289 0, // uses operator() instead of member function
1290 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1291 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1295 * @brief Function object callback for connecting void() methods
1297 template< typename P1, typename R >
1298 class CallbackFunctorDelegateReturn1 : public CallbackBase
1303 * @brief Constructor which copies a function object.
1305 * This variant calls a void() member, ignoring any signal parameters.
1306 * @param[in] object The object to copy.
1308 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1309 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1310 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1311 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1312 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1316 * @brief Function object callback for matching callbacks to signal signature
1318 template< class T, typename P1, typename P2, typename R >
1319 class CallbackFunctorReturn2 : public CallbackBase
1324 * @brief Constructor which copies a function object.
1326 * @param[in] object The object to copy.
1328 CallbackFunctorReturn2( const T& object )
1329 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1330 0, // uses operator() instead of member function
1331 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1332 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1336 * @brief Function object callback for connecting void() methods
1338 template< typename P1, typename P2, typename R >
1339 class CallbackFunctorDelegateReturn2 : public CallbackBase
1344 * @brief Constructor which copies a function object.
1346 * This variant calls a void() member, ignoring any signal parameters.
1347 * @param[in] object The object to copy.
1349 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1350 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1351 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1352 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1353 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1357 * @brief Function object callback for matching callbacks to signal signature
1359 template< class T, typename P1, typename P2, typename P3, typename R >
1360 class CallbackFunctorReturn3 : public CallbackBase
1365 * @brief Constructor which copies a function object.
1367 * @param[in] object The object to copy.
1369 CallbackFunctorReturn3( const T& object )
1370 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1371 0, // uses operator() instead of member function
1372 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1373 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1377 * @brief Function object callback for connecting void() methods
1379 template< typename P1, typename P2, typename P3, typename R >
1380 class CallbackFunctorDelegateReturn3 : public CallbackBase
1385 * @brief Constructor which copies a function object.
1387 * This variant calls a void() member, ignoring any signal parameters.
1388 * @param[in] object The object to copy.
1390 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1391 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1392 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1393 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1394 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1397 // Callback creation thin templates
1400 * @brief Creates a callback from a C function or static member function with no parameters.
1402 * @param[in] function The function to call.
1403 * @return a newly allocated Callback object, ownership transferred to caller
1405 inline CallbackBase* MakeCallback( void(*function)(void) )
1407 return new CallbackFunction( function );
1411 * @brief Creates a callback from a C function or static member function with one parameter.
1413 * @param[in] function The function to call.
1414 * @return a newly allocated Callback object, ownership transferred to caller
1416 template< typename P1 >
1417 inline CallbackBase* MakeCallback( void(*function)(P1) )
1419 return new CallbackFunction( function );
1423 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1425 * @param[in] function The function to call.
1426 * @return a newly allocated Callback object, ownership transferred to caller
1428 template< typename R >
1429 inline CallbackBase* MakeCallback( R(*function)(void) )
1431 return new CallbackFunction( function );
1435 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1437 * @param[in] function The function to call.
1438 * @return a newly allocated Callback object, ownership transferred to caller
1440 template< typename R, typename P1 >
1441 inline CallbackBase* MakeCallback( R(*function)(P1) )
1443 return new CallbackFunction( function );
1447 * @brief Creates a callback from a C function or static member function with two parameters.
1449 * @param[in] function The function to call.
1450 * @return a newly allocated Callback object, ownership transferred to caller
1452 template< typename P1, typename P2 >
1453 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1455 return new CallbackFunction( function );
1459 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1461 * @param[in] function The function to call.
1462 * @return a newly allocated Callback object, ownership transferred to caller
1464 template< typename R, typename P1, typename P2 >
1465 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1467 return new CallbackFunction( function );
1471 * @brief Creates a callback from a C function or static member function with three parameters.
1473 * @param[in] function The function to call.
1474 * @return a newly allocated Callback object, ownership transferred to caller
1476 template< typename P1, typename P2, typename P3 >
1477 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1479 return new CallbackFunction( function );
1483 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1485 * @param[in] function The function to call.
1486 * @return a newly allocated Callback object, ownership transferred to caller
1488 template< typename R, typename P1, typename P2, typename P3 >
1489 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1491 return new CallbackFunction( function );
1495 * @brief Creates a callback from a class member function with no parameters.
1497 * requires the function to be member of the same class
1498 * @param[in] object The object to call.
1499 * @param[in] function The member function to call.
1500 * @return a newly allocated Callback object, ownership transferred to caller
1503 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1505 return new Callback< T >( object, function );
1509 * @brief Creates a callback from a class member function with one parameter.
1511 * requires the function to be member of the same class
1512 * @param[in] object The object to call.
1513 * @param[in] function The member function to call.
1514 * @return a newly allocated Callback object, ownership transferred to caller
1516 template< class T, typename P1 >
1517 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1519 return new Callback< T >( object, function );
1523 * @brief Creates a callback from a class member function with two parameters.
1525 * requires the function to be member of the same class
1526 * @param[in] object The object to call.
1527 * @param[in] function The member function to call.
1528 * @return a newly allocated Callback object, ownership transferred to caller
1530 template< class T, typename P1, typename P2 >
1531 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1533 return new Callback< T >( object, function );
1537 * @brief Creates a callback from a class member function with three parameters.
1539 * requires the function to be member of the same class
1540 * @param[in] object The object to call.
1541 * @param[in] function The member function to call.
1542 * @return a newly allocated Callback object, ownership transferred to caller
1544 template< class T, typename P1, typename P2, typename P3 >
1545 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1547 return new Callback< T >( object, function );
1551 * @brief Creates a callback from a class member function with no parameters and a return type.
1553 * requires the function to be member of the same class
1554 * @param[in] object The object to call.
1555 * @param[in] function The member function to call.
1556 * @return a newly allocated Callback object, ownership transferred to caller
1558 template< class T, typename R >
1559 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1561 return new Callback< T >( object, function );
1565 * @brief Creates a callback from a class member function with one parameter and a return type.
1567 * requires the function to be member of the same class
1568 * @param[in] object The object to call.
1569 * @param[in] function The member function to call.
1570 * @return a newly allocated Callback object, ownership transferred to caller
1572 template< class T, typename P1, typename R >
1573 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1575 return new Callback< T >( object, function );
1579 * @brief Creates a callback from a class member function with two parameters and a return type.
1581 * requires the function to be member of the same class
1582 * @param[in] object The object to call.
1583 * @param[in] function The member function to call.
1584 * @return a newly allocated Callback object, ownership transferred to caller
1586 template< class T, typename P1, typename P2, typename R >
1587 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1589 return new Callback< T >( object, function );
1593 * @brief Creates a callback from a class member function with three parameters and a return type.
1595 * requires the function to be member of the same class
1596 * @param[in] object The object to call.
1597 * @param[in] function The member function to call.
1598 * @return a newly allocated Callback object, ownership transferred to caller
1600 template< class T, typename P1, typename P2, typename P3, typename R >
1601 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1603 return new Callback< T >( object, function );
1607 * @brief Creates a callback from a class's parent member function with no parameters.
1609 * requires the function to be member of the same class
1610 * @param[in] object The object to call.
1611 * @param[in] function The member function to call.
1612 * @return a newly allocated Callback object, ownership transferred to caller
1614 template< class T, class Base >
1615 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1617 return new Callback< T >( object, function );
1620 * @brief Creates a callback from a class's parent member function with no parameters.
1622 * requires the function to be member of the same class
1623 * @param[in] object The object to call.
1624 * @param[in] function The member function to call.
1625 * @return a newly allocated Callback object, ownership transferred to caller
1627 template< class T, class Base >
1628 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1630 return new Callback< T >( object, function );
1635 #endif // __DALI_CALLBACK_H__