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.
41 class DALI_IMPORT_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 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.
344 CallbackBase( const CallbackBase& rhs );
346 * @brief assignment operator not declared.
349 const CallbackBase& operator=( const CallbackBase& rhs );
352 * @brief Constructor for function with static linkage.
355 * @param[in] function The function to call.
357 CallbackBase( Function function );
360 * @brief Constructor for member function.
363 * @param[in] object The object to call (not owned).
364 * @param[in] function The member function of the object.
365 * @param[in] dispatcher Used to call the actual object.
367 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
370 * @brief Constructor for member function.
373 * @param[in] object The object to call (owned).
374 * @param[in] function The member function of the object.
375 * @param dispatcher Used to call the actual object.
376 * @param destructor Used to delete the owned object.
378 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
380 public: // Data for deriving classes & Dispatchers
383 * @brief struct to hold the extra data needed for member functions.
388 Impl(); ///< Default constructor @SINCE_1_0.0
390 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
391 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
392 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
394 Impl* mImpl; ///< Implementation pointer
398 MemberFunction mMemberFunction; ///< Pointer to member function
399 Function mFunction; ///< Static function
404 * @brief Non-member equality operator
407 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
410 * @brief Dispatcher to delete an object.
417 * @brief Dispatcher to delete an object.
420 static void Delete( void* object )
422 // CallbackBase owns the object but we're the only one who knows the real type so need
423 // to delete by "downcasting" from void* to the correct type
424 delete reinterpret_cast< T* >( object );
429 * @brief Dispatcher to call the actual member function.
436 * @brief Call an actual member function.
439 * @param[in] callback The callback information.
441 static void Dispatch( CallbackBase& callback )
443 // "downcast" the object and function type back to the correct ones
444 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
445 typedef void(T::*MemberFunction)(void);
446 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
447 (object->*function)();
452 * @brief Dispatcher to call the actual member function.
455 template< class T, typename P1 >
459 * @brief Call an actual member function.
462 * @param[in] callback The callback information.
463 * @param[in] param1 The first parameter to pass to the real member function.
465 static void Dispatch( CallbackBase& callback, P1 param1 )
467 // "downcast" the object and function type back to the correct ones
468 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
469 typedef void(T::*MemberFunction)(P1);
470 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
471 (object->*function)( param1 );
476 * @brief Dispatcher to call the actual member function.
479 template< class T, typename P1, typename P2 >
483 * @brief Call an actual member function.
486 * @param[in] callback The callback information.
487 * @param[in] param1 The first parameter to pass to the real member function.
488 * @param[in] param2 The second parameter to pass to the real member function.
490 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
492 // "downcast" the object and function type back to the correct ones
493 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
494 typedef void(T::*MemberFunction)(P1, P2);
495 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
496 (object->*function)( param1, param2 );
501 * @brief Dispatcher to call the actual member function.
504 template< class T, typename P1, typename P2, typename P3 >
508 * @brief Call an actual member function.
511 * @param[in] callback The callback information.
512 * @param[in] param1 The first parameter to pass to the real member function.
513 * @param[in] param2 The second parameter to pass to the real member function.
514 * @param[in] param3 The third parameter to pass to the real member function.
516 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
518 // "downcast" the object and function type back to the correct ones
519 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
520 typedef void(T::*MemberFunction)(P1, P2, P3);
521 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
522 (object->*function)( param1, param2, param3 );
527 * @brief Dispatcher to call the actual member function.
530 template< class T, typename R >
531 struct DispatcherReturn0
534 * @brief Call an actual member function.
537 * @param[in] callback The callback information.
540 static R Dispatch( CallbackBase& callback )
542 // "downcast" the object and function type back to the correct ones
543 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
544 typedef R(T::*MemberFunction)(void);
545 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
546 return (object->*function)();
551 * @brief Dispatcher to call the actual member function.
554 template< class T, typename R, typename P1 >
555 struct DispatcherReturn1
558 * @brief Call an actual member function.
561 * @param[in] callback The callback information.
562 * @param[in] param1 The first parameter to pass to the real member function.
563 * @return The return value from the function
565 static R Dispatch( CallbackBase& callback, P1 param1 )
567 // "downcast" the object and function type back to the correct ones
568 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
569 typedef R(T::*MemberFunction)(P1);
570 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
571 return (object->*function)( param1 );
576 * @brief Dispatcher to call the actual member function.
579 template< class T, typename R, typename P1, typename P2 >
580 struct DispatcherReturn2
583 * @brief Call an actual member function.
586 * @param[in] callback The callback information.
587 * @param[in] param1 The first parameter to pass to the real member function.
588 * @param[in] param2 The second parameter to pass to the real member function.
589 * @return The return value from the function
591 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
593 // "downcast" the object and function type back to the correct ones
594 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
595 typedef R(T::*MemberFunction)(P1, P2);
596 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
597 return (object->*function)( param1, param2 );
602 * @brief Dispatcher to call the actual member function.
605 template< class T, typename R, typename P1, typename P2, typename P3 >
606 struct DispatcherReturn3
609 * @brief Call an actual member function.
612 * @param[in] callback The callback information.
613 * @param[in] param1 The first parameter to pass to the real member function.
614 * @param[in] param2 The second parameter to pass to the real member function.
615 * @param[in] param3 The third parameter to pass to the real member function.
616 * @return The return value from the function
618 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
620 // "downcast" the object and function type back to the correct ones
621 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
622 typedef R(T::*MemberFunction)(P1, P2, P3);
623 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
624 return (object->*function)( param1, param2, param3 );
629 * @brief Dispatcher to call a functor.
633 struct FunctorDispatcher0
636 * @brief Call a function object.
639 * @param[in] callback The callback information.
641 static void Dispatch( CallbackBase& callback )
643 // "downcast" the object and function type back to the correct ones
644 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
650 * @brief Dispatcher to call a functor.
653 template< class T, typename P1 >
654 struct FunctorDispatcher1
657 * @brief Call a function object.
660 * @param[in] callback The callback information.
661 * @param[in] param1 The first parameter to pass to the real member function.
663 static void Dispatch( CallbackBase& callback, P1 param1 )
665 // "downcast" the object and function type back to the correct ones
666 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
672 * @brief Dispatcher to call a functor.
675 template< class T, typename P1, typename P2 >
676 struct FunctorDispatcher2
679 * @brief Call a function object.
682 * @param[in] callback The callback information.
683 * @param[in] param1 The first parameter to pass to the real member function.
684 * @param[in] param2 The second parameter to pass to the real member function.
686 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
688 // "downcast" the object and function type back to the correct ones
689 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
690 (*object)( param1, param2 );
695 * @brief Dispatcher to call a functor.
698 template< class T, typename P1, typename P2, typename P3 >
699 struct FunctorDispatcher3
702 * @brief Call a function object.
705 * @param[in] callback The callback information.
706 * @param[in] param1 The first parameter to pass to the real member function.
707 * @param[in] param2 The second parameter to pass to the real member function.
708 * @param[in] param3 The third parameter to pass to the real member function.
710 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
712 // "downcast" the object and function type back to the correct ones
713 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
714 (*object)( param1, param2, param3 );
719 * @brief Dispatcher to call a functor.
722 template< class T, typename R >
723 struct FunctorDispatcherReturn0
726 * @brief Call a function object.
729 * @param[in] callback The callback information.
732 static R Dispatch( CallbackBase& callback )
734 // "downcast" the object and function type back to the correct ones
735 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
741 * @brief Dispatcher to call a functor.
744 template< class T, typename R, typename P1 >
745 struct FunctorDispatcherReturn1
748 * @brief Call a function object.
751 * @param[in] callback The callback information.
752 * @param[in] param1 The first parameter to pass to the real member function.
753 * @return The return value from the function
755 static R Dispatch( CallbackBase& callback, P1 param1 )
757 // "downcast" the object and function type back to the correct ones
758 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
759 return (*object)( param1 );
764 * @brief Dispatcher to call a functor.
767 template< class T, typename R, typename P1, typename P2 >
768 struct FunctorDispatcherReturn2
771 * @brief Call a function object.
774 * @param[in] callback The callback information.
775 * @param[in] param1 The first parameter to pass to the real member function.
776 * @param[in] param2 The second parameter to pass to the real member function.
777 * @return The return value from the function
779 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
781 // "downcast" the object and function type back to the correct ones
782 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
783 return (*object)( param1, param2 );
788 * @brief Dispatcher to call a functor.
791 template< class T, typename R, typename P1, typename P2, typename P3 >
792 struct FunctorDispatcherReturn3
795 * @brief Call a function object.
798 * @param[in] callback The callback information.
799 * @param[in] param1 The first parameter to pass to the real member function.
800 * @param[in] param2 The second parameter to pass to the real member function.
801 * @param[in] param3 The third parameter to pass to the real member function.
802 * @return The return value from the function
804 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
806 // "downcast" the object and function type back to the correct ones
807 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
808 return (*object)( param1, param2, param3 );
813 * @brief Dispatcher to call a functor.
814 * This variant calls a specific void() member function.
818 struct VoidFunctorDispatcher0
821 * @brief Call a function object.
824 * @param[in] callback The callback information.
826 static void Dispatch( CallbackBase& callback )
828 // "downcast" the object and function type back to the correct ones
829 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
830 typedef void(T::*MemberFunction)(void);
831 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
832 (object->*function)();
837 * @brief Dispatcher to call a functor.
839 * This variant calls a void() member, ignoring any signal parameters
842 template< class T, typename P1 >
843 struct VoidFunctorDispatcher1
846 * @brief Call a function object.
849 * @param[in] callback The callback information.
850 * @param[in] param1 The first parameter to pass to the real member function.
852 static void Dispatch( CallbackBase& callback, P1 param1 )
854 // "downcast" the object and function type back to the correct ones
855 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
856 typedef void(T::*MemberFunction)(void);
857 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
858 (object->*function)(/*ignore params*/);
863 * @brief Dispatcher to call a functor.
865 * This variant calls a void() member, ignoring any signal parameters
868 template< class T, typename P1, typename P2 >
869 struct VoidFunctorDispatcher2
872 * @brief Call a function object.
875 * @param[in] callback The callback information.
876 * @param[in] param1 The first parameter to pass to the real member function.
877 * @param[in] param2 The second parameter to pass to the real member function.
879 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
881 // "downcast" the object and function type back to the correct ones
882 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
883 typedef void(T::*MemberFunction)(void);
884 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
885 (object->*function)(/*ignore params*/);
890 * @brief Dispatcher to call a functor.
892 * This variant calls a void() member, ignoring any signal parameters
895 template< class T, typename P1, typename P2, typename P3 >
896 struct VoidFunctorDispatcher3
899 * @brief Call a function object.
902 * @param[in] callback The callback information.
903 * @param[in] param1 The first parameter to pass to the real member function.
904 * @param[in] param2 The second parameter to pass to the real member function.
905 * @param[in] param3 The third parameter to pass to the real member function.
907 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
909 // "downcast" the object and function type back to the correct ones
910 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
911 typedef void(T::*MemberFunction)(void);
912 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
913 (object->*function)(/*ignore params*/);
918 * @brief Dispatcher to call a functor.
920 * This variant calls a void() member, and returns a default-constructed value
923 template< class T, typename R >
924 struct VoidFunctorDispatcherReturn0
927 * @brief Call a function object.
930 * @param[in] callback The callback information.
933 static R Dispatch( CallbackBase& callback )
935 // "downcast" the object and function type back to the correct ones
936 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
937 typedef void(T::*MemberFunction)(void);
938 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
939 (object->*function)(/*ignore params*/);
945 * @brief Dispatcher to call a functor.
947 * This variant calls a void() member, and returns a default-constructed value
950 template< class T, typename R, typename P1 >
951 struct VoidFunctorDispatcherReturn1
954 * @brief Call a function object.
957 * @param[in] callback The callback information.
958 * @param[in] param1 The first parameter to pass to the real member function.
959 * @return The return value from the function
961 static R Dispatch( CallbackBase& callback, P1 param1 )
963 // "downcast" the object and function type back to the correct ones
964 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
965 typedef void(T::*MemberFunction)(void);
966 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
967 (object->*function)(/*ignore params*/);
973 * @brief Dispatcher to call a functor.
975 * This variant calls a void() member, and returns a default-constructed value
978 template< class T, typename R, typename P1, typename P2 >
979 struct VoidFunctorDispatcherReturn2
982 * @brief Call a function object.
985 * @param[in] callback The callback information.
986 * @param[in] param1 The first parameter to pass to the real member function.
987 * @param[in] param2 The second parameter to pass to the real member function.
988 * @return The return value from the function
990 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
992 // "downcast" the object and function type back to the correct ones
993 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
994 typedef void(T::*MemberFunction)(void);
995 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
996 (object->*function)(/*ignore params*/);
1002 * @brief Dispatcher to call a functor.
1004 * This variant calls a void() member, and returns a default-constructed value
1007 template< class T, typename R, typename P1, typename P2, typename P3 >
1008 struct VoidFunctorDispatcherReturn3
1011 * @brief Call a function object.
1014 * @param[in] callback The callback information.
1015 * @param[in] param1 The first parameter to pass to the real member function.
1016 * @param[in] param2 The second parameter to pass to the real member function.
1017 * @param[in] param3 The third parameter to pass to the real member function.
1018 * @return The return value from the function
1020 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
1022 // "downcast" the object and function type back to the correct ones
1023 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1024 typedef void(T::*MemberFunction)(void);
1025 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1026 (object->*function)(/*ignore params*/);
1032 * @brief Thin template to provide type safety for member function callbacks.
1034 * version with two parameters and return value
1038 class Callback : public CallbackBase
1043 * @brief Default constructor.
1053 * @brief Constructor for member function.
1055 * Copies the function object.
1057 * @param[in] object The object to call.
1058 * @param[in] memberFunction The member function of the object.
1060 Callback( T* object, void(T::*memberFunction)(void) )
1061 : CallbackBase( object,
1062 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1063 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
1064 template< typename P1 >
1065 Callback( T* object, void(T::*memberFunction)(P1) )
1066 : CallbackBase( object,
1067 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1068 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
1069 template< typename P1, typename P2 >
1070 Callback( T* object, void(T::*memberFunction)(P1, P2) )
1071 : CallbackBase( object,
1072 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1073 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
1074 template< typename P1, typename P2, typename P3 >
1075 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
1076 : CallbackBase( object,
1077 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1078 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
1079 template< typename R >
1080 Callback( T* object, R(T::*memberFunction)(void) )
1081 : CallbackBase( object,
1082 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1083 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1084 template< typename R, typename P1 >
1085 Callback( T* object, R(T::*memberFunction)(P1) )
1086 : CallbackBase( object,
1087 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1088 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1089 template< typename R, typename P1, typename P2 >
1090 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1091 : CallbackBase( object,
1092 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1093 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1094 template< typename R, typename P1, typename P2, typename P3 >
1095 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1096 : CallbackBase( object,
1097 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1098 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1103 * @brief Specializations for static function callbacks.
1106 class CallbackFunction : public CallbackBase
1111 * @brief Default constructor.
1120 * @brief Constructors for functions with static linkage.
1123 * @param[in] function The function to call.
1125 CallbackFunction( void(*function)() )
1126 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1128 template< typename R >
1129 CallbackFunction( R(*function)() )
1130 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1132 template< typename P1 >
1133 CallbackFunction( void(*function)(P1) )
1134 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1136 template< typename P1, typename R >
1137 CallbackFunction( R(*function)(P1) )
1138 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1140 template< typename P1, typename P2 >
1141 CallbackFunction( void(*function)(P1,P2) )
1142 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1144 template< typename P1, typename P2, typename R >
1145 CallbackFunction( R(*function)(P1,P2) )
1146 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1148 template< typename P1, typename P2, typename P3 >
1149 CallbackFunction( void(*function)(P1,P2,P3) )
1150 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1152 template< typename P1, typename P2, typename P3, typename R >
1153 CallbackFunction( R(*function)(P1,P2,P3) )
1154 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1160 * @brief Specializations for function object callbacks.
1164 class CallbackFunctor0 : public CallbackBase
1169 * @brief Constructor which copies a function object.
1172 * @param[in] object The object to copy.
1174 CallbackFunctor0( 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 >( &FunctorDispatcher0<T>::Dispatch ),
1178 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1182 * @brief Function object callback for connecting void() methods
1185 class CallbackFunctorDelegate0 : public CallbackBase
1190 * @brief Constructor which copies a function object.
1192 * This variant calls a void() member, ignoring any signal parameters.
1194 * @param[in] object A newly allocated object (ownership is transferred).
1196 CallbackFunctorDelegate0( FunctorDelegate* object )
1197 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1198 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1199 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1200 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1204 * @brief Function object callback for matching callbacks to signal signature.
1207 template< class T, typename P1 >
1208 class CallbackFunctor1 : public CallbackBase
1213 * @brief Constructor which copies a function object.
1216 * @param[in] object The object to copy.
1218 CallbackFunctor1( const T& object )
1219 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1220 NULL, // uses operator() instead of member function
1221 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1222 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1226 * @brief Function object callback for connecting void() methods.
1229 template< typename P1 >
1230 class CallbackFunctorDelegate1 : public CallbackBase
1235 * @brief Constructor which copies a function object.
1237 * This variant calls a void() member, ignoring any signal parameters.
1239 * @param[in] object The object to copy.
1241 CallbackFunctorDelegate1( FunctorDelegate* object )
1242 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1243 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1244 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1245 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1249 * @brief Function object callback for matching callbacks to signal signature
1252 template< class T, typename P1, typename P2 >
1253 class CallbackFunctor2 : public CallbackBase
1258 * @brief Constructor which copies a function object.
1261 * @param[in] object The object to copy.
1263 CallbackFunctor2( const T& object )
1264 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1265 NULL, // uses operator() instead of member function
1266 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1267 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1271 * @brief Function object callback for connecting void() methods
1274 template< typename P1, typename P2 >
1275 class CallbackFunctorDelegate2 : public CallbackBase
1280 * @brief Constructor which copies a function object.
1282 * This variant calls a void() member, ignoring any signal parameters.
1284 * @param[in] object The object to copy.
1286 CallbackFunctorDelegate2( FunctorDelegate* object )
1287 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1288 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1289 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1290 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1294 * @brief Function object callback for matching callbacks to signal signature
1297 template< class T, typename P1, typename P2, typename P3 >
1298 class CallbackFunctor3 : public CallbackBase
1303 * @brief Constructor which copies a function object.
1306 * @param[in] object The object to copy.
1308 CallbackFunctor3( const T& object )
1309 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1310 NULL, // uses operator() instead of member function
1311 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1312 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1316 * @brief Function object callback for connecting void() methods
1319 template< typename P1, typename P2, typename P3 >
1320 class CallbackFunctorDelegate3 : public CallbackBase
1326 * @brief Constructor which copies a function object.
1328 * This variant calls a void() member, ignoring any signal parameters.
1330 * @param[in] object The object to copy.
1332 CallbackFunctorDelegate3( FunctorDelegate* object )
1333 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1334 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1335 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1336 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1340 * @brief Function object callback for matching callbacks to signal signature
1343 template< class T, typename R >
1344 class CallbackFunctorReturn0 : public CallbackBase
1349 * @brief Constructor which copies a function object.
1352 * @param[in] object The object to copy.
1354 CallbackFunctorReturn0( const T& object )
1355 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1356 NULL, // uses operator() instead of member function
1357 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1358 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1362 * @brief Function object callback for connecting void() methods
1365 template< typename R >
1366 class CallbackFunctorDelegateReturn0 : public CallbackBase
1371 * @brief Constructor which copies a function object.
1373 * This variant calls a void() member, ignoring any signal parameters.
1375 * @param[in] object The object to copy.
1377 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1378 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1379 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1380 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1381 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1385 * @brief Function object callback for matching callbacks to signal signature
1388 template< class T, typename P1, typename R >
1389 class CallbackFunctorReturn1 : public CallbackBase
1394 * @brief Constructor which copies a function object.
1397 * @param[in] object The object to copy.
1399 CallbackFunctorReturn1( const T& object )
1400 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1401 NULL, // uses operator() instead of member function
1402 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1403 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1407 * @brief Function object callback for connecting void() methods
1410 template< typename P1, typename R >
1411 class CallbackFunctorDelegateReturn1 : public CallbackBase
1416 * @brief Constructor which copies a function object.
1418 * This variant calls a void() member, ignoring any signal parameters.
1420 * @param[in] object The object to copy.
1422 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1423 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1424 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1425 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1426 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1430 * @brief Function object callback for matching callbacks to signal signature
1433 template< class T, typename P1, typename P2, typename R >
1434 class CallbackFunctorReturn2 : public CallbackBase
1439 * @brief Constructor which copies a function object.
1442 * @param[in] object The object to copy.
1444 CallbackFunctorReturn2( const T& object )
1445 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1446 NULL, // uses operator() instead of member function
1447 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1448 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1452 * @brief Function object callback for connecting void() methods
1455 template< typename P1, typename P2, typename R >
1456 class CallbackFunctorDelegateReturn2 : public CallbackBase
1461 * @brief Constructor which copies a function object.
1463 * This variant calls a void() member, ignoring any signal parameters.
1465 * @param[in] object The object to copy.
1467 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1468 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1469 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1470 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1471 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1475 * @brief Function object callback for matching callbacks to signal signature
1478 template< class T, typename P1, typename P2, typename P3, typename R >
1479 class CallbackFunctorReturn3 : public CallbackBase
1484 * @brief Constructor which copies a function object.
1487 * @param[in] object The object to copy.
1489 CallbackFunctorReturn3( const T& object )
1490 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1491 NULL, // uses operator() instead of member function
1492 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1493 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1497 * @brief Function object callback for connecting void() methods
1500 template< typename P1, typename P2, typename P3, typename R >
1501 class CallbackFunctorDelegateReturn3 : public CallbackBase
1506 * @brief Constructor which copies a function object.
1508 * This variant calls a void() member, ignoring any signal parameters.
1510 * @param[in] object The object to copy.
1512 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1513 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1514 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1515 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1516 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1519 // Callback creation thin templates
1522 * @brief Creates a callback from a C function or static member function with no parameters.
1525 * @param[in] function The function to call.
1526 * @return a newly allocated Callback object, ownership transferred to caller
1528 inline CallbackBase* MakeCallback( void(*function)(void) )
1530 return new CallbackFunction( function );
1534 * @brief Creates a callback from a C function or static member function with one parameter.
1537 * @param[in] function The function to call.
1538 * @return a newly allocated Callback object, ownership transferred to caller
1540 template< typename P1 >
1541 inline CallbackBase* MakeCallback( void(*function)(P1) )
1543 return new CallbackFunction( function );
1547 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1550 * @param[in] function The function to call.
1551 * @return a newly allocated Callback object, ownership transferred to caller
1553 template< typename R >
1554 inline CallbackBase* MakeCallback( R(*function)(void) )
1556 return new CallbackFunction( function );
1560 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1563 * @param[in] function The function to call.
1564 * @return a newly allocated Callback object, ownership transferred to caller
1566 template< typename R, typename P1 >
1567 inline CallbackBase* MakeCallback( R(*function)(P1) )
1569 return new CallbackFunction( function );
1573 * @brief Creates a callback from a C function or static member function with two parameters.
1576 * @param[in] function The function to call.
1577 * @return a newly allocated Callback object, ownership transferred to caller
1579 template< typename P1, typename P2 >
1580 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1582 return new CallbackFunction( function );
1586 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1589 * @param[in] function The function to call.
1590 * @return a newly allocated Callback object, ownership transferred to caller
1592 template< typename R, typename P1, typename P2 >
1593 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1595 return new CallbackFunction( function );
1599 * @brief Creates a callback from a C function or static member function with three parameters.
1602 * @param[in] function The function to call.
1603 * @return a newly allocated Callback object, ownership transferred to caller
1605 template< typename P1, typename P2, typename P3 >
1606 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1608 return new CallbackFunction( function );
1612 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1615 * @param[in] function The function to call.
1616 * @return a newly allocated Callback object, ownership transferred to caller
1618 template< typename R, typename P1, typename P2, typename P3 >
1619 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1621 return new CallbackFunction( function );
1625 * @brief Creates a callback from a class member function with no parameters.
1627 * requires the function to be member of the same class
1629 * @param[in] object The object to call.
1630 * @param[in] function The member function to call.
1631 * @return a newly allocated Callback object, ownership transferred to caller
1634 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1636 return new Callback< T >( object, function );
1640 * @brief Creates a callback from a class member function with one parameter.
1642 * requires the function to be member of the same class
1644 * @param[in] object The object to call.
1645 * @param[in] function The member function to call.
1646 * @return a newly allocated Callback object, ownership transferred to caller
1648 template< class T, typename P1 >
1649 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1651 return new Callback< T >( object, function );
1655 * @brief Creates a callback from a class member function with two parameters.
1657 * requires the function to be member of the same class
1659 * @param[in] object The object to call.
1660 * @param[in] function The member function to call.
1661 * @return a newly allocated Callback object, ownership transferred to caller
1663 template< class T, typename P1, typename P2 >
1664 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1666 return new Callback< T >( object, function );
1670 * @brief Creates a callback from a class member function with three parameters.
1672 * requires the function to be member of the same class
1674 * @param[in] object The object to call.
1675 * @param[in] function The member function to call.
1676 * @return a newly allocated Callback object, ownership transferred to caller
1678 template< class T, typename P1, typename P2, typename P3 >
1679 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1681 return new Callback< T >( object, function );
1685 * @brief Creates a callback from a class member function with no parameters and a return type.
1687 * requires the function to be member of the same class
1689 * @param[in] object The object to call.
1690 * @param[in] function The member function to call.
1691 * @return a newly allocated Callback object, ownership transferred to caller
1693 template< class T, typename R >
1694 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1696 return new Callback< T >( object, function );
1700 * @brief Creates a callback from a class member function with one parameter and a return type.
1702 * requires the function to be member of the same class
1704 * @param[in] object The object to call.
1705 * @param[in] function The member function to call.
1706 * @return a newly allocated Callback object, ownership transferred to caller
1708 template< class T, typename P1, typename R >
1709 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1711 return new Callback< T >( object, function );
1715 * @brief Creates a callback from a class member function with two parameters and a return type.
1717 * requires the function to be member of the same class
1719 * @param[in] object The object to call.
1720 * @param[in] function The member function to call.
1721 * @return a newly allocated Callback object, ownership transferred to caller
1723 template< class T, typename P1, typename P2, typename R >
1724 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1726 return new Callback< T >( object, function );
1730 * @brief Creates a callback from a class member function with three parameters and a return type.
1732 * requires the function to be member of the same class
1734 * @param[in] object The object to call.
1735 * @param[in] function The member function to call.
1736 * @return a newly allocated Callback object, ownership transferred to caller
1738 template< class T, typename P1, typename P2, typename P3, typename R >
1739 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1741 return new Callback< T >( object, function );
1745 * @brief Creates a callback from a class's parent member function with no parameters.
1747 * requires the function to be member of the same class
1749 * @param[in] object The object to call.
1750 * @param[in] function The member function to call.
1751 * @return a newly allocated Callback object, ownership transferred to caller
1753 template< class T, class Base >
1754 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1756 return new Callback< T >( object, function );
1759 * @brief Creates a callback from a class's parent member function with no parameters.
1761 * requires the function to be member of the same class
1763 * @param[in] object The object to call.
1764 * @param[in] function The member function to call.
1765 * @return a newly allocated Callback object, ownership transferred to caller
1767 template< class T, class Base >
1768 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1770 return new Callback< T >( object, function );
1778 #endif // __DALI_CALLBACK_H__