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 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 );
347 * @brief Assignment operator not declared.
349 * @param[in] rhs Handle to an object
350 * @return A reference to this
352 const CallbackBase& operator=( const CallbackBase& rhs );
355 * @brief Constructor for function with static linkage.
358 * @param[in] function The function to call
360 CallbackBase( Function function );
363 * @brief Constructor for member function.
366 * @param[in] object The object to call (not owned)
367 * @param[in] function The member function of the object
368 * @param[in] dispatcher Used to call the actual object
370 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
373 * @brief Constructor for member function.
376 * @param[in] object The object to call (owned)
377 * @param[in] function The member function of the object
378 * @param dispatcher Used to call the actual object
379 * @param destructor Used to delete the owned object
381 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
383 public: // Data for deriving classes & Dispatchers
386 * @brief Struct to hold the extra data needed for member functions.
391 Impl(); ///< Default constructor @SINCE_1_0.0
393 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
394 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
395 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
397 Impl* mImpl; ///< Implementation pointer
401 MemberFunction mMemberFunction; ///< Pointer to member function
402 Function mFunction; ///< Static function
407 * @brief Non-member equality operator.
409 * @param[in] lhs A reference to compare
410 * @param[in] rhs A reference to compare to
411 * @return True if lhs is same as rhs
413 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
416 * @brief Dispatcher to delete an object.
423 * @brief Dispatcher to delete an object.
425 * @param[in] object An object to delete
427 static void Delete( void* object )
429 // CallbackBase owns the object but we're the only one who knows the real type so need
430 // to delete by "downcasting" from void* to the correct type
431 delete reinterpret_cast< T* >( object );
436 * @brief Dispatcher to call the actual member function.
443 * @brief Calls an actual member function.
446 * @param[in] callback The callback information
448 static void Dispatch( CallbackBase& callback )
450 // "downcast" the object and function type back to the correct ones
451 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
452 typedef void(T::*MemberFunction)(void);
453 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
454 (object->*function)();
459 * @brief Dispatcher to call the actual member function.
462 template< class T, typename P1 >
466 * @brief Calls an actual member function.
469 * @param[in] callback The callback information
470 * @param[in] param1 The first parameter to pass to the real member function
472 static void Dispatch( CallbackBase& callback, P1 param1 )
474 // "downcast" the object and function type back to the correct ones
475 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
476 typedef void(T::*MemberFunction)(P1);
477 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
478 (object->*function)( param1 );
483 * @brief Dispatcher to call the actual member function.
486 template< class T, typename P1, typename P2 >
490 * @brief Call an actual member function.
493 * @param[in] callback The callback information
494 * @param[in] param1 The first parameter to pass to the real member function
495 * @param[in] param2 The second parameter to pass to the real member function
497 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
499 // "downcast" the object and function type back to the correct ones
500 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
501 typedef void(T::*MemberFunction)(P1, P2);
502 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
503 (object->*function)( param1, param2 );
508 * @brief Dispatcher to call the actual member function.
511 template< class T, typename P1, typename P2, typename P3 >
515 * @brief Call an actual member function.
518 * @param[in] callback The callback information
519 * @param[in] param1 The first parameter to pass to the real member function
520 * @param[in] param2 The second parameter to pass to the real member function
521 * @param[in] param3 The third parameter to pass to the real member function
523 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
525 // "downcast" the object and function type back to the correct ones
526 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
527 typedef void(T::*MemberFunction)(P1, P2, P3);
528 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
529 (object->*function)( param1, param2, param3 );
534 * @brief Dispatcher to call the actual member function.
537 template< class T, typename R >
538 struct DispatcherReturn0
541 * @brief Calls an actual member function.
544 * @param[in] callback The callback information
547 static R Dispatch( CallbackBase& callback )
549 // "downcast" the object and function type back to the correct ones
550 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
551 typedef R(T::*MemberFunction)(void);
552 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
553 return (object->*function)();
558 * @brief Dispatcher to call the actual member function.
561 template< class T, typename R, typename P1 >
562 struct DispatcherReturn1
565 * @brief Calls an actual member function.
568 * @param[in] callback The callback information
569 * @param[in] param1 The first parameter to pass to the real member function
570 * @return The return value from the function
572 static R Dispatch( CallbackBase& callback, P1 param1 )
574 // "downcast" the object and function type back to the correct ones
575 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
576 typedef R(T::*MemberFunction)(P1);
577 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
578 return (object->*function)( param1 );
583 * @brief Dispatcher to call the actual member function.
586 template< class T, typename R, typename P1, typename P2 >
587 struct DispatcherReturn2
590 * @brief Calls an actual member function.
593 * @param[in] callback The callback information
594 * @param[in] param1 The first parameter to pass to the real member function
595 * @param[in] param2 The second parameter to pass to the real member function
596 * @return The return value from the function
598 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
600 // "downcast" the object and function type back to the correct ones
601 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
602 typedef R(T::*MemberFunction)(P1, P2);
603 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
604 return (object->*function)( param1, param2 );
609 * @brief Dispatcher to call the actual member function.
612 template< class T, typename R, typename P1, typename P2, typename P3 >
613 struct DispatcherReturn3
616 * @brief Calls an actual member function.
619 * @param[in] callback The callback information
620 * @param[in] param1 The first parameter to pass to the real member function
621 * @param[in] param2 The second parameter to pass to the real member function
622 * @param[in] param3 The third parameter to pass to the real member function
623 * @return The return value from the function
625 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
627 // "downcast" the object and function type back to the correct ones
628 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
629 typedef R(T::*MemberFunction)(P1, P2, P3);
630 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
631 return (object->*function)( param1, param2, param3 );
636 * @brief Dispatcher to call a functor.
640 struct FunctorDispatcher0
643 * @brief Calls a function object.
646 * @param[in] callback The callback information
648 static void Dispatch( CallbackBase& callback )
650 // "downcast" the object and function type back to the correct ones
651 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
657 * @brief Dispatcher to call a functor.
660 template< class T, typename P1 >
661 struct FunctorDispatcher1
664 * @brief Calls a function object.
667 * @param[in] callback The callback information
668 * @param[in] param1 The first parameter to pass to the real member function.
670 static void Dispatch( CallbackBase& callback, P1 param1 )
672 // "downcast" the object and function type back to the correct ones
673 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
679 * @brief Dispatcher to call a functor.
682 template< class T, typename P1, typename P2 >
683 struct FunctorDispatcher2
686 * @brief Calls a function object.
689 * @param[in] callback The callback information
690 * @param[in] param1 The first parameter to pass to the real member function
691 * @param[in] param2 The second parameter to pass to the real member function
693 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
695 // "downcast" the object and function type back to the correct ones
696 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
697 (*object)( param1, param2 );
702 * @brief Dispatcher to call a functor.
705 template< class T, typename P1, typename P2, typename P3 >
706 struct FunctorDispatcher3
709 * @brief Calls a function object.
712 * @param[in] callback The callback information
713 * @param[in] param1 The first parameter to pass to the real member function
714 * @param[in] param2 The second parameter to pass to the real member function
715 * @param[in] param3 The third parameter to pass to the real member function
717 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
719 // "downcast" the object and function type back to the correct ones
720 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
721 (*object)( param1, param2, param3 );
726 * @brief Dispatcher to call a functor.
729 template< class T, typename R >
730 struct FunctorDispatcherReturn0
733 * @brief Calls a function object.
736 * @param[in] callback The callback information
739 static R Dispatch( CallbackBase& callback )
741 // "downcast" the object and function type back to the correct ones
742 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
748 * @brief Dispatcher to call a functor.
751 template< class T, typename R, typename P1 >
752 struct FunctorDispatcherReturn1
755 * @brief Calls a function object.
758 * @param[in] callback The callback information
759 * @param[in] param1 The first parameter to pass to the real member function
760 * @return The return value from the function
762 static R Dispatch( CallbackBase& callback, P1 param1 )
764 // "downcast" the object and function type back to the correct ones
765 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
766 return (*object)( param1 );
771 * @brief Dispatcher to call a functor.
774 template< class T, typename R, typename P1, typename P2 >
775 struct FunctorDispatcherReturn2
778 * @brief Calls a function object.
781 * @param[in] callback The callback information
782 * @param[in] param1 The first parameter to pass to the real member function
783 * @param[in] param2 The second parameter to pass to the real member function
784 * @return The return value from the function
786 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
788 // "downcast" the object and function type back to the correct ones
789 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
790 return (*object)( param1, param2 );
795 * @brief Dispatcher to call a functor.
798 template< class T, typename R, typename P1, typename P2, typename P3 >
799 struct FunctorDispatcherReturn3
802 * @brief Calls a function object.
805 * @param[in] callback The callback information
806 * @param[in] param1 The first parameter to pass to the real member function
807 * @param[in] param2 The second parameter to pass to the real member function
808 * @param[in] param3 The third parameter to pass to the real member function
809 * @return The return value from the function
811 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
813 // "downcast" the object and function type back to the correct ones
814 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
815 return (*object)( param1, param2, param3 );
820 * @brief Dispatcher to call a functor.
822 * This variant calls a specific void() member function.
826 struct VoidFunctorDispatcher0
829 * @brief Calls a function object.
832 * @param[in] callback The callback information
834 static void Dispatch( CallbackBase& callback )
836 // "downcast" the object and function type back to the correct ones
837 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
838 typedef void(T::*MemberFunction)(void);
839 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
840 (object->*function)();
845 * @brief Dispatcher to call a functor.
847 * This variant calls a void() member, ignoring any signal parameters.
850 template< class T, typename P1 >
851 struct VoidFunctorDispatcher1
854 * @brief Calls a function object.
857 * @param[in] callback The callback information
858 * @param[in] param1 The first parameter to pass to the real member function
860 static void Dispatch( CallbackBase& callback, P1 param1 )
862 // "downcast" the object and function type back to the correct ones
863 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
864 typedef void(T::*MemberFunction)(void);
865 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
866 (object->*function)(/*ignore params*/);
871 * @brief Dispatcher to call a functor.
873 * This variant calls a void() member, ignoring any signal parameters.
876 template< class T, typename P1, typename P2 >
877 struct VoidFunctorDispatcher2
880 * @brief Calls a function object.
883 * @param[in] callback The callback information
884 * @param[in] param1 The first parameter to pass to the real member function
885 * @param[in] param2 The second parameter to pass to the real member function
887 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
889 // "downcast" the object and function type back to the correct ones
890 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
891 typedef void(T::*MemberFunction)(void);
892 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
893 (object->*function)(/*ignore params*/);
898 * @brief Dispatcher to call a functor.
900 * This variant calls a void() member, ignoring any signal parameters.
903 template< class T, typename P1, typename P2, typename P3 >
904 struct VoidFunctorDispatcher3
907 * @brief Calls a function object.
910 * @param[in] callback The callback information
911 * @param[in] param1 The first parameter to pass to the real member function
912 * @param[in] param2 The second parameter to pass to the real member function
913 * @param[in] param3 The third parameter to pass to the real member function
915 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
917 // "downcast" the object and function type back to the correct ones
918 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
919 typedef void(T::*MemberFunction)(void);
920 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
921 (object->*function)(/*ignore params*/);
926 * @brief Dispatcher to call a functor.
928 * This variant calls a void() member, and returns a default-constructed value.
931 template< class T, typename R >
932 struct VoidFunctorDispatcherReturn0
935 * @brief Calls a function object.
938 * @param[in] callback The callback information
941 static R Dispatch( CallbackBase& callback )
943 // "downcast" the object and function type back to the correct ones
944 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
945 typedef void(T::*MemberFunction)(void);
946 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
947 (object->*function)(/*ignore params*/);
953 * @brief Dispatcher to call a functor.
955 * This variant calls a void() member, and returns a default-constructed value.
958 template< class T, typename R, typename P1 >
959 struct VoidFunctorDispatcherReturn1
962 * @brief Calls a function object.
965 * @param[in] callback The callback information
966 * @param[in] param1 The first parameter to pass to the real member function
967 * @return The return value from the function
969 static R Dispatch( CallbackBase& callback, P1 param1 )
971 // "downcast" the object and function type back to the correct ones
972 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
973 typedef void(T::*MemberFunction)(void);
974 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
975 (object->*function)(/*ignore params*/);
981 * @brief Dispatcher to call a functor.
983 * This variant calls a void() member, and returns a default-constructed value.
986 template< class T, typename R, typename P1, typename P2 >
987 struct VoidFunctorDispatcherReturn2
990 * @brief Calls a function object.
993 * @param[in] callback The callback information
994 * @param[in] param1 The first parameter to pass to the real member function
995 * @param[in] param2 The second parameter to pass to the real member function
996 * @return The return value from the function
998 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
1000 // "downcast" the object and function type back to the correct ones
1001 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1002 typedef void(T::*MemberFunction)(void);
1003 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1004 (object->*function)(/*ignore params*/);
1010 * @brief Dispatcher to call a functor.
1012 * This variant calls a void() member, and returns a default-constructed value.
1015 template< class T, typename R, typename P1, typename P2, typename P3 >
1016 struct VoidFunctorDispatcherReturn3
1019 * @brief Calls a function object.
1022 * @param[in] callback The callback information
1023 * @param[in] param1 The first parameter to pass to the real member function
1024 * @param[in] param2 The second parameter to pass to the real member function
1025 * @param[in] param3 The third parameter to pass to the real member function
1026 * @return The return value from the function
1028 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
1030 // "downcast" the object and function type back to the correct ones
1031 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1032 typedef void(T::*MemberFunction)(void);
1033 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1034 (object->*function)(/*ignore params*/);
1040 * @brief Thin template to provide type safety for member function callbacks.
1042 * Version with two parameters and return value.
1046 class Callback : public CallbackBase
1051 * @brief Default constructor.
1061 * @brief Constructor for member function.
1063 * Copies the function object.
1065 * @param[in] object The object to call
1066 * @param[in] memberFunction The member function of the object
1068 Callback( T* object, void(T::*memberFunction)(void) )
1069 : CallbackBase( object,
1070 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1071 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
1072 template< typename P1 >
1073 Callback( T* object, void(T::*memberFunction)(P1) )
1074 : CallbackBase( object,
1075 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1076 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
1077 template< typename P1, typename P2 >
1078 Callback( T* object, void(T::*memberFunction)(P1, P2) )
1079 : CallbackBase( object,
1080 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1081 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
1082 template< typename P1, typename P2, typename P3 >
1083 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
1084 : CallbackBase( object,
1085 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1086 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
1087 template< typename R >
1088 Callback( T* object, R(T::*memberFunction)(void) )
1089 : CallbackBase( object,
1090 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1091 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1092 template< typename R, typename P1 >
1093 Callback( T* object, R(T::*memberFunction)(P1) )
1094 : CallbackBase( object,
1095 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1096 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1097 template< typename R, typename P1, typename P2 >
1098 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1099 : CallbackBase( object,
1100 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1101 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1102 template< typename R, typename P1, typename P2, typename P3 >
1103 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1104 : CallbackBase( object,
1105 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1106 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1111 * @brief Specializations for static function callbacks.
1114 class CallbackFunction : public CallbackBase
1119 * @brief Default constructor.
1128 * @brief Constructors for functions with static linkage.
1131 * @param[in] function The function to call
1133 CallbackFunction( void(*function)() )
1134 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1136 template< typename R >
1137 CallbackFunction( R(*function)() )
1138 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1140 template< typename P1 >
1141 CallbackFunction( void(*function)(P1) )
1142 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1144 template< typename P1, typename R >
1145 CallbackFunction( R(*function)(P1) )
1146 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1148 template< typename P1, typename P2 >
1149 CallbackFunction( void(*function)(P1,P2) )
1150 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1152 template< typename P1, typename P2, typename R >
1153 CallbackFunction( R(*function)(P1,P2) )
1154 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1156 template< typename P1, typename P2, typename P3 >
1157 CallbackFunction( void(*function)(P1,P2,P3) )
1158 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1160 template< typename P1, typename P2, typename P3, typename R >
1161 CallbackFunction( R(*function)(P1,P2,P3) )
1162 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1168 * @brief Specializations for function object callbacks.
1172 class CallbackFunctor0 : public CallbackBase
1177 * @brief Constructor which copies a function object.
1180 * @param[in] object The object to copy
1182 CallbackFunctor0( const T& object )
1183 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1184 NULL, // uses operator() instead of member function
1185 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1186 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1190 * @brief Function object callback for connecting void() methods.
1193 class CallbackFunctorDelegate0 : public CallbackBase
1198 * @brief Constructor which copies a function object.
1200 * This variant calls a void() member, ignoring any signal parameters.
1202 * @param[in] object A newly allocated object (ownership is transferred)
1204 CallbackFunctorDelegate0( FunctorDelegate* object )
1205 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1206 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1207 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1208 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1212 * @brief Function object callback for matching callbacks to signal signature.
1215 template< class T, typename P1 >
1216 class CallbackFunctor1 : public CallbackBase
1221 * @brief Constructor which copies a function object.
1224 * @param[in] object The object to copy
1226 CallbackFunctor1( const T& object )
1227 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1228 NULL, // uses operator() instead of member function
1229 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1230 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1234 * @brief Function object callback for connecting void() methods.
1237 template< typename P1 >
1238 class CallbackFunctorDelegate1 : public CallbackBase
1243 * @brief Constructor which copies a function object.
1245 * This variant calls a void() member, ignoring any signal parameters.
1247 * @param[in] object The object to copy
1249 CallbackFunctorDelegate1( FunctorDelegate* object )
1250 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1251 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1252 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1253 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1257 * @brief Function object callback for matching callbacks to signal signature.
1260 template< class T, typename P1, typename P2 >
1261 class CallbackFunctor2 : public CallbackBase
1266 * @brief Constructor which copies a function object.
1269 * @param[in] object The object to copy
1271 CallbackFunctor2( const T& object )
1272 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1273 NULL, // uses operator() instead of member function
1274 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1275 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1279 * @brief Function object callback for connecting void() methods.
1282 template< typename P1, typename P2 >
1283 class CallbackFunctorDelegate2 : public CallbackBase
1288 * @brief Constructor which copies a function object.
1290 * This variant calls a void() member, ignoring any signal parameters.
1292 * @param[in] object The object to copy
1294 CallbackFunctorDelegate2( FunctorDelegate* object )
1295 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1296 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1297 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1298 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1302 * @brief Function object callback for matching callbacks to signal signature.
1305 template< class T, typename P1, typename P2, typename P3 >
1306 class CallbackFunctor3 : public CallbackBase
1311 * @brief Constructor which copies a function object.
1314 * @param[in] object The object to copy
1316 CallbackFunctor3( const T& object )
1317 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1318 NULL, // uses operator() instead of member function
1319 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1320 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1324 * @brief Function object callback for connecting void() methods.
1327 template< typename P1, typename P2, typename P3 >
1328 class CallbackFunctorDelegate3 : public CallbackBase
1334 * @brief Constructor which copies a function object.
1336 * This variant calls a void() member, ignoring any signal parameters.
1338 * @param[in] object The object to copy
1340 CallbackFunctorDelegate3( FunctorDelegate* object )
1341 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1342 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1343 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1344 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1348 * @brief Function object callback for matching callbacks to signal signature.
1351 template< class T, typename R >
1352 class CallbackFunctorReturn0 : public CallbackBase
1357 * @brief Constructor which copies a function object.
1360 * @param[in] object The object to copy
1362 CallbackFunctorReturn0( const T& object )
1363 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1364 NULL, // uses operator() instead of member function
1365 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1366 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1370 * @brief Function object callback for connecting void() methods.
1373 template< typename R >
1374 class CallbackFunctorDelegateReturn0 : public CallbackBase
1379 * @brief Constructor which copies a function object.
1381 * This variant calls a void() member, ignoring any signal parameters.
1383 * @param[in] object The object to copy
1385 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1386 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1387 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1388 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1389 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1393 * @brief Function object callback for matching callbacks to signal signature.
1396 template< class T, typename P1, typename R >
1397 class CallbackFunctorReturn1 : public CallbackBase
1402 * @brief Constructor which copies a function object.
1405 * @param[in] object The object to copy
1407 CallbackFunctorReturn1( const T& object )
1408 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1409 NULL, // uses operator() instead of member function
1410 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1411 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1415 * @brief Function object callback for connecting void() methods.
1418 template< typename P1, typename R >
1419 class CallbackFunctorDelegateReturn1 : public CallbackBase
1424 * @brief Constructor which copies a function object.
1426 * This variant calls a void() member, ignoring any signal parameters.
1428 * @param[in] object The object to copy
1430 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1431 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1432 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1433 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1434 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1438 * @brief Function object callback for matching callbacks to signal signature.
1441 template< class T, typename P1, typename P2, typename R >
1442 class CallbackFunctorReturn2 : public CallbackBase
1447 * @brief Constructor which copies a function object.
1450 * @param[in] object The object to copy
1452 CallbackFunctorReturn2( const T& object )
1453 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1454 NULL, // uses operator() instead of member function
1455 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1456 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1460 * @brief Function object callback for connecting void() methods.
1463 template< typename P1, typename P2, typename R >
1464 class CallbackFunctorDelegateReturn2 : public CallbackBase
1469 * @brief Constructor which copies a function object.
1471 * This variant calls a void() member, ignoring any signal parameters.
1473 * @param[in] object The object to copy
1475 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1476 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1477 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1478 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1479 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1483 * @brief Function object callback for matching callbacks to signal signature.
1486 template< class T, typename P1, typename P2, typename P3, typename R >
1487 class CallbackFunctorReturn3 : public CallbackBase
1492 * @brief Constructor which copies a function object.
1495 * @param[in] object The object to copy
1497 CallbackFunctorReturn3( const T& object )
1498 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1499 NULL, // uses operator() instead of member function
1500 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1501 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1505 * @brief Function object callback for connecting void() methods.
1508 template< typename P1, typename P2, typename P3, typename R >
1509 class CallbackFunctorDelegateReturn3 : public CallbackBase
1514 * @brief Constructor which copies a function object.
1516 * This variant calls a void() member, ignoring any signal parameters.
1518 * @param[in] object The object to copy
1520 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1521 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1522 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1523 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1524 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1527 // Callback creation thin templates
1530 * @brief Creates a callback from a C function or static member function with no parameters.
1533 * @param[in] function The function to call
1534 * @return A newly allocated Callback object, ownership transferred to caller
1536 inline CallbackBase* MakeCallback( void(*function)(void) )
1538 return new CallbackFunction( function );
1542 * @brief Creates a callback from a C function or static member function with one parameter.
1545 * @param[in] function The function to call
1546 * @return A newly allocated Callback object, ownership transferred to caller
1548 template< typename P1 >
1549 inline CallbackBase* MakeCallback( void(*function)(P1) )
1551 return new CallbackFunction( function );
1555 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1558 * @param[in] function The function to call
1559 * @return A newly allocated Callback object, ownership transferred to caller
1561 template< typename R >
1562 inline CallbackBase* MakeCallback( R(*function)(void) )
1564 return new CallbackFunction( function );
1568 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1571 * @param[in] function The function to call
1572 * @return A newly allocated Callback object, ownership transferred to caller
1574 template< typename R, typename P1 >
1575 inline CallbackBase* MakeCallback( R(*function)(P1) )
1577 return new CallbackFunction( function );
1581 * @brief Creates a callback from a C function or static member function with two parameters.
1584 * @param[in] function The function to call
1585 * @return A newly allocated Callback object, ownership transferred to caller
1587 template< typename P1, typename P2 >
1588 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1590 return new CallbackFunction( function );
1594 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1597 * @param[in] function The function to call
1598 * @return A newly allocated Callback object, ownership transferred to caller
1600 template< typename R, typename P1, typename P2 >
1601 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1603 return new CallbackFunction( function );
1607 * @brief Creates a callback from a C function or static member function with three parameters.
1610 * @param[in] function The function to call
1611 * @return A newly allocated Callback object, ownership transferred to caller
1613 template< typename P1, typename P2, typename P3 >
1614 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1616 return new CallbackFunction( function );
1620 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1623 * @param[in] function The function to call
1624 * @return A newly allocated Callback object, ownership transferred to caller
1626 template< typename R, typename P1, typename P2, typename P3 >
1627 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1629 return new CallbackFunction( function );
1633 * @brief Creates a callback from a class member function with no parameters.
1635 * Requires the function to be member of the same class.
1637 * @param[in] object The object to call
1638 * @param[in] function The member function to call
1639 * @return A newly allocated Callback object, ownership transferred to caller
1642 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1644 return new Callback< T >( object, function );
1648 * @brief Creates a callback from a class member function with one parameter.
1650 * Requires the function to be member of the same class.
1652 * @param[in] object The object to call
1653 * @param[in] function The member function to call
1654 * @return A newly allocated Callback object, ownership transferred to caller
1656 template< class T, typename P1 >
1657 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1659 return new Callback< T >( object, function );
1663 * @brief Creates a callback from a class member function with two parameters.
1665 * Requires the function to be member of the same class.
1667 * @param[in] object The object to call
1668 * @param[in] function The member function to call
1669 * @return A newly allocated Callback object, ownership transferred to caller
1671 template< class T, typename P1, typename P2 >
1672 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1674 return new Callback< T >( object, function );
1678 * @brief Creates a callback from a class member function with three parameters.
1680 * Requires the function to be member of the same class.
1682 * @param[in] object The object to call
1683 * @param[in] function The member function to call
1684 * @return A newly allocated Callback object, ownership transferred to caller
1686 template< class T, typename P1, typename P2, typename P3 >
1687 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1689 return new Callback< T >( object, function );
1693 * @brief Creates a callback from a class member function with no parameters and a return type.
1695 * Requires the function to be member of the same class.
1697 * @param[in] object The object to call
1698 * @param[in] function The member function to call
1699 * @return A newly allocated Callback object, ownership transferred to caller
1701 template< class T, typename R >
1702 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1704 return new Callback< T >( object, function );
1708 * @brief Creates a callback from a class member function with one parameter and a return type.
1710 * Requires the function to be member of the same class.
1712 * @param[in] object The object to call
1713 * @param[in] function The member function to call
1714 * @return A newly allocated Callback object, ownership transferred to caller
1716 template< class T, typename P1, typename R >
1717 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1719 return new Callback< T >( object, function );
1723 * @brief Creates a callback from a class member function with two parameters and a return type.
1725 * Requires the function to be member of the same class.
1727 * @param[in] object The object to call
1728 * @param[in] function The member function to call
1729 * @return A newly allocated Callback object, ownership transferred to caller
1731 template< class T, typename P1, typename P2, typename R >
1732 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1734 return new Callback< T >( object, function );
1738 * @brief Creates a callback from a class member function with three parameters and a return type.
1740 * Requires the function to be member of the same class.
1742 * @param[in] object The object to call
1743 * @param[in] function The member function to call
1744 * @return A newly allocated Callback object, ownership transferred to caller
1746 template< class T, typename P1, typename P2, typename P3, typename R >
1747 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1749 return new Callback< T >( object, function );
1753 * @brief Creates a callback from a class's parent member function with no parameters.
1755 * Requires the function to be member of the same class.
1757 * @param[in] object The object to call
1758 * @param[in] function The member function to call
1759 * @return A newly allocated Callback object, ownership transferred to caller
1761 template< class T, class Base >
1762 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1764 return new Callback< T >( object, function );
1767 * @brief Creates a callback from a class's parent member function with no parameters.
1769 * Requires the function to be member of the same class.
1771 * @param[in] object The object to call
1772 * @param[in] function The member function to call
1773 * @return A newly allocated Callback object, ownership transferred to caller
1775 template< class T, class Base >
1776 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1778 return new Callback< T >( object, function );
1786 #endif // __DALI_CALLBACK_H__