1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2018 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.
41 class DALI_CORE_API CallbackBase
46 * @brief Default constructor.
58 * @brief Resets the object pointer so that we know not to call methods of this object any more.
64 * @brief Function to call the function or member function dispatcher.
67 * @param[in] callback The callback to call
69 static void Execute( CallbackBase& callback )
71 // if we point to a function, we can call it directly
72 // otherwise call the dispatcher function that knows the real type of the object
73 // Note that this template dispatcher lives in client code so the library containing
74 // the code has to be loaded, otherwise we crash boom bang
75 if( callback.mImpl && callback.mImpl->mObjectPointer )
77 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
78 (*dispatcher)( callback );
80 // its also possible to have a member function pointer to a CallbackProvider
81 // that has been deleted, so check if we have impl still
82 else if( !callback.mImpl && callback.mFunction )
84 (*(callback.mFunction))();
88 DALI_ASSERT_ALWAYS( 0 && "no function to execute" );
93 * @brief Function to call the function or member function dispatcher.
96 * @param[in] callback The callback to call
97 * @return The value from the function
99 template< typename R >
100 static R ExecuteReturn( CallbackBase& callback )
103 // if we point to a function, we can call it directly
104 // otherwise call the dispatcher function that knows the real type of the object
105 // Note that this template dispatcher lives in client code so the library containing
106 // the code has to be loaded, otherwise we crash boom bang
107 if( callback.mImpl && callback.mImpl->mObjectPointer )
109 typedef R(*Dispatcher)(CallbackBase& base);
110 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
111 returnVal = (*dispatcher)( callback );
113 else if( !callback.mImpl && callback.mFunction )
115 typedef R(*Function1)();
116 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
123 * @brief Function to call the function or member function dispatcher.
125 * This function template gets instantiated at the call site.
127 * @param[in] callback The callback to call
128 * @param[in] param1 The first parameter to pass into the function
130 template< typename P1 >
131 static void Execute( CallbackBase& callback, P1 param1 )
133 // if we point to a function, we can call it directly
134 // otherwise call the dispatcher function that knows the real type of the object
135 // Note that this template dispatcher lives in client code (where the callback was created)
136 // so the library containing the code has to be loaded, otherwise we crash boom bang
137 if( callback.mImpl && callback.mImpl->mObjectPointer )
139 typedef void(*Dispatcher)(CallbackBase& base,P1);
140 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
141 (*dispatcher)( callback, param1 );
143 else if( !callback.mImpl && callback.mFunction )
145 // convert function type
146 typedef void(*Function1)(P1);
147 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
152 * @brief Function to call the function or member function dispatcher.
154 * This function template gets instantiated at the call site.
156 * @param[in] callback The callback to call
157 * @param[in] param1 The first parameter to pass into the function
158 * @return The value from the function
160 template< typename R, typename P1 >
161 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
164 // if we point to a function, we can call it directly
165 // otherwise call the dispatcher function that knows the real type of the object
166 // Note that this template dispatcher lives in client code (where the callback was created)
167 // so the library containing the code has to be loaded, otherwise we crash boom bang
168 if( callback.mImpl && callback.mImpl->mObjectPointer )
170 typedef R(*Dispatcher)(CallbackBase& base,P1);
171 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
172 returnVal = (*dispatcher)( callback, param1 );
174 else if( !callback.mImpl && callback.mFunction )
176 // convert function type
177 typedef R(*Function1)(P1);
178 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
185 * @brief Function to call the function or member function dispatcher.
187 * This function template gets instantiated at the call site.
189 * @param[in] callback The callback to call
190 * @param[in] param1 The first parameter to pass into the function
191 * @param[in] param2 The second parameter to pass into the function
193 template< typename P1, typename P2 >
194 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
196 // if we point to a function, we can call it directly
197 // otherwise call the dispatcher function that knows the real type of the object
198 // Note that this template dispatcher lives in client code (where the callback was created)
199 // so the library containing the code has to be loaded, otherwise we crash boom bang
200 if( callback.mImpl && callback.mImpl->mObjectPointer )
202 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
203 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
204 (*dispatcher)( callback, param1, param2 );
206 else if( !callback.mImpl && callback.mFunction )
208 // convert function type
209 typedef void(*Function2)(P1,P2);
210 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
215 * @brief Function to call the function or member function dispatcher.
217 * This function template gets instantiated at the call site.
219 * @param[in] callback The callback to call
220 * @param[in] param1 The first parameter to pass into the function
221 * @param[in] param2 The second parameter to pass into the function
222 * @return The return value from the function
224 template< typename R, typename P1, typename P2 >
225 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
228 // if we point to a function, we can call it directly
229 // otherwise call the dispatcher function that knows the real type of the object
230 // Note that this template dispatcher lives in client code (where the callback was created)
231 // so the library containing the code has to be loaded, otherwise we crash boom bang
232 if( callback.mImpl && callback.mImpl->mObjectPointer )
234 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
235 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
236 returnVal = (*dispatcher)( callback, param1, param2 );
238 else if( !callback.mImpl && callback.mFunction )
240 // convert function type
241 typedef R(*Function2)(P1,P2);
242 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
249 * @brief Function to call the function or member function dispatcher.
251 * This function template gets instantiated at the call site.
253 * @param[in] callback The callback to call
254 * @param[in] param1 The first parameter to pass into the function
255 * @param[in] param2 The second parameter to pass into the function
256 * @param[in] param3 The third parameter to pass into the function
258 template< typename P1, typename P2, typename P3 >
259 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
261 // if we point to a function, we can call it directly
262 // otherwise call the dispatcher function that knows the real type of the object
263 // Note that this template dispatcher lives in client code (where the callback was created)
264 // so the library containing the code has to be loaded, otherwise we crash boom bang
265 if( callback.mImpl && callback.mImpl->mObjectPointer )
267 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
268 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
269 (*dispatcher)( callback, param1, param2, param3 );
271 else if( !callback.mImpl && callback.mFunction )
273 // convert function type
274 typedef void(*Function2)(P1,P2,P3);
275 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
280 * @brief Function to call the function or member function dispatcher.
282 * This function template gets instantiated at the call site.
284 * @param[in] callback The callback to call
285 * @param[in] param1 The first parameter to pass into the function
286 * @param[in] param2 The second parameter to pass into the function
287 * @param[in] param3 The third parameter to pass into the function
288 * @return The return value from the function
290 template< typename R, typename P1, typename P2, typename P3 >
291 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
294 // if we point to a function, we can call it directly
295 // otherwise call the dispatcher function that knows the real type of the object
296 // Note that this template dispatcher lives in client code (where the callback was created)
297 // so the library containing the code has to be loaded, otherwise we crash boom bang
298 if( callback.mImpl && callback.mImpl->mObjectPointer )
300 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
301 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
302 returnVal = (*dispatcher)( callback, param1, param2, param3 );
304 else if( !callback.mImpl && callback.mFunction )
306 // convert function type
307 typedef R(*Function2)(P1,P2,P3);
308 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
314 protected: // Constructors for deriving classes
317 * @brief Function with static linkage.
320 typedef void(*Function)(void);
323 * @brief Member function.
326 typedef void (CallbackBase::*MemberFunction)( void );
329 * @brief Used to call the correct member function.
332 typedef void (*Dispatcher)( CallbackBase& base );
335 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned).
338 typedef void(*Destructor)(void* object);
341 * @brief Copy constructor operator not declared.
343 * @param[in] rhs Handle to an object
345 CallbackBase( const CallbackBase& rhs );
348 * @brief Assignment operator not declared.
350 * @param[in] rhs Handle to an object
351 * @return A reference to this
353 CallbackBase& operator=( const CallbackBase& rhs );
356 * @brief Constructor for function with static linkage.
359 * @param[in] function The function to call
361 CallbackBase( Function function );
364 * @brief Constructor for member function.
367 * @param[in] object The object to call (not owned)
368 * @param[in] function The member function of the object
369 * @param[in] dispatcher Used to call the actual object
371 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
374 * @brief Constructor for member function.
377 * @param[in] object The object to call (owned)
378 * @param[in] function The member function of the object
379 * @param dispatcher Used to call the actual object
380 * @param destructor Used to delete the owned object
382 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
384 public: // Data for deriving classes & Dispatchers
387 * @brief Struct to hold the extra data needed for member functions.
392 Impl(); ///< Default constructor @SINCE_1_0.0
394 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
395 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
396 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
398 Impl* mImpl; ///< Implementation pointer
402 MemberFunction mMemberFunction; ///< Pointer to member function
403 Function mFunction; ///< Static function
408 * @brief Non-member equality operator.
410 * @param[in] lhs A reference to compare
411 * @param[in] rhs A reference to compare to
412 * @return True if lhs is same as rhs
414 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
417 * @brief Dispatcher to delete an object.
424 * @brief Dispatcher to delete an object.
426 * @param[in] object An object to delete
428 static void Delete( void* object )
430 // CallbackBase owns the object but we're the only one who knows the real type so need
431 // to delete by "downcasting" from void* to the correct type
432 delete reinterpret_cast< T* >( object );
437 * @brief Dispatcher to call the actual member function.
444 * @brief Calls an actual member function.
447 * @param[in] callback The callback information
449 static void Dispatch( CallbackBase& callback )
451 // "downcast" the object and function type back to the correct ones
452 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
453 typedef void(T::*MemberFunction)(void);
454 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
455 (object->*function)();
460 * @brief Dispatcher to call the actual member function.
463 template< class T, typename P1 >
467 * @brief Calls an actual member function.
470 * @param[in] callback The callback information
471 * @param[in] param1 The first parameter to pass to the real member function
473 static void Dispatch( CallbackBase& callback, P1 param1 )
475 // "downcast" the object and function type back to the correct ones
476 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
477 typedef void(T::*MemberFunction)(P1);
478 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
479 (object->*function)( param1 );
484 * @brief Dispatcher to call the actual member function.
487 template< class T, typename P1, typename P2 >
491 * @brief Call an actual member function.
494 * @param[in] callback The callback information
495 * @param[in] param1 The first parameter to pass to the real member function
496 * @param[in] param2 The second parameter to pass to the real member function
498 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
500 // "downcast" the object and function type back to the correct ones
501 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
502 typedef void(T::*MemberFunction)(P1, P2);
503 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
504 (object->*function)( param1, param2 );
509 * @brief Dispatcher to call the actual member function.
512 template< class T, typename P1, typename P2, typename P3 >
516 * @brief Call an actual member function.
519 * @param[in] callback The callback information
520 * @param[in] param1 The first parameter to pass to the real member function
521 * @param[in] param2 The second parameter to pass to the real member function
522 * @param[in] param3 The third parameter to pass to the real member function
524 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
526 // "downcast" the object and function type back to the correct ones
527 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
528 typedef void(T::*MemberFunction)(P1, P2, P3);
529 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
530 (object->*function)( param1, param2, param3 );
535 * @brief Dispatcher to call the actual member function.
538 template< class T, typename R >
539 struct DispatcherReturn0
542 * @brief Calls an actual member function.
545 * @param[in] callback The callback information
548 static R Dispatch( CallbackBase& callback )
550 // "downcast" the object and function type back to the correct ones
551 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
552 typedef R(T::*MemberFunction)(void);
553 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
554 return (object->*function)();
559 * @brief Dispatcher to call the actual member function.
562 template< class T, typename R, typename P1 >
563 struct DispatcherReturn1
566 * @brief Calls an actual member function.
569 * @param[in] callback The callback information
570 * @param[in] param1 The first parameter to pass to the real member function
571 * @return The return value from the function
573 static R Dispatch( CallbackBase& callback, P1 param1 )
575 // "downcast" the object and function type back to the correct ones
576 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
577 typedef R(T::*MemberFunction)(P1);
578 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
579 return (object->*function)( param1 );
584 * @brief Dispatcher to call the actual member function.
587 template< class T, typename R, typename P1, typename P2 >
588 struct DispatcherReturn2
591 * @brief Calls an actual member function.
594 * @param[in] callback The callback information
595 * @param[in] param1 The first parameter to pass to the real member function
596 * @param[in] param2 The second parameter to pass to the real member function
597 * @return The return value from the function
599 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
601 // "downcast" the object and function type back to the correct ones
602 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
603 typedef R(T::*MemberFunction)(P1, P2);
604 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
605 return (object->*function)( param1, param2 );
610 * @brief Dispatcher to call the actual member function.
613 template< class T, typename R, typename P1, typename P2, typename P3 >
614 struct DispatcherReturn3
617 * @brief Calls an actual member function.
620 * @param[in] callback The callback information
621 * @param[in] param1 The first parameter to pass to the real member function
622 * @param[in] param2 The second parameter to pass to the real member function
623 * @param[in] param3 The third parameter to pass to the real member function
624 * @return The return value from the function
626 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
628 // "downcast" the object and function type back to the correct ones
629 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
630 typedef R(T::*MemberFunction)(P1, P2, P3);
631 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
632 return (object->*function)( param1, param2, param3 );
637 * @brief Dispatcher to call a functor.
641 struct FunctorDispatcher0
644 * @brief Calls a function object.
647 * @param[in] callback The callback information
649 static void Dispatch( CallbackBase& callback )
651 // "downcast" the object and function type back to the correct ones
652 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
658 * @brief Dispatcher to call a functor.
661 template< class T, typename P1 >
662 struct FunctorDispatcher1
665 * @brief Calls a function object.
668 * @param[in] callback The callback information
669 * @param[in] param1 The first parameter to pass to the real member function.
671 static void Dispatch( CallbackBase& callback, P1 param1 )
673 // "downcast" the object and function type back to the correct ones
674 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
680 * @brief Dispatcher to call a functor.
683 template< class T, typename P1, typename P2 >
684 struct FunctorDispatcher2
687 * @brief Calls a function object.
690 * @param[in] callback The callback information
691 * @param[in] param1 The first parameter to pass to the real member function
692 * @param[in] param2 The second parameter to pass to the real member function
694 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
696 // "downcast" the object and function type back to the correct ones
697 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
698 (*object)( param1, param2 );
703 * @brief Dispatcher to call a functor.
706 template< class T, typename P1, typename P2, typename P3 >
707 struct FunctorDispatcher3
710 * @brief Calls a function object.
713 * @param[in] callback The callback information
714 * @param[in] param1 The first parameter to pass to the real member function
715 * @param[in] param2 The second parameter to pass to the real member function
716 * @param[in] param3 The third parameter to pass to the real member function
718 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
720 // "downcast" the object and function type back to the correct ones
721 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
722 (*object)( param1, param2, param3 );
727 * @brief Dispatcher to call a functor.
730 template< class T, typename R >
731 struct FunctorDispatcherReturn0
734 * @brief Calls a function object.
737 * @param[in] callback The callback information
740 static R Dispatch( CallbackBase& callback )
742 // "downcast" the object and function type back to the correct ones
743 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
749 * @brief Dispatcher to call a functor.
752 template< class T, typename R, typename P1 >
753 struct FunctorDispatcherReturn1
756 * @brief Calls a function object.
759 * @param[in] callback The callback information
760 * @param[in] param1 The first parameter to pass to the real member function
761 * @return The return value from the function
763 static R Dispatch( CallbackBase& callback, P1 param1 )
765 // "downcast" the object and function type back to the correct ones
766 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
767 return (*object)( param1 );
772 * @brief Dispatcher to call a functor.
775 template< class T, typename R, typename P1, typename P2 >
776 struct FunctorDispatcherReturn2
779 * @brief Calls a function object.
782 * @param[in] callback The callback information
783 * @param[in] param1 The first parameter to pass to the real member function
784 * @param[in] param2 The second parameter to pass to the real member function
785 * @return The return value from the function
787 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
789 // "downcast" the object and function type back to the correct ones
790 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
791 return (*object)( param1, param2 );
796 * @brief Dispatcher to call a functor.
799 template< class T, typename R, typename P1, typename P2, typename P3 >
800 struct FunctorDispatcherReturn3
803 * @brief Calls a function object.
806 * @param[in] callback The callback information
807 * @param[in] param1 The first parameter to pass to the real member function
808 * @param[in] param2 The second parameter to pass to the real member function
809 * @param[in] param3 The third parameter to pass to the real member function
810 * @return The return value from the function
812 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
814 // "downcast" the object and function type back to the correct ones
815 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
816 return (*object)( param1, param2, param3 );
821 * @brief Dispatcher to call a functor.
823 * This variant calls a specific void() member function.
827 struct VoidFunctorDispatcher0
830 * @brief Calls a function object.
833 * @param[in] callback The callback information
835 static void Dispatch( CallbackBase& callback )
837 // "downcast" the object and function type back to the correct ones
838 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
839 typedef void(T::*MemberFunction)(void);
840 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
841 (object->*function)();
846 * @brief Dispatcher to call a functor.
848 * This variant calls a void() member, ignoring any signal parameters.
851 template< class T, typename P1 >
852 struct VoidFunctorDispatcher1
855 * @brief Calls a function object.
858 * @param[in] callback The callback information
859 * @param[in] param1 The first parameter to pass to the real member function
861 static void Dispatch( CallbackBase& callback, P1 param1 )
863 // "downcast" the object and function type back to the correct ones
864 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
865 typedef void(T::*MemberFunction)(void);
866 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
867 (object->*function)(/*ignore params*/);
872 * @brief Dispatcher to call a functor.
874 * This variant calls a void() member, ignoring any signal parameters.
877 template< class T, typename P1, typename P2 >
878 struct VoidFunctorDispatcher2
881 * @brief Calls a function object.
884 * @param[in] callback The callback information
885 * @param[in] param1 The first parameter to pass to the real member function
886 * @param[in] param2 The second parameter to pass to the real member function
888 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
890 // "downcast" the object and function type back to the correct ones
891 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
892 typedef void(T::*MemberFunction)(void);
893 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
894 (object->*function)(/*ignore params*/);
899 * @brief Dispatcher to call a functor.
901 * This variant calls a void() member, ignoring any signal parameters.
904 template< class T, typename P1, typename P2, typename P3 >
905 struct VoidFunctorDispatcher3
908 * @brief Calls a function object.
911 * @param[in] callback The callback information
912 * @param[in] param1 The first parameter to pass to the real member function
913 * @param[in] param2 The second parameter to pass to the real member function
914 * @param[in] param3 The third parameter to pass to the real member function
916 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
918 // "downcast" the object and function type back to the correct ones
919 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
920 typedef void(T::*MemberFunction)(void);
921 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
922 (object->*function)(/*ignore params*/);
927 * @brief Dispatcher to call a functor.
929 * This variant calls a void() member, and returns a default-constructed value.
932 template< class T, typename R >
933 struct VoidFunctorDispatcherReturn0
936 * @brief Calls a function object.
939 * @param[in] callback The callback information
942 static R Dispatch( CallbackBase& callback )
944 // "downcast" the object and function type back to the correct ones
945 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
946 typedef void(T::*MemberFunction)(void);
947 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
948 (object->*function)(/*ignore params*/);
954 * @brief Dispatcher to call a functor.
956 * This variant calls a void() member, and returns a default-constructed value.
959 template< class T, typename R, typename P1 >
960 struct VoidFunctorDispatcherReturn1
963 * @brief Calls a function object.
966 * @param[in] callback The callback information
967 * @param[in] param1 The first parameter to pass to the real member function
968 * @return The return value from the function
970 static R Dispatch( CallbackBase& callback, P1 param1 )
972 // "downcast" the object and function type back to the correct ones
973 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
974 typedef void(T::*MemberFunction)(void);
975 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
976 (object->*function)(/*ignore params*/);
982 * @brief Dispatcher to call a functor.
984 * This variant calls a void() member, and returns a default-constructed value.
987 template< class T, typename R, typename P1, typename P2 >
988 struct VoidFunctorDispatcherReturn2
991 * @brief Calls a function object.
994 * @param[in] callback The callback information
995 * @param[in] param1 The first parameter to pass to the real member function
996 * @param[in] param2 The second parameter to pass to the real member function
997 * @return The return value from the function
999 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
1001 // "downcast" the object and function type back to the correct ones
1002 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1003 typedef void(T::*MemberFunction)(void);
1004 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1005 (object->*function)(/*ignore params*/);
1011 * @brief Dispatcher to call a functor.
1013 * This variant calls a void() member, and returns a default-constructed value.
1016 template< class T, typename R, typename P1, typename P2, typename P3 >
1017 struct VoidFunctorDispatcherReturn3
1020 * @brief Calls a function object.
1023 * @param[in] callback The callback information
1024 * @param[in] param1 The first parameter to pass to the real member function
1025 * @param[in] param2 The second parameter to pass to the real member function
1026 * @param[in] param3 The third parameter to pass to the real member function
1027 * @return The return value from the function
1029 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
1031 // "downcast" the object and function type back to the correct ones
1032 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1033 typedef void(T::*MemberFunction)(void);
1034 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1035 (object->*function)(/*ignore params*/);
1041 * @brief Thin template to provide type safety for member function callbacks.
1043 * Version with two parameters and return value.
1047 class Callback : public CallbackBase
1052 * @brief Default constructor.
1062 * @brief Constructor for member function.
1064 * Copies the function object.
1066 * @param[in] object The object to call
1067 * @param[in] memberFunction The member function of the object
1069 Callback( T* object, void(T::*memberFunction)(void) )
1070 : CallbackBase( object,
1071 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1072 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
1073 template< typename P1 >
1074 Callback( T* object, void(T::*memberFunction)(P1) )
1075 : CallbackBase( object,
1076 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1077 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
1078 template< typename P1, typename P2 >
1079 Callback( T* object, void(T::*memberFunction)(P1, P2) )
1080 : CallbackBase( object,
1081 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1082 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
1083 template< typename P1, typename P2, typename P3 >
1084 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
1085 : CallbackBase( object,
1086 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1087 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
1088 template< typename R >
1089 Callback( T* object, R(T::*memberFunction)(void) )
1090 : CallbackBase( object,
1091 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1092 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1093 template< typename R, typename P1 >
1094 Callback( T* object, R(T::*memberFunction)(P1) )
1095 : CallbackBase( object,
1096 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1097 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1098 template< typename R, typename P1, typename P2 >
1099 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1100 : CallbackBase( object,
1101 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1102 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1103 template< typename R, typename P1, typename P2, typename P3 >
1104 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1105 : CallbackBase( object,
1106 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1107 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1112 * @brief Specializations for static function callbacks.
1115 class CallbackFunction : public CallbackBase
1120 * @brief Default constructor.
1129 * @brief Constructors for functions with static linkage.
1132 * @param[in] function The function to call
1134 CallbackFunction( void(*function)() )
1135 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1137 template< typename R >
1138 CallbackFunction( R(*function)() )
1139 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1141 template< typename P1 >
1142 CallbackFunction( void(*function)(P1) )
1143 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1145 template< typename P1, typename R >
1146 CallbackFunction( R(*function)(P1) )
1147 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1149 template< typename P1, typename P2 >
1150 CallbackFunction( void(*function)(P1,P2) )
1151 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1153 template< typename P1, typename P2, typename R >
1154 CallbackFunction( R(*function)(P1,P2) )
1155 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1157 template< typename P1, typename P2, typename P3 >
1158 CallbackFunction( void(*function)(P1,P2,P3) )
1159 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1161 template< typename P1, typename P2, typename P3, typename R >
1162 CallbackFunction( R(*function)(P1,P2,P3) )
1163 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1169 * @brief Specializations for function object callbacks.
1173 class CallbackFunctor0 : public CallbackBase
1178 * @brief Constructor which copies a function object.
1181 * @param[in] object The object to copy
1183 CallbackFunctor0( const T& object )
1184 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1185 NULL, // uses operator() instead of member function
1186 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1187 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1191 * @brief Function object callback for connecting void() methods.
1194 class CallbackFunctorDelegate0 : public CallbackBase
1199 * @brief Constructor which copies a function object.
1201 * This variant calls a void() member, ignoring any signal parameters.
1203 * @param[in] object A newly allocated object (ownership is transferred)
1205 CallbackFunctorDelegate0( FunctorDelegate* object )
1206 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1207 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1208 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1209 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1213 * @brief Function object callback for matching callbacks to signal signature.
1216 template< class T, typename P1 >
1217 class CallbackFunctor1 : public CallbackBase
1222 * @brief Constructor which copies a function object.
1225 * @param[in] object The object to copy
1227 CallbackFunctor1( const T& object )
1228 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1229 NULL, // uses operator() instead of member function
1230 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1231 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1235 * @brief Function object callback for connecting void() methods.
1238 template< typename P1 >
1239 class CallbackFunctorDelegate1 : public CallbackBase
1244 * @brief Constructor which copies a function object.
1246 * This variant calls a void() member, ignoring any signal parameters.
1248 * @param[in] object The object to copy
1250 CallbackFunctorDelegate1( FunctorDelegate* object )
1251 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1252 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1253 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1254 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1258 * @brief Function object callback for matching callbacks to signal signature.
1261 template< class T, typename P1, typename P2 >
1262 class CallbackFunctor2 : public CallbackBase
1267 * @brief Constructor which copies a function object.
1270 * @param[in] object The object to copy
1272 CallbackFunctor2( const T& object )
1273 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1274 NULL, // uses operator() instead of member function
1275 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1276 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1280 * @brief Function object callback for connecting void() methods.
1283 template< typename P1, typename P2 >
1284 class CallbackFunctorDelegate2 : public CallbackBase
1289 * @brief Constructor which copies a function object.
1291 * This variant calls a void() member, ignoring any signal parameters.
1293 * @param[in] object The object to copy
1295 CallbackFunctorDelegate2( FunctorDelegate* object )
1296 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1297 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1298 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1299 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1303 * @brief Function object callback for matching callbacks to signal signature.
1306 template< class T, typename P1, typename P2, typename P3 >
1307 class CallbackFunctor3 : public CallbackBase
1312 * @brief Constructor which copies a function object.
1315 * @param[in] object The object to copy
1317 CallbackFunctor3( const T& object )
1318 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1319 NULL, // uses operator() instead of member function
1320 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1321 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1325 * @brief Function object callback for connecting void() methods.
1328 template< typename P1, typename P2, typename P3 >
1329 class CallbackFunctorDelegate3 : public CallbackBase
1335 * @brief Constructor which copies a function object.
1337 * This variant calls a void() member, ignoring any signal parameters.
1339 * @param[in] object The object to copy
1341 CallbackFunctorDelegate3( FunctorDelegate* object )
1342 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1343 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1344 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1345 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1349 * @brief Function object callback for matching callbacks to signal signature.
1352 template< class T, typename R >
1353 class CallbackFunctorReturn0 : public CallbackBase
1358 * @brief Constructor which copies a function object.
1361 * @param[in] object The object to copy
1363 CallbackFunctorReturn0( const T& object )
1364 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1365 NULL, // uses operator() instead of member function
1366 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1367 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1371 * @brief Function object callback for connecting void() methods.
1374 template< typename R >
1375 class CallbackFunctorDelegateReturn0 : public CallbackBase
1380 * @brief Constructor which copies a function object.
1382 * This variant calls a void() member, ignoring any signal parameters.
1384 * @param[in] object The object to copy
1386 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1387 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1388 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1389 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1390 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1394 * @brief Function object callback for matching callbacks to signal signature.
1397 template< class T, typename P1, typename R >
1398 class CallbackFunctorReturn1 : public CallbackBase
1403 * @brief Constructor which copies a function object.
1406 * @param[in] object The object to copy
1408 CallbackFunctorReturn1( const T& object )
1409 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1410 NULL, // uses operator() instead of member function
1411 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1412 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1416 * @brief Function object callback for connecting void() methods.
1419 template< typename P1, typename R >
1420 class CallbackFunctorDelegateReturn1 : public CallbackBase
1425 * @brief Constructor which copies a function object.
1427 * This variant calls a void() member, ignoring any signal parameters.
1429 * @param[in] object The object to copy
1431 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1432 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1433 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1434 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1435 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1439 * @brief Function object callback for matching callbacks to signal signature.
1442 template< class T, typename P1, typename P2, typename R >
1443 class CallbackFunctorReturn2 : public CallbackBase
1448 * @brief Constructor which copies a function object.
1451 * @param[in] object The object to copy
1453 CallbackFunctorReturn2( const T& object )
1454 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1455 NULL, // uses operator() instead of member function
1456 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1457 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1461 * @brief Function object callback for connecting void() methods.
1464 template< typename P1, typename P2, typename R >
1465 class CallbackFunctorDelegateReturn2 : public CallbackBase
1470 * @brief Constructor which copies a function object.
1472 * This variant calls a void() member, ignoring any signal parameters.
1474 * @param[in] object The object to copy
1476 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1477 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1478 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1479 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1480 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1484 * @brief Function object callback for matching callbacks to signal signature.
1487 template< class T, typename P1, typename P2, typename P3, typename R >
1488 class CallbackFunctorReturn3 : public CallbackBase
1493 * @brief Constructor which copies a function object.
1496 * @param[in] object The object to copy
1498 CallbackFunctorReturn3( const T& object )
1499 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1500 NULL, // uses operator() instead of member function
1501 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1502 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1506 * @brief Function object callback for connecting void() methods.
1509 template< typename P1, typename P2, typename P3, typename R >
1510 class CallbackFunctorDelegateReturn3 : public CallbackBase
1515 * @brief Constructor which copies a function object.
1517 * This variant calls a void() member, ignoring any signal parameters.
1519 * @param[in] object The object to copy
1521 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1522 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1523 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1524 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1525 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1528 // Callback creation thin templates
1531 * @brief Creates a callback from a C function or static member function with no parameters.
1534 * @param[in] function The function to call
1535 * @return A newly allocated Callback object, ownership transferred to caller
1537 inline CallbackBase* MakeCallback( void(*function)(void) )
1539 return new CallbackFunction( function );
1543 * @brief Creates a callback from a C function or static member function with one parameter.
1546 * @param[in] function The function to call
1547 * @return A newly allocated Callback object, ownership transferred to caller
1549 template< typename P1 >
1550 inline CallbackBase* MakeCallback( void(*function)(P1) )
1552 return new CallbackFunction( function );
1556 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1559 * @param[in] function The function to call
1560 * @return A newly allocated Callback object, ownership transferred to caller
1562 template< typename R >
1563 inline CallbackBase* MakeCallback( R(*function)(void) )
1565 return new CallbackFunction( function );
1569 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1572 * @param[in] function The function to call
1573 * @return A newly allocated Callback object, ownership transferred to caller
1575 template< typename R, typename P1 >
1576 inline CallbackBase* MakeCallback( R(*function)(P1) )
1578 return new CallbackFunction( function );
1582 * @brief Creates a callback from a C function or static member function with two parameters.
1585 * @param[in] function The function to call
1586 * @return A newly allocated Callback object, ownership transferred to caller
1588 template< typename P1, typename P2 >
1589 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1591 return new CallbackFunction( function );
1595 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1598 * @param[in] function The function to call
1599 * @return A newly allocated Callback object, ownership transferred to caller
1601 template< typename R, typename P1, typename P2 >
1602 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1604 return new CallbackFunction( function );
1608 * @brief Creates a callback from a C function or static member function with three parameters.
1611 * @param[in] function The function to call
1612 * @return A newly allocated Callback object, ownership transferred to caller
1614 template< typename P1, typename P2, typename P3 >
1615 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1617 return new CallbackFunction( function );
1621 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1624 * @param[in] function The function to call
1625 * @return A newly allocated Callback object, ownership transferred to caller
1627 template< typename R, typename P1, typename P2, typename P3 >
1628 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1630 return new CallbackFunction( function );
1634 * @brief Creates a callback from a class member function with no parameters.
1636 * Requires the function to be member of the same class.
1638 * @param[in] object The object to call
1639 * @param[in] function The member function to call
1640 * @return A newly allocated Callback object, ownership transferred to caller
1643 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1645 return new Callback< T >( object, function );
1649 * @brief Creates a callback from a class member function with one parameter.
1651 * Requires the function to be member of the same class.
1653 * @param[in] object The object to call
1654 * @param[in] function The member function to call
1655 * @return A newly allocated Callback object, ownership transferred to caller
1657 template< class T, typename P1 >
1658 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1660 return new Callback< T >( object, function );
1664 * @brief Creates a callback from a class member function with two parameters.
1666 * Requires the function to be member of the same class.
1668 * @param[in] object The object to call
1669 * @param[in] function The member function to call
1670 * @return A newly allocated Callback object, ownership transferred to caller
1672 template< class T, typename P1, typename P2 >
1673 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1675 return new Callback< T >( object, function );
1679 * @brief Creates a callback from a class member function with three parameters.
1681 * Requires the function to be member of the same class.
1683 * @param[in] object The object to call
1684 * @param[in] function The member function to call
1685 * @return A newly allocated Callback object, ownership transferred to caller
1687 template< class T, typename P1, typename P2, typename P3 >
1688 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1690 return new Callback< T >( object, function );
1694 * @brief Creates a callback from a class member function with no parameters and a return type.
1696 * Requires the function to be member of the same class.
1698 * @param[in] object The object to call
1699 * @param[in] function The member function to call
1700 * @return A newly allocated Callback object, ownership transferred to caller
1702 template< class T, typename R >
1703 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1705 return new Callback< T >( object, function );
1709 * @brief Creates a callback from a class member function with one parameter and a return type.
1711 * Requires the function to be member of the same class.
1713 * @param[in] object The object to call
1714 * @param[in] function The member function to call
1715 * @return A newly allocated Callback object, ownership transferred to caller
1717 template< class T, typename P1, typename R >
1718 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1720 return new Callback< T >( object, function );
1724 * @brief Creates a callback from a class member function with two parameters and a return type.
1726 * Requires the function to be member of the same class.
1728 * @param[in] object The object to call
1729 * @param[in] function The member function to call
1730 * @return A newly allocated Callback object, ownership transferred to caller
1732 template< class T, typename P1, typename P2, typename R >
1733 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1735 return new Callback< T >( object, function );
1739 * @brief Creates a callback from a class member function with three parameters and a return type.
1741 * Requires the function to be member of the same class.
1743 * @param[in] object The object to call
1744 * @param[in] function The member function to call
1745 * @return A newly allocated Callback object, ownership transferred to caller
1747 template< class T, typename P1, typename P2, typename P3, typename R >
1748 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1750 return new Callback< T >( object, function );
1754 * @brief Creates a callback from a class's parent member function with no parameters.
1756 * Requires the function to be member of the same class.
1758 * @param[in] object The object to call
1759 * @param[in] function The member function to call
1760 * @return A newly allocated Callback object, ownership transferred to caller
1762 template< class T, class Base >
1763 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1765 return new Callback< T >( object, function );
1768 * @brief Creates a callback from a class's parent member function with no parameters.
1770 * Requires the function to be member of the same class.
1772 * @param[in] object The object to call
1773 * @param[in] function The member function to call
1774 * @return A newly allocated Callback object, ownership transferred to caller
1776 template< class T, class Base >
1777 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1779 return new Callback< T >( object, function );
1787 #endif // __DALI_CALLBACK_H__