1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2015 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.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/functor-delegate.h>
31 * @addtogroup dali-core-signals
38 * @brief Callback base class to hold the data for callback function and member function calls.
40 class DALI_IMPORT_API CallbackBase
45 * @brief Default constructor
55 * @brief Resets the object pointer so that we know not to call methods of this object any more.
60 * @brief Function to call the function or member function dispatcher
62 * @param[in] callback The callback to call.
64 static void Execute( CallbackBase& callback )
66 // if we point to a function, we can call it directly
67 // otherwise call the dispatcher function that knows the real type of the object
68 // Note that this template dispatcher lives in client code so the library containing
69 // the code has to be loaded, otherwise we crash boom bang
70 if( callback.mImpl && callback.mImpl->mObjectPointer )
72 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
73 (*dispatcher)( callback );
75 // its also possible to have a member function pointer to a CallbackProvider
76 // that has been deleted, so check if we have impl still
77 else if( !callback.mImpl && callback.mFunction )
79 (*(callback.mFunction))();
83 DALI_ASSERT_ALWAYS( 0 && "no function to execute" );
88 * @brief Function to call the function or member function dispatcher.
90 * @param[in] callback The callback to call.
91 * @return value from the function
93 template< typename R >
94 static R ExecuteReturn( CallbackBase& callback )
97 // if we point to a function, we can call it directly
98 // otherwise call the dispatcher function that knows the real type of the object
99 // Note that this template dispatcher lives in client code so the library containing
100 // the code has to be loaded, otherwise we crash boom bang
101 if( callback.mImpl && callback.mImpl->mObjectPointer )
103 typedef R(*Dispatcher)(CallbackBase& base);
104 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
105 returnVal = (*dispatcher)( callback );
107 else if( !callback.mImpl && callback.mFunction )
109 typedef R(*Function1)();
110 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
117 * @brief Function to call the function or member function dispatcher.
119 * This function template gets instantiated at the call site
120 * @param[in] callback The callback to call.
121 * @param[in] param1 The first parameter to pass into the function.
123 template< typename P1 >
124 static void Execute( CallbackBase& callback, P1 param1 )
126 // if we point to a function, we can call it directly
127 // otherwise call the dispatcher function that knows the real type of the object
128 // Note that this template dispatcher lives in client code (where the callback was created)
129 // so the library containing the code has to be loaded, otherwise we crash boom bang
130 if( callback.mImpl && callback.mImpl->mObjectPointer )
132 typedef void(*Dispatcher)(CallbackBase& base,P1);
133 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
134 (*dispatcher)( callback, param1 );
136 else if( !callback.mImpl && callback.mFunction )
138 // convert function type
139 typedef void(*Function1)(P1);
140 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
145 * @brief Function to call the function or member function dispatcher.
147 * This function template gets instantiated at the call site
148 * @param[in] callback The callback to call.
149 * @param[in] param1 The first parameter to pass into the function.
150 * @return the value from the function
152 template< typename R, typename P1 >
153 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
156 // if we point to a function, we can call it directly
157 // otherwise call the dispatcher function that knows the real type of the object
158 // Note that this template dispatcher lives in client code (where the callback was created)
159 // so the library containing the code has to be loaded, otherwise we crash boom bang
160 if( callback.mImpl && callback.mImpl->mObjectPointer )
162 typedef R(*Dispatcher)(CallbackBase& base,P1);
163 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
164 returnVal = (*dispatcher)( callback, param1 );
166 else if( !callback.mImpl && callback.mFunction )
168 // convert function type
169 typedef R(*Function1)(P1);
170 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
177 * @brief Function to call the function or member function dispatcher.
179 * This function template gets instantiated at the call site.
180 * @param[in] callback The callback to call.
181 * @param[in] param1 The first parameter to pass into the function.
182 * @param[in] param2 The second parameter to pass into the function.
184 template< typename P1, typename P2 >
185 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
187 // if we point to a function, we can call it directly
188 // otherwise call the dispatcher function that knows the real type of the object
189 // Note that this template dispatcher lives in client code (where the callback was created)
190 // so the library containing the code has to be loaded, otherwise we crash boom bang
191 if( callback.mImpl && callback.mImpl->mObjectPointer )
193 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
194 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
195 (*dispatcher)( callback, param1, param2 );
197 else if( !callback.mImpl && callback.mFunction )
199 // convert function type
200 typedef void(*Function2)(P1,P2);
201 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
206 * @brief Function to call the function or member function dispatcher.
208 * This function template gets instantiated at the call site
209 * @param[in] callback The callback to call.
210 * @param[in] param1 The first parameter to pass into the function.
211 * @param[in] param2 The second parameter to pass into the function.
212 * @return The return value from the function
214 template< typename R, typename P1, typename P2 >
215 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
218 // if we point to a function, we can call it directly
219 // otherwise call the dispatcher function that knows the real type of the object
220 // Note that this template dispatcher lives in client code (where the callback was created)
221 // so the library containing the code has to be loaded, otherwise we crash boom bang
222 if( callback.mImpl && callback.mImpl->mObjectPointer )
224 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
225 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
226 returnVal = (*dispatcher)( callback, param1, param2 );
228 else if( !callback.mImpl && callback.mFunction )
230 // convert function type
231 typedef R(*Function2)(P1,P2);
232 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
239 * @brief Function to call the function or member function dispatcher.
241 * This function template gets instantiated at the call site.
242 * @param[in] callback The callback to call.
243 * @param[in] param1 The first parameter to pass into the function.
244 * @param[in] param2 The second parameter to pass into the function.
245 * @param[in] param3 The third parameter to pass into the function.
247 template< typename P1, typename P2, typename P3 >
248 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
250 // if we point to a function, we can call it directly
251 // otherwise call the dispatcher function that knows the real type of the object
252 // Note that this template dispatcher lives in client code (where the callback was created)
253 // so the library containing the code has to be loaded, otherwise we crash boom bang
254 if( callback.mImpl && callback.mImpl->mObjectPointer )
256 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
257 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
258 (*dispatcher)( callback, param1, param2, param3 );
260 else if( !callback.mImpl && callback.mFunction )
262 // convert function type
263 typedef void(*Function2)(P1,P2,P3);
264 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
269 * @brief Function to call the function or member function dispatcher.
271 * This function template gets instantiated at the call site
272 * @param[in] callback The callback to call.
273 * @param[in] param1 The first parameter to pass into the function.
274 * @param[in] param2 The second parameter to pass into the function.
275 * @param[in] param3 The third parameter to pass into the function.
276 * @return The return value from the function
278 template< typename R, typename P1, typename P2, typename P3 >
279 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
282 // if we point to a function, we can call it directly
283 // otherwise call the dispatcher function that knows the real type of the object
284 // Note that this template dispatcher lives in client code (where the callback was created)
285 // so the library containing the code has to be loaded, otherwise we crash boom bang
286 if( callback.mImpl && callback.mImpl->mObjectPointer )
288 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
289 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
290 returnVal = (*dispatcher)( callback, param1, param2, param3 );
292 else if( !callback.mImpl && callback.mFunction )
294 // convert function type
295 typedef R(*Function2)(P1,P2,P3);
296 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
302 protected: // Constructors for deriving classes
305 * @brief Function with static linkage
307 typedef void(*Function)(void);
310 * @brief Member function
312 typedef void (CallbackBase::*MemberFunction)( void );
315 * @brief Used to call the correct member function
317 typedef void (*Dispatcher)( CallbackBase& base );
320 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned)
322 typedef void(*Destructor)(void* object);
325 * @brief Copy constructor operator not declared.
327 CallbackBase( const CallbackBase& rhs );
329 * @brief assignment operator not declared.
331 const CallbackBase& operator=( const CallbackBase& rhs );
334 * @brief Constructor for function with static linkage.
336 * @param[in] function The function to call.
338 CallbackBase( Function function );
341 * @brief Constructor for member function.
343 * @param[in] object The object to call (not owned).
344 * @param[in] function The member function of the object.
345 * @param[in] dispatcher Used to call the actual object.
347 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
350 * @brief Constructor for member function.
352 * @param[in] object The object to call (owned).
353 * @param[in] function The member function of the object.
354 * @param dispatcher Used to call the actual object.
355 * @param destructor Used to delete the owned object.
357 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
359 public: // Data for deriving classes & Dispatchers
362 * @brief struct to hold the extra data needed for member functions.
366 Impl(); ///< Default constructor
368 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
369 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
370 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
372 Impl* mImpl; ///< Implementation pointer
376 MemberFunction mMemberFunction; ///< Pointer to member function
377 Function mFunction; ///< Static function
382 * @brief Non-member equality operator
384 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
387 * @brief Dispatcher to delete an object.
393 * @brief Dispatcher to delete an object.
395 static void Delete( void* object )
397 // CallbackBase owns the object but we're the only one who knows the real type so need
398 // to delete by "downcasting" from void* to the correct type
399 delete reinterpret_cast< T* >( object );
404 * @brief Dispatcher to call the actual member function.
410 * @brief Call an actual member function.
412 * @param[in] callback The callback information.
414 static void Dispatch( CallbackBase& callback )
416 // "downcast" the object and function type back to the correct ones
417 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
418 typedef void(T::*MemberFunction)(void);
419 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
420 (object->*function)();
425 * @brief Dispatcher to call the actual member function.
427 template< class T, typename P1 >
431 * @brief Call an actual member function.
433 * @param[in] callback The callback information.
434 * @param[in] param1 The first parameter to pass to the real member function.
436 static void Dispatch( CallbackBase& callback, P1 param1 )
438 // "downcast" the object and function type back to the correct ones
439 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
440 typedef void(T::*MemberFunction)(P1);
441 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
442 (object->*function)( param1 );
447 * @brief Dispatcher to call the actual member function.
449 template< class T, typename P1, typename P2 >
453 * @brief Call an actual member function.
455 * @param[in] callback The callback information.
456 * @param[in] param1 The first parameter to pass to the real member function.
457 * @param[in] param2 The second parameter to pass to the real member function.
459 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
461 // "downcast" the object and function type back to the correct ones
462 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
463 typedef void(T::*MemberFunction)(P1, P2);
464 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
465 (object->*function)( param1, param2 );
470 * @brief Dispatcher to call the actual member function.
472 template< class T, typename P1, typename P2, typename P3 >
476 * @brief Call an actual member function.
478 * @param[in] callback The callback information.
479 * @param[in] param1 The first parameter to pass to the real member function.
480 * @param[in] param2 The second parameter to pass to the real member function.
481 * @param[in] param3 The third parameter to pass to the real member function.
483 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
485 // "downcast" the object and function type back to the correct ones
486 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
487 typedef void(T::*MemberFunction)(P1, P2, P3);
488 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
489 (object->*function)( param1, param2, param3 );
494 * @brief Dispatcher to call the actual member function.
496 template< class T, typename R >
497 struct DispatcherReturn0
500 * @brief Call an actual member function.
502 * @param[in] callback The callback information.
505 static R Dispatch( CallbackBase& callback )
507 // "downcast" the object and function type back to the correct ones
508 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
509 typedef R(T::*MemberFunction)(void);
510 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
511 return (object->*function)();
516 * @brief Dispatcher to call the actual member function.
518 template< class T, typename R, typename P1 >
519 struct DispatcherReturn1
522 * @brief Call an actual member function.
524 * @param[in] callback The callback information.
525 * @param[in] param1 The first parameter to pass to the real member function.
526 * @return The return value from the function
528 static R Dispatch( CallbackBase& callback, P1 param1 )
530 // "downcast" the object and function type back to the correct ones
531 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
532 typedef R(T::*MemberFunction)(P1);
533 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
534 return (object->*function)( param1 );
539 * @brief Dispatcher to call the actual member function.
541 template< class T, typename R, typename P1, typename P2 >
542 struct DispatcherReturn2
545 * @brief Call an actual member function.
547 * @param[in] callback The callback information.
548 * @param[in] param1 The first parameter to pass to the real member function.
549 * @param[in] param2 The second parameter to pass to the real member function.
550 * @return The return value from the function
552 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
554 // "downcast" the object and function type back to the correct ones
555 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
556 typedef R(T::*MemberFunction)(P1, P2);
557 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
558 return (object->*function)( param1, param2 );
563 * @brief Dispatcher to call the actual member function.
565 template< class T, typename R, typename P1, typename P2, typename P3 >
566 struct DispatcherReturn3
569 * @brief Call an actual member function.
571 * @param[in] callback The callback information.
572 * @param[in] param1 The first parameter to pass to the real member function.
573 * @param[in] param2 The second parameter to pass to the real member function.
574 * @param[in] param3 The third parameter to pass to the real member function.
575 * @return The return value from the function
577 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
579 // "downcast" the object and function type back to the correct ones
580 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
581 typedef R(T::*MemberFunction)(P1, P2, P3);
582 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
583 return (object->*function)( param1, param2, param3 );
588 * @brief Dispatcher to call a functor.
591 struct FunctorDispatcher0
594 * @brief Call a function object.
596 * @param[in] callback The callback information.
598 static void Dispatch( CallbackBase& callback )
600 // "downcast" the object and function type back to the correct ones
601 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
607 * @brief Dispatcher to call a functor.
609 template< class T, typename P1 >
610 struct FunctorDispatcher1
613 * @brief Call a function object.
615 * @param[in] callback The callback information.
616 * @param[in] param1 The first parameter to pass to the real member function.
618 static void Dispatch( CallbackBase& callback, P1 param1 )
620 // "downcast" the object and function type back to the correct ones
621 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
627 * @brief Dispatcher to call a functor.
629 template< class T, typename P1, typename P2 >
630 struct FunctorDispatcher2
633 * @brief Call a function object.
635 * @param[in] callback The callback information.
636 * @param[in] param1 The first parameter to pass to the real member function.
637 * @param[in] param2 The second parameter to pass to the real member function.
639 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
641 // "downcast" the object and function type back to the correct ones
642 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
643 (*object)( param1, param2 );
648 * @brief Dispatcher to call a functor.
650 template< class T, typename P1, typename P2, typename P3 >
651 struct FunctorDispatcher3
654 * @brief Call a function object.
656 * @param[in] callback The callback information.
657 * @param[in] param1 The first parameter to pass to the real member function.
658 * @param[in] param2 The second parameter to pass to the real member function.
659 * @param[in] param3 The third parameter to pass to the real member function.
661 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
663 // "downcast" the object and function type back to the correct ones
664 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
665 (*object)( param1, param2, param3 );
670 * @brief Dispatcher to call a functor.
672 template< class T, typename R >
673 struct FunctorDispatcherReturn0
676 * @brief Call a function object.
678 * @param[in] callback The callback information.
681 static R Dispatch( CallbackBase& callback )
683 // "downcast" the object and function type back to the correct ones
684 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
690 * @brief Dispatcher to call a functor.
692 template< class T, typename R, typename P1 >
693 struct FunctorDispatcherReturn1
696 * @brief Call a function object.
698 * @param[in] callback The callback information.
699 * @param[in] param1 The first parameter to pass to the real member function.
700 * @return The return value from the function
702 static R Dispatch( CallbackBase& callback, P1 param1 )
704 // "downcast" the object and function type back to the correct ones
705 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
706 return (*object)( param1 );
711 * @brief Dispatcher to call a functor.
713 template< class T, typename R, typename P1, typename P2 >
714 struct FunctorDispatcherReturn2
717 * @brief Call a function object.
719 * @param[in] callback The callback information.
720 * @param[in] param1 The first parameter to pass to the real member function.
721 * @param[in] param2 The second parameter to pass to the real member function.
722 * @return The return value from the function
724 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
726 // "downcast" the object and function type back to the correct ones
727 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
728 return (*object)( param1, param2 );
733 * @brief Dispatcher to call a functor.
735 template< class T, typename R, typename P1, typename P2, typename P3 >
736 struct FunctorDispatcherReturn3
739 * @brief Call a function object.
741 * @param[in] callback The callback information.
742 * @param[in] param1 The first parameter to pass to the real member function.
743 * @param[in] param2 The second parameter to pass to the real member function.
744 * @param[in] param3 The third parameter to pass to the real member function.
745 * @return The return value from the function
747 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
749 // "downcast" the object and function type back to the correct ones
750 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
751 return (*object)( param1, param2, param3 );
756 * @brief Dispatcher to call a functor.
757 * This variant calls a specific void() member function.
760 struct VoidFunctorDispatcher0
763 * @brief Call a function object.
765 * @param[in] callback The callback information.
767 static void Dispatch( CallbackBase& callback )
769 // "downcast" the object and function type back to the correct ones
770 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
771 typedef void(T::*MemberFunction)(void);
772 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
773 (object->*function)();
778 * @brief Dispatcher to call a functor.
780 * This variant calls a void() member, ignoring any signal parameters
782 template< class T, typename P1 >
783 struct VoidFunctorDispatcher1
786 * @brief Call a function object.
788 * @param[in] callback The callback information.
789 * @param[in] param1 The first parameter to pass to the real member function.
791 static void Dispatch( CallbackBase& callback, P1 param1 )
793 // "downcast" the object and function type back to the correct ones
794 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
795 typedef void(T::*MemberFunction)(void);
796 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
797 (object->*function)(/*ignore params*/);
802 * @brief Dispatcher to call a functor.
804 * This variant calls a void() member, ignoring any signal parameters
806 template< class T, typename P1, typename P2 >
807 struct VoidFunctorDispatcher2
810 * @brief Call a function object.
812 * @param[in] callback The callback information.
813 * @param[in] param1 The first parameter to pass to the real member function.
814 * @param[in] param2 The second parameter to pass to the real member function.
816 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
818 // "downcast" the object and function type back to the correct ones
819 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
820 typedef void(T::*MemberFunction)(void);
821 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
822 (object->*function)(/*ignore params*/);
827 * @brief Dispatcher to call a functor.
829 * This variant calls a void() member, ignoring any signal parameters
831 template< class T, typename P1, typename P2, typename P3 >
832 struct VoidFunctorDispatcher3
835 * @brief Call a function object.
837 * @param[in] callback The callback information.
838 * @param[in] param1 The first parameter to pass to the real member function.
839 * @param[in] param2 The second parameter to pass to the real member function.
840 * @param[in] param3 The third parameter to pass to the real member function.
842 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
844 // "downcast" the object and function type back to the correct ones
845 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
846 typedef void(T::*MemberFunction)(void);
847 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
848 (object->*function)(/*ignore params*/);
853 * @brief Dispatcher to call a functor.
855 * This variant calls a void() member, and returns a default-constructed value
857 template< class T, typename R >
858 struct VoidFunctorDispatcherReturn0
861 * @brief Call a function object.
863 * @param[in] callback The callback information.
866 static R Dispatch( CallbackBase& callback )
868 // "downcast" the object and function type back to the correct ones
869 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
870 typedef void(T::*MemberFunction)(void);
871 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
872 (object->*function)(/*ignore params*/);
878 * @brief Dispatcher to call a functor.
880 * This variant calls a void() member, and returns a default-constructed value
882 template< class T, typename R, typename P1 >
883 struct VoidFunctorDispatcherReturn1
886 * @brief Call a function object.
888 * @param[in] callback The callback information.
889 * @param[in] param1 The first parameter to pass to the real member function.
890 * @return The return value from the function
892 static R Dispatch( CallbackBase& callback, P1 param1 )
894 // "downcast" the object and function type back to the correct ones
895 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
896 typedef void(T::*MemberFunction)(void);
897 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
898 (object->*function)(/*ignore params*/);
904 * @brief Dispatcher to call a functor.
906 * This variant calls a void() member, and returns a default-constructed value
908 template< class T, typename R, typename P1, typename P2 >
909 struct VoidFunctorDispatcherReturn2
912 * @brief Call a function object.
914 * @param[in] callback The callback information.
915 * @param[in] param1 The first parameter to pass to the real member function.
916 * @param[in] param2 The second parameter to pass to the real member function.
917 * @return The return value from the function
919 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
921 // "downcast" the object and function type back to the correct ones
922 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
923 typedef void(T::*MemberFunction)(void);
924 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
925 (object->*function)(/*ignore params*/);
931 * @brief Dispatcher to call a functor.
933 * This variant calls a void() member, and returns a default-constructed value
935 template< class T, typename R, typename P1, typename P2, typename P3 >
936 struct VoidFunctorDispatcherReturn3
939 * @brief Call a function object.
941 * @param[in] callback The callback information.
942 * @param[in] param1 The first parameter to pass to the real member function.
943 * @param[in] param2 The second parameter to pass to the real member function.
944 * @param[in] param3 The third parameter to pass to the real member function.
945 * @return The return value from the function
947 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
949 // "downcast" the object and function type back to the correct ones
950 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
951 typedef void(T::*MemberFunction)(void);
952 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
953 (object->*function)(/*ignore params*/);
959 * @brief Thin template to provide type safety for member function callbacks.
961 * version with two parameters and return value
964 class Callback : public CallbackBase
969 * @brief Default constructor.
978 * @brief Constructor for member function.
980 * Copies the function object.
981 * @param[in] object The object to call.
982 * @param[in] memberFunction The member function of the object.
984 Callback( T* object, void(T::*memberFunction)(void) )
985 : CallbackBase( object,
986 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
987 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
988 template< typename P1 >
989 Callback( T* object, void(T::*memberFunction)(P1) )
990 : CallbackBase( object,
991 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
992 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
993 template< typename P1, typename P2 >
994 Callback( T* object, void(T::*memberFunction)(P1, P2) )
995 : CallbackBase( object,
996 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
997 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
998 template< typename P1, typename P2, typename P3 >
999 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
1000 : CallbackBase( object,
1001 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1002 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
1003 template< typename R >
1004 Callback( T* object, R(T::*memberFunction)(void) )
1005 : CallbackBase( object,
1006 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1007 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1008 template< typename R, typename P1 >
1009 Callback( T* object, R(T::*memberFunction)(P1) )
1010 : CallbackBase( object,
1011 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1012 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1013 template< typename R, typename P1, typename P2 >
1014 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1015 : CallbackBase( object,
1016 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1017 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1018 template< typename R, typename P1, typename P2, typename P3 >
1019 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1020 : CallbackBase( object,
1021 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1022 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1027 * @brief Specializations for static function callbacks.
1029 class CallbackFunction : public CallbackBase
1034 * @brief Default constructor.
1042 * @brief Constructors for functions with static linkage.
1044 * @param[in] function The function to call.
1046 CallbackFunction( void(*function)() )
1047 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1049 template< typename R >
1050 CallbackFunction( R(*function)() )
1051 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1053 template< typename P1 >
1054 CallbackFunction( void(*function)(P1) )
1055 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1057 template< typename P1, typename R >
1058 CallbackFunction( R(*function)(P1) )
1059 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1061 template< typename P1, typename P2 >
1062 CallbackFunction( void(*function)(P1,P2) )
1063 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1065 template< typename P1, typename P2, typename R >
1066 CallbackFunction( R(*function)(P1,P2) )
1067 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1069 template< typename P1, typename P2, typename P3 >
1070 CallbackFunction( void(*function)(P1,P2,P3) )
1071 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1073 template< typename P1, typename P2, typename P3, typename R >
1074 CallbackFunction( R(*function)(P1,P2,P3) )
1075 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1081 * @brief Specializations for function object callbacks.
1084 class CallbackFunctor0 : public CallbackBase
1089 * @brief Constructor which copies a function object.
1091 * @param[in] object The object to copy.
1093 CallbackFunctor0( const T& object )
1094 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1095 NULL, // uses operator() instead of member function
1096 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1097 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1101 * @brief Function object callback for connecting void() methods
1103 class CallbackFunctorDelegate0 : public CallbackBase
1108 * @brief Constructor which copies a function object.
1110 * This variant calls a void() member, ignoring any signal parameters.
1111 * @param[in] object A newly allocated object (ownership is transferred).
1113 CallbackFunctorDelegate0( FunctorDelegate* object )
1114 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1115 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1116 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1117 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1121 * @brief Function object callback for matching callbacks to signal signature.
1123 template< class T, typename P1 >
1124 class CallbackFunctor1 : public CallbackBase
1129 * @brief Constructor which copies a function object.
1131 * @param[in] object The object to copy.
1133 CallbackFunctor1( const T& object )
1134 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1135 NULL, // uses operator() instead of member function
1136 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1137 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1141 * @brief Function object callback for connecting void() methods.
1143 template< typename P1 >
1144 class CallbackFunctorDelegate1 : public CallbackBase
1149 * @brief Constructor which copies a function object.
1151 * This variant calls a void() member, ignoring any signal parameters.
1152 * @param[in] object The object to copy.
1154 CallbackFunctorDelegate1( FunctorDelegate* object )
1155 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1156 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1157 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1158 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1162 * @brief Function object callback for matching callbacks to signal signature
1164 template< class T, typename P1, typename P2 >
1165 class CallbackFunctor2 : public CallbackBase
1170 * @brief Constructor which copies a function object.
1172 * @param[in] object The object to copy.
1174 CallbackFunctor2( const T& object )
1175 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1176 NULL, // uses operator() instead of member function
1177 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1178 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1182 * @brief Function object callback for connecting void() methods
1184 template< typename P1, typename P2 >
1185 class CallbackFunctorDelegate2 : public CallbackBase
1190 * @brief Constructor which copies a function object.
1192 * This variant calls a void() member, ignoring any signal parameters.
1193 * @param[in] object The object to copy.
1195 CallbackFunctorDelegate2( FunctorDelegate* object )
1196 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1197 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1198 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1199 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1203 * @brief Function object callback for matching callbacks to signal signature
1205 template< class T, typename P1, typename P2, typename P3 >
1206 class CallbackFunctor3 : public CallbackBase
1211 * @brief Constructor which copies a function object.
1213 * @param[in] object The object to copy.
1215 CallbackFunctor3( const T& object )
1216 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1217 NULL, // uses operator() instead of member function
1218 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1219 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1223 * @brief Function object callback for connecting void() methods
1225 template< typename P1, typename P2, typename P3 >
1226 class CallbackFunctorDelegate3 : public CallbackBase
1232 * @brief Constructor which copies a function object.
1234 * This variant calls a void() member, ignoring any signal parameters.
1235 * @param[in] object The object to copy.
1237 CallbackFunctorDelegate3( FunctorDelegate* object )
1238 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1239 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1240 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1241 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1245 * @brief Function object callback for matching callbacks to signal signature
1247 template< class T, typename R >
1248 class CallbackFunctorReturn0 : public CallbackBase
1253 * @brief Constructor which copies a function object.
1255 * @param[in] object The object to copy.
1257 CallbackFunctorReturn0( const T& object )
1258 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1259 NULL, // uses operator() instead of member function
1260 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1261 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1265 * @brief Function object callback for connecting void() methods
1267 template< typename R >
1268 class CallbackFunctorDelegateReturn0 : public CallbackBase
1273 * @brief Constructor which copies a function object.
1275 * This variant calls a void() member, ignoring any signal parameters.
1276 * @param[in] object The object to copy.
1278 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1279 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1280 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1281 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1282 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1286 * @brief Function object callback for matching callbacks to signal signature
1288 template< class T, typename P1, typename R >
1289 class CallbackFunctorReturn1 : public CallbackBase
1294 * @brief Constructor which copies a function object.
1296 * @param[in] object The object to copy.
1298 CallbackFunctorReturn1( const T& object )
1299 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1300 NULL, // uses operator() instead of member function
1301 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1302 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1306 * @brief Function object callback for connecting void() methods
1308 template< typename P1, typename R >
1309 class CallbackFunctorDelegateReturn1 : public CallbackBase
1314 * @brief Constructor which copies a function object.
1316 * This variant calls a void() member, ignoring any signal parameters.
1317 * @param[in] object The object to copy.
1319 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1320 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1321 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1322 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1323 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1327 * @brief Function object callback for matching callbacks to signal signature
1329 template< class T, typename P1, typename P2, typename R >
1330 class CallbackFunctorReturn2 : public CallbackBase
1335 * @brief Constructor which copies a function object.
1337 * @param[in] object The object to copy.
1339 CallbackFunctorReturn2( const T& object )
1340 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1341 NULL, // uses operator() instead of member function
1342 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1343 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1347 * @brief Function object callback for connecting void() methods
1349 template< typename P1, typename P2, typename R >
1350 class CallbackFunctorDelegateReturn2 : public CallbackBase
1355 * @brief Constructor which copies a function object.
1357 * This variant calls a void() member, ignoring any signal parameters.
1358 * @param[in] object The object to copy.
1360 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1361 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1362 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1363 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1364 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1368 * @brief Function object callback for matching callbacks to signal signature
1370 template< class T, typename P1, typename P2, typename P3, typename R >
1371 class CallbackFunctorReturn3 : public CallbackBase
1376 * @brief Constructor which copies a function object.
1378 * @param[in] object The object to copy.
1380 CallbackFunctorReturn3( const T& object )
1381 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1382 NULL, // uses operator() instead of member function
1383 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1384 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1388 * @brief Function object callback for connecting void() methods
1390 template< typename P1, typename P2, typename P3, typename R >
1391 class CallbackFunctorDelegateReturn3 : public CallbackBase
1396 * @brief Constructor which copies a function object.
1398 * This variant calls a void() member, ignoring any signal parameters.
1399 * @param[in] object The object to copy.
1401 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1402 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1403 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1404 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1405 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1408 // Callback creation thin templates
1411 * @brief Creates a callback from a C function or static member function with no parameters.
1413 * @param[in] function The function to call.
1414 * @return a newly allocated Callback object, ownership transferred to caller
1416 inline CallbackBase* MakeCallback( void(*function)(void) )
1418 return new CallbackFunction( function );
1422 * @brief Creates a callback from a C function or static member function with one parameter.
1424 * @param[in] function The function to call.
1425 * @return a newly allocated Callback object, ownership transferred to caller
1427 template< typename P1 >
1428 inline CallbackBase* MakeCallback( void(*function)(P1) )
1430 return new CallbackFunction( function );
1434 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1436 * @param[in] function The function to call.
1437 * @return a newly allocated Callback object, ownership transferred to caller
1439 template< typename R >
1440 inline CallbackBase* MakeCallback( R(*function)(void) )
1442 return new CallbackFunction( function );
1446 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1448 * @param[in] function The function to call.
1449 * @return a newly allocated Callback object, ownership transferred to caller
1451 template< typename R, typename P1 >
1452 inline CallbackBase* MakeCallback( R(*function)(P1) )
1454 return new CallbackFunction( function );
1458 * @brief Creates a callback from a C function or static member function with two parameters.
1460 * @param[in] function The function to call.
1461 * @return a newly allocated Callback object, ownership transferred to caller
1463 template< typename P1, typename P2 >
1464 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1466 return new CallbackFunction( function );
1470 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1472 * @param[in] function The function to call.
1473 * @return a newly allocated Callback object, ownership transferred to caller
1475 template< typename R, typename P1, typename P2 >
1476 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1478 return new CallbackFunction( function );
1482 * @brief Creates a callback from a C function or static member function with three parameters.
1484 * @param[in] function The function to call.
1485 * @return a newly allocated Callback object, ownership transferred to caller
1487 template< typename P1, typename P2, typename P3 >
1488 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1490 return new CallbackFunction( function );
1494 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1496 * @param[in] function The function to call.
1497 * @return a newly allocated Callback object, ownership transferred to caller
1499 template< typename R, typename P1, typename P2, typename P3 >
1500 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1502 return new CallbackFunction( function );
1506 * @brief Creates a callback from a class member function with no parameters.
1508 * requires the function to be member of the same class
1509 * @param[in] object The object to call.
1510 * @param[in] function The member function to call.
1511 * @return a newly allocated Callback object, ownership transferred to caller
1514 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1516 return new Callback< T >( object, function );
1520 * @brief Creates a callback from a class member function with one parameter.
1522 * requires the function to be member of the same class
1523 * @param[in] object The object to call.
1524 * @param[in] function The member function to call.
1525 * @return a newly allocated Callback object, ownership transferred to caller
1527 template< class T, typename P1 >
1528 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1530 return new Callback< T >( object, function );
1534 * @brief Creates a callback from a class member function with two parameters.
1536 * requires the function to be member of the same class
1537 * @param[in] object The object to call.
1538 * @param[in] function The member function to call.
1539 * @return a newly allocated Callback object, ownership transferred to caller
1541 template< class T, typename P1, typename P2 >
1542 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1544 return new Callback< T >( object, function );
1548 * @brief Creates a callback from a class member function with three parameters.
1550 * requires the function to be member of the same class
1551 * @param[in] object The object to call.
1552 * @param[in] function The member function to call.
1553 * @return a newly allocated Callback object, ownership transferred to caller
1555 template< class T, typename P1, typename P2, typename P3 >
1556 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1558 return new Callback< T >( object, function );
1562 * @brief Creates a callback from a class member function with no parameters and a return type.
1564 * requires the function to be member of the same class
1565 * @param[in] object The object to call.
1566 * @param[in] function The member function to call.
1567 * @return a newly allocated Callback object, ownership transferred to caller
1569 template< class T, typename R >
1570 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1572 return new Callback< T >( object, function );
1576 * @brief Creates a callback from a class member function with one parameter and a return type.
1578 * requires the function to be member of the same class
1579 * @param[in] object The object to call.
1580 * @param[in] function The member function to call.
1581 * @return a newly allocated Callback object, ownership transferred to caller
1583 template< class T, typename P1, typename R >
1584 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1586 return new Callback< T >( object, function );
1590 * @brief Creates a callback from a class member function with two parameters and a return type.
1592 * requires the function to be member of the same class
1593 * @param[in] object The object to call.
1594 * @param[in] function The member function to call.
1595 * @return a newly allocated Callback object, ownership transferred to caller
1597 template< class T, typename P1, typename P2, typename R >
1598 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1600 return new Callback< T >( object, function );
1604 * @brief Creates a callback from a class member function with three parameters and a return type.
1606 * requires the function to be member of the same class
1607 * @param[in] object The object to call.
1608 * @param[in] function The member function to call.
1609 * @return a newly allocated Callback object, ownership transferred to caller
1611 template< class T, typename P1, typename P2, typename P3, typename R >
1612 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1614 return new Callback< T >( object, function );
1618 * @brief Creates a callback from a class's parent member function with no parameters.
1620 * requires the function to be member of the same class
1621 * @param[in] object The object to call.
1622 * @param[in] function The member function to call.
1623 * @return a newly allocated Callback object, ownership transferred to caller
1625 template< class T, class Base >
1626 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1628 return new Callback< T >( object, function );
1631 * @brief Creates a callback from a class's parent member function with no parameters.
1633 * requires the function to be member of the same class
1634 * @param[in] object The object to call.
1635 * @param[in] function The member function to call.
1636 * @return a newly allocated Callback object, ownership transferred to caller
1638 template< class T, class Base >
1639 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1641 return new Callback< T >( object, function );
1649 #endif // __DALI_CALLBACK_H__