1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/functor-delegate.h>
34 * @brief Callback base class to hold the data for callback function and member function calls.
36 class DALI_IMPORT_API CallbackBase
41 * @brief Default constructor
51 * @brief Resets the object pointer so that we know not to call methods of this object any more.
56 * @brief Function to call the function or member function dispatcher
58 * @param[in] callback The callback to call.
60 static void Execute( CallbackBase& callback )
62 // if we point to a function, we can call it directly
63 // otherwise call the dispatcher function that knows the real type of the object
64 // Note that this template dispatcher lives in client code so the library containing
65 // the code has to be loaded, otherwise we crash boom bang
66 if( callback.mImpl && callback.mImpl->mObjectPointer )
68 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
69 (*dispatcher)( callback );
71 // its also possible to have a member function pointer to a CallbackProvider
72 // that has been deleted, so check if we have impl still
73 else if( !callback.mImpl && callback.mFunction )
75 (*(callback.mFunction))();
80 * @brief Function to call the function or member function dispatcher.
82 * @param[in] callback The callback to call.
83 * @return value from the function
85 template< typename R >
86 static R ExecuteReturn( CallbackBase& callback )
89 // if we point to a function, we can call it directly
90 // otherwise call the dispatcher function that knows the real type of the object
91 // Note that this template dispatcher lives in client code so the library containing
92 // the code has to be loaded, otherwise we crash boom bang
93 if( callback.mImpl && callback.mImpl->mObjectPointer )
95 typedef R(*Dispatcher)(CallbackBase& base);
96 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
97 returnVal = (*dispatcher)( callback );
99 else if( !callback.mImpl && callback.mFunction )
101 typedef R(*Function1)();
102 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
109 * @brief Function to call the function or member function dispatcher.
111 * This function template gets instantiated at the call site
112 * @param[in] callback The callback to call.
113 * @param[in] param1 The first parameter to pass into the function.
115 template< typename P1 >
116 static void Execute( CallbackBase& callback, P1 param1 )
118 // if we point to a function, we can call it directly
119 // otherwise call the dispatcher function that knows the real type of the object
120 // Note that this template dispatcher lives in client code (where the callback was created)
121 // so the library containing the code has to be loaded, otherwise we crash boom bang
122 if( callback.mImpl && callback.mImpl->mObjectPointer )
124 typedef void(*Dispatcher)(CallbackBase& base,P1);
125 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
126 (*dispatcher)( callback, param1 );
128 else if( !callback.mImpl && callback.mFunction )
130 // convert function type
131 typedef void(*Function1)(P1);
132 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
137 * @brief Function to call the function or member function dispatcher.
139 * This function template gets instantiated at the call site
140 * @param[in] callback The callback to call.
141 * @param[in] param1 The first parameter to pass into the function.
142 * @return the value from the function
144 template< typename R, typename P1 >
145 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
148 // if we point to a function, we can call it directly
149 // otherwise call the dispatcher function that knows the real type of the object
150 // Note that this template dispatcher lives in client code (where the callback was created)
151 // so the library containing the code has to be loaded, otherwise we crash boom bang
152 if( callback.mImpl && callback.mImpl->mObjectPointer )
154 typedef R(*Dispatcher)(CallbackBase& base,P1);
155 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
156 returnVal = (*dispatcher)( callback, param1 );
158 else if( !callback.mImpl && callback.mFunction )
160 // convert function type
161 typedef R(*Function1)(P1);
162 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
169 * @brief Function to call the function or member function dispatcher.
171 * This function template gets instantiated at the call site.
172 * @param[in] callback The callback to call.
173 * @param[in] param1 The first parameter to pass into the function.
174 * @param[in] param2 The second parameter to pass into the function.
176 template< typename P1, typename P2 >
177 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
179 // if we point to a function, we can call it directly
180 // otherwise call the dispatcher function that knows the real type of the object
181 // Note that this template dispatcher lives in client code (where the callback was created)
182 // so the library containing the code has to be loaded, otherwise we crash boom bang
183 if( callback.mImpl && callback.mImpl->mObjectPointer )
185 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
186 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
187 (*dispatcher)( callback, param1, param2 );
189 else if( !callback.mImpl && callback.mFunction )
191 // convert function type
192 typedef void(*Function2)(P1,P2);
193 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
198 * @brief Function to call the function or member function dispatcher.
200 * This function template gets instantiated at the call site
201 * @param[in] callback The callback to call.
202 * @param[in] param1 The first parameter to pass into the function.
203 * @param[in] param2 The second parameter to pass into the function.
204 * @return The return value from the function
206 template< typename R, typename P1, typename P2 >
207 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
210 // if we point to a function, we can call it directly
211 // otherwise call the dispatcher function that knows the real type of the object
212 // Note that this template dispatcher lives in client code (where the callback was created)
213 // so the library containing the code has to be loaded, otherwise we crash boom bang
214 if( callback.mImpl && callback.mImpl->mObjectPointer )
216 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
217 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
218 returnVal = (*dispatcher)( callback, param1, param2 );
220 else if( !callback.mImpl && callback.mFunction )
222 // convert function type
223 typedef R(*Function2)(P1,P2);
224 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
231 * @brief Function to call the function or member function dispatcher.
233 * This function template gets instantiated at the call site.
234 * @param[in] callback The callback to call.
235 * @param[in] param1 The first parameter to pass into the function.
236 * @param[in] param2 The second parameter to pass into the function.
237 * @param[in] param3 The third parameter to pass into the function.
239 template< typename P1, typename P2, typename P3 >
240 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
242 // if we point to a function, we can call it directly
243 // otherwise call the dispatcher function that knows the real type of the object
244 // Note that this template dispatcher lives in client code (where the callback was created)
245 // so the library containing the code has to be loaded, otherwise we crash boom bang
246 if( callback.mImpl && callback.mImpl->mObjectPointer )
248 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
249 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
250 (*dispatcher)( callback, param1, param2, param3 );
252 else if( !callback.mImpl && callback.mFunction )
254 // convert function type
255 typedef void(*Function2)(P1,P2,P3);
256 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
261 * @brief Function to call the function or member function dispatcher.
263 * This function template gets instantiated at the call site
264 * @param[in] callback The callback to call.
265 * @param[in] param1 The first parameter to pass into the function.
266 * @param[in] param2 The second parameter to pass into the function.
267 * @param[in] param3 The third parameter to pass into the function.
268 * @return The return value from the function
270 template< typename R, typename P1, typename P2, typename P3 >
271 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
274 // if we point to a function, we can call it directly
275 // otherwise call the dispatcher function that knows the real type of the object
276 // Note that this template dispatcher lives in client code (where the callback was created)
277 // so the library containing the code has to be loaded, otherwise we crash boom bang
278 if( callback.mImpl && callback.mImpl->mObjectPointer )
280 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
281 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
282 returnVal = (*dispatcher)( callback, param1, param2, param3 );
284 else if( !callback.mImpl && callback.mFunction )
286 // convert function type
287 typedef R(*Function2)(P1,P2,P3);
288 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
294 protected: // Constructors for deriving classes
297 * @brief Function with static linkage
299 typedef void(*Function)(void);
302 * @brief Member function
304 typedef void (CallbackBase::*MemberFunction)( void );
307 * @brief Used to call the correct member function
309 typedef void (*Dispatcher)( CallbackBase& base );
312 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned)
314 typedef void(*Destructor)(void* object);
317 * @brief Copy constructor operator not declared.
319 CallbackBase( const CallbackBase& rhs );
321 * @brief assignment operator not declared.
323 const CallbackBase& operator=( const CallbackBase& rhs );
326 * @brief Constructor for function with static linkage.
328 * @param[in] function The function to call.
330 CallbackBase( Function function );
333 * @brief Constructor for member function.
335 * @param[in] object The object to call (not owned).
336 * @param[in] function The member function of the object.
337 * @param[in] dispatcher Used to call the actual object.
339 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
342 * @brief Constructor for member function.
344 * @param[in] object The object to call (owned).
345 * @param[in] function The member function of the object.
346 * @param dispatcher Used to call the actual object.
347 * @param destructor Used to delete the owned object.
349 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
351 public: // Data for deriving classes & Dispatchers
354 * @brief struct to hold the extra data needed for member functions.
358 Impl(); ///< Default constructor
360 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
361 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
362 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
364 Impl* mImpl; ///< Implementation pointer
368 MemberFunction mMemberFunction; ///< Pointer to member function
369 Function mFunction; ///< Static function
374 * @brief Non-member equality operator
376 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
379 * @brief Dispatcher to delete an object.
385 * @brief Dispatcher to delete an object.
387 static void Delete( void* object )
389 // CallbackBase owns the object but we're the only one who knows the real type so need
390 // to delete by "downcasting" from void* to the correct type
391 delete reinterpret_cast< T* >( object );
396 * @brief Dispatcher to call the actual member function.
402 * @brief Call an actual member function.
404 * @param[in] callback The callback information.
406 static void Dispatch( CallbackBase& callback )
408 // "downcast" the object and function type back to the correct ones
409 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
410 typedef void(T::*MemberFunction)(void);
411 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
412 (object->*function)();
417 * @brief Dispatcher to call the actual member function.
419 template< class T, typename P1 >
423 * @brief Call an actual member function.
425 * @param[in] callback The callback information.
426 * @param[in] param1 The first parameter to pass to the real member function.
428 static void Dispatch( CallbackBase& callback, P1 param1 )
430 // "downcast" the object and function type back to the correct ones
431 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
432 typedef void(T::*MemberFunction)(P1);
433 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
434 (object->*function)( param1 );
439 * @brief Dispatcher to call the actual member function.
441 template< class T, typename P1, typename P2 >
445 * @brief Call an actual member function.
447 * @param[in] callback The callback information.
448 * @param[in] param1 The first parameter to pass to the real member function.
449 * @param[in] param2 The second parameter to pass to the real member function.
451 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
453 // "downcast" the object and function type back to the correct ones
454 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
455 typedef void(T::*MemberFunction)(P1, P2);
456 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
457 (object->*function)( param1, param2 );
462 * @brief Dispatcher to call the actual member function.
464 template< class T, typename P1, typename P2, typename P3 >
468 * @brief Call an actual member function.
470 * @param[in] callback The callback information.
471 * @param[in] param1 The first parameter to pass to the real member function.
472 * @param[in] param2 The second parameter to pass to the real member function.
473 * @param[in] param3 The third parameter to pass to the real member function.
475 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
477 // "downcast" the object and function type back to the correct ones
478 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
479 typedef void(T::*MemberFunction)(P1, P2, P3);
480 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
481 (object->*function)( param1, param2, param3 );
486 * @brief Dispatcher to call the actual member function.
488 template< class T, typename R >
489 struct DispatcherReturn0
492 * @brief Call an actual member function.
494 * @param[in] callback The callback information.
497 static R Dispatch( CallbackBase& callback )
499 // "downcast" the object and function type back to the correct ones
500 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
501 typedef R(T::*MemberFunction)(void);
502 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
503 return (object->*function)();
508 * @brief Dispatcher to call the actual member function.
510 template< class T, typename R, typename P1 >
511 struct DispatcherReturn1
514 * @brief Call an actual member function.
516 * @param[in] callback The callback information.
517 * @param[in] param1 The first parameter to pass to the real member function.
518 * @return The return value from the function
520 static R Dispatch( CallbackBase& callback, P1 param1 )
522 // "downcast" the object and function type back to the correct ones
523 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
524 typedef R(T::*MemberFunction)(P1);
525 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
526 return (object->*function)( param1 );
531 * @brief Dispatcher to call the actual member function.
533 template< class T, typename R, typename P1, typename P2 >
534 struct DispatcherReturn2
537 * @brief Call an actual member function.
539 * @param[in] callback The callback information.
540 * @param[in] param1 The first parameter to pass to the real member function.
541 * @param[in] param2 The second parameter to pass to the real member function.
542 * @return The return value from the function
544 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
546 // "downcast" the object and function type back to the correct ones
547 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
548 typedef R(T::*MemberFunction)(P1, P2);
549 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
550 return (object->*function)( param1, param2 );
555 * @brief Dispatcher to call the actual member function.
557 template< class T, typename R, typename P1, typename P2, typename P3 >
558 struct DispatcherReturn3
561 * @brief Call an actual member function.
563 * @param[in] callback The callback information.
564 * @param[in] param1 The first parameter to pass to the real member function.
565 * @param[in] param2 The second parameter to pass to the real member function.
566 * @param[in] param3 The third parameter to pass to the real member function.
567 * @return The return value from the function
569 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
571 // "downcast" the object and function type back to the correct ones
572 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
573 typedef R(T::*MemberFunction)(P1, P2, P3);
574 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
575 return (object->*function)( param1, param2, param3 );
580 * @brief Dispatcher to call a functor.
583 struct FunctorDispatcher0
586 * @brief Call a function object.
588 * @param[in] callback The callback information.
590 static void Dispatch( CallbackBase& callback )
592 // "downcast" the object and function type back to the correct ones
593 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
599 * @brief Dispatcher to call a functor.
601 template< class T, typename P1 >
602 struct FunctorDispatcher1
605 * @brief Call a function object.
607 * @param[in] callback The callback information.
608 * @param[in] param1 The first parameter to pass to the real member function.
610 static void Dispatch( CallbackBase& callback, P1 param1 )
612 // "downcast" the object and function type back to the correct ones
613 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
619 * @brief Dispatcher to call a functor.
621 template< class T, typename P1, typename P2 >
622 struct FunctorDispatcher2
625 * @brief Call a function object.
627 * @param[in] callback The callback information.
628 * @param[in] param1 The first parameter to pass to the real member function.
629 * @param[in] param2 The second parameter to pass to the real member function.
631 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
633 // "downcast" the object and function type back to the correct ones
634 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
635 (*object)( param1, param2 );
640 * @brief Dispatcher to call a functor.
642 template< class T, typename P1, typename P2, typename P3 >
643 struct FunctorDispatcher3
646 * @brief Call a function object.
648 * @param[in] callback The callback information.
649 * @param[in] param1 The first parameter to pass to the real member function.
650 * @param[in] param2 The second parameter to pass to the real member function.
651 * @param[in] param3 The third parameter to pass to the real member function.
653 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
655 // "downcast" the object and function type back to the correct ones
656 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
657 (*object)( param1, param2, param3 );
662 * @brief Dispatcher to call a functor.
664 template< class T, typename R >
665 struct FunctorDispatcherReturn0
668 * @brief Call a function object.
670 * @param[in] callback The callback information.
673 static R Dispatch( CallbackBase& callback )
675 // "downcast" the object and function type back to the correct ones
676 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
682 * @brief Dispatcher to call a functor.
684 template< class T, typename R, typename P1 >
685 struct FunctorDispatcherReturn1
688 * @brief Call a function object.
690 * @param[in] callback The callback information.
691 * @param[in] param1 The first parameter to pass to the real member function.
692 * @return The return value from the function
694 static R Dispatch( CallbackBase& callback, P1 param1 )
696 // "downcast" the object and function type back to the correct ones
697 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
698 return (*object)( param1 );
703 * @brief Dispatcher to call a functor.
705 template< class T, typename R, typename P1, typename P2 >
706 struct FunctorDispatcherReturn2
709 * @brief Call a function object.
711 * @param[in] callback The callback information.
712 * @param[in] param1 The first parameter to pass to the real member function.
713 * @param[in] param2 The second parameter to pass to the real member function.
714 * @return The return value from the function
716 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
718 // "downcast" the object and function type back to the correct ones
719 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
720 return (*object)( param1, param2 );
725 * @brief Dispatcher to call a functor.
727 template< class T, typename R, typename P1, typename P2, typename P3 >
728 struct FunctorDispatcherReturn3
731 * @brief Call a function object.
733 * @param[in] callback The callback information.
734 * @param[in] param1 The first parameter to pass to the real member function.
735 * @param[in] param2 The second parameter to pass to the real member function.
736 * @param[in] param3 The third parameter to pass to the real member function.
737 * @return The return value from the function
739 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
741 // "downcast" the object and function type back to the correct ones
742 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
743 return (*object)( param1, param2, param3 );
748 * @brief Dispatcher to call a functor.
749 * This variant calls a specific void() member function.
752 struct VoidFunctorDispatcher0
755 * @brief Call a function object.
757 * @param[in] callback The callback information.
759 static void Dispatch( CallbackBase& callback )
761 // "downcast" the object and function type back to the correct ones
762 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
763 typedef void(T::*MemberFunction)(void);
764 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
765 (object->*function)();
770 * @brief Dispatcher to call a functor.
772 * This variant calls a void() member, ignoring any signal parameters
774 template< class T, typename P1 >
775 struct VoidFunctorDispatcher1
778 * @brief Call a function object.
780 * @param[in] callback The callback information.
781 * @param[in] param1 The first parameter to pass to the real member function.
783 static void Dispatch( CallbackBase& callback, P1 param1 )
785 // "downcast" the object and function type back to the correct ones
786 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
787 typedef void(T::*MemberFunction)(void);
788 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
789 (object->*function)(/*ignore params*/);
794 * @brief Dispatcher to call a functor.
796 * This variant calls a void() member, ignoring any signal parameters
798 template< class T, typename P1, typename P2 >
799 struct VoidFunctorDispatcher2
802 * @brief Call a function object.
804 * @param[in] callback The callback information.
805 * @param[in] param1 The first parameter to pass to the real member function.
806 * @param[in] param2 The second parameter to pass to the real member function.
808 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
810 // "downcast" the object and function type back to the correct ones
811 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
812 typedef void(T::*MemberFunction)(void);
813 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
814 (object->*function)(/*ignore params*/);
819 * @brief Dispatcher to call a functor.
821 * This variant calls a void() member, ignoring any signal parameters
823 template< class T, typename P1, typename P2, typename P3 >
824 struct VoidFunctorDispatcher3
827 * @brief Call a function object.
829 * @param[in] callback The callback information.
830 * @param[in] param1 The first parameter to pass to the real member function.
831 * @param[in] param2 The second parameter to pass to the real member function.
832 * @param[in] param3 The third parameter to pass to the real member function.
834 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
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)(/*ignore params*/);
845 * @brief Dispatcher to call a functor.
847 * This variant calls a void() member, and returns a default-constructed value
849 template< class T, typename R >
850 struct VoidFunctorDispatcherReturn0
853 * @brief Call a function object.
855 * @param[in] callback The callback information.
858 static R Dispatch( CallbackBase& callback )
860 // "downcast" the object and function type back to the correct ones
861 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
862 typedef void(T::*MemberFunction)(void);
863 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
864 (object->*function)(/*ignore params*/);
870 * @brief Dispatcher to call a functor.
872 * This variant calls a void() member, and returns a default-constructed value
874 template< class T, typename R, typename P1 >
875 struct VoidFunctorDispatcherReturn1
878 * @brief Call a function object.
880 * @param[in] callback The callback information.
881 * @param[in] param1 The first parameter to pass to the real member function.
882 * @return The return value from the function
884 static R Dispatch( CallbackBase& callback, P1 param1 )
886 // "downcast" the object and function type back to the correct ones
887 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
888 typedef void(T::*MemberFunction)(void);
889 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
890 (object->*function)(/*ignore params*/);
896 * @brief Dispatcher to call a functor.
898 * This variant calls a void() member, and returns a default-constructed value
900 template< class T, typename R, typename P1, typename P2 >
901 struct VoidFunctorDispatcherReturn2
904 * @brief Call a function object.
906 * @param[in] callback The callback information.
907 * @param[in] param1 The first parameter to pass to the real member function.
908 * @param[in] param2 The second parameter to pass to the real member function.
909 * @return The return value from the function
911 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
913 // "downcast" the object and function type back to the correct ones
914 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
915 typedef void(T::*MemberFunction)(void);
916 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
917 (object->*function)(/*ignore params*/);
923 * @brief Dispatcher to call a functor.
925 * This variant calls a void() member, and returns a default-constructed value
927 template< class T, typename R, typename P1, typename P2, typename P3 >
928 struct VoidFunctorDispatcherReturn3
931 * @brief Call a function object.
933 * @param[in] callback The callback information.
934 * @param[in] param1 The first parameter to pass to the real member function.
935 * @param[in] param2 The second parameter to pass to the real member function.
936 * @param[in] param3 The third parameter to pass to the real member function.
937 * @return The return value from the function
939 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
941 // "downcast" the object and function type back to the correct ones
942 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
943 typedef void(T::*MemberFunction)(void);
944 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
945 (object->*function)(/*ignore params*/);
951 * @brief Thin template to provide type safety for member function callbacks.
953 * version with two parameters and return value
956 class Callback : public CallbackBase
961 * @brief Default constructor.
970 * @brief Constructor for member function.
972 * Copies the function object.
973 * @param[in] object The object to call.
974 * @param[in] memberFunction The member function of the object.
976 Callback( T* object, void(T::*memberFunction)(void) )
977 : CallbackBase( object,
978 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
979 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
980 template< typename P1 >
981 Callback( T* object, void(T::*memberFunction)(P1) )
982 : CallbackBase( object,
983 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
984 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
985 template< typename P1, typename P2 >
986 Callback( T* object, void(T::*memberFunction)(P1, P2) )
987 : CallbackBase( object,
988 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
989 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
990 template< typename P1, typename P2, typename P3 >
991 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
992 : CallbackBase( object,
993 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
994 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
995 template< typename R >
996 Callback( T* object, R(T::*memberFunction)(void) )
997 : CallbackBase( object,
998 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
999 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1000 template< typename R, typename P1 >
1001 Callback( T* object, R(T::*memberFunction)(P1) )
1002 : CallbackBase( object,
1003 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1004 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1005 template< typename R, typename P1, typename P2 >
1006 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1007 : CallbackBase( object,
1008 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1009 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1010 template< typename R, typename P1, typename P2, typename P3 >
1011 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1012 : CallbackBase( object,
1013 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1014 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1019 * @brief Specializations for static function callbacks.
1021 class CallbackFunction : public CallbackBase
1026 * @brief Default constructor.
1034 * @brief Constructors for functions with static linkage.
1036 * @param[in] function The function to call.
1038 CallbackFunction( void(*function)() )
1039 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1041 template< typename R >
1042 CallbackFunction( R(*function)() )
1043 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1045 template< typename P1 >
1046 CallbackFunction( void(*function)(P1) )
1047 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1049 template< typename P1, typename R >
1050 CallbackFunction( R(*function)(P1) )
1051 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1053 template< typename P1, typename P2 >
1054 CallbackFunction( void(*function)(P1,P2) )
1055 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1057 template< typename P1, typename P2, typename R >
1058 CallbackFunction( R(*function)(P1,P2) )
1059 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1061 template< typename P1, typename P2, typename P3 >
1062 CallbackFunction( void(*function)(P1,P2,P3) )
1063 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1065 template< typename P1, typename P2, typename P3, typename R >
1066 CallbackFunction( R(*function)(P1,P2,P3) )
1067 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1073 * @brief Specializations for function object callbacks.
1076 class CallbackFunctor0 : public CallbackBase
1081 * @brief Constructor which copies a function object.
1083 * @param[in] object The object to copy.
1085 CallbackFunctor0( const T& object )
1086 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1087 NULL, // uses operator() instead of member function
1088 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1089 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1093 * @brief Function object callback for connecting void() methods
1095 class CallbackFunctorDelegate0 : public CallbackBase
1100 * @brief Constructor which copies a function object.
1102 * This variant calls a void() member, ignoring any signal parameters.
1103 * @param[in] object A newly allocated object (ownership is transferred).
1105 CallbackFunctorDelegate0( FunctorDelegate* object )
1106 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1107 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1108 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1109 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1113 * @brief Function object callback for matching callbacks to signal signature.
1115 template< class T, typename P1 >
1116 class CallbackFunctor1 : public CallbackBase
1121 * @brief Constructor which copies a function object.
1123 * @param[in] object The object to copy.
1125 CallbackFunctor1( const T& object )
1126 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1127 NULL, // uses operator() instead of member function
1128 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1129 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1133 * @brief Function object callback for connecting void() methods.
1135 template< typename P1 >
1136 class CallbackFunctorDelegate1 : public CallbackBase
1141 * @brief Constructor which copies a function object.
1143 * This variant calls a void() member, ignoring any signal parameters.
1144 * @param[in] object The object to copy.
1146 CallbackFunctorDelegate1( FunctorDelegate* object )
1147 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1148 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1149 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1150 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1154 * @brief Function object callback for matching callbacks to signal signature
1156 template< class T, typename P1, typename P2 >
1157 class CallbackFunctor2 : public CallbackBase
1162 * @brief Constructor which copies a function object.
1164 * @param[in] object The object to copy.
1166 CallbackFunctor2( const T& object )
1167 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1168 NULL, // uses operator() instead of member function
1169 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1170 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1174 * @brief Function object callback for connecting void() methods
1176 template< typename P1, typename P2 >
1177 class CallbackFunctorDelegate2 : public CallbackBase
1182 * @brief Constructor which copies a function object.
1184 * This variant calls a void() member, ignoring any signal parameters.
1185 * @param[in] object The object to copy.
1187 CallbackFunctorDelegate2( FunctorDelegate* object )
1188 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1189 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1190 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1191 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1195 * @brief Function object callback for matching callbacks to signal signature
1197 template< class T, typename P1, typename P2, typename P3 >
1198 class CallbackFunctor3 : public CallbackBase
1203 * @brief Constructor which copies a function object.
1205 * @param[in] object The object to copy.
1207 CallbackFunctor3( const T& object )
1208 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1209 NULL, // uses operator() instead of member function
1210 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1211 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1215 * @brief Function object callback for connecting void() methods
1217 template< typename P1, typename P2, typename P3 >
1218 class CallbackFunctorDelegate3 : public CallbackBase
1224 * @brief Constructor which copies a function object.
1226 * This variant calls a void() member, ignoring any signal parameters.
1227 * @param[in] object The object to copy.
1229 CallbackFunctorDelegate3( FunctorDelegate* object )
1230 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1231 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1232 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1233 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1237 * @brief Function object callback for matching callbacks to signal signature
1239 template< class T, typename R >
1240 class CallbackFunctorReturn0 : public CallbackBase
1245 * @brief Constructor which copies a function object.
1247 * @param[in] object The object to copy.
1249 CallbackFunctorReturn0( const T& object )
1250 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1251 NULL, // uses operator() instead of member function
1252 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1253 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1257 * @brief Function object callback for connecting void() methods
1259 template< typename R >
1260 class CallbackFunctorDelegateReturn0 : public CallbackBase
1265 * @brief Constructor which copies a function object.
1267 * This variant calls a void() member, ignoring any signal parameters.
1268 * @param[in] object The object to copy.
1270 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1271 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1272 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1273 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1274 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1278 * @brief Function object callback for matching callbacks to signal signature
1280 template< class T, typename P1, typename R >
1281 class CallbackFunctorReturn1 : public CallbackBase
1286 * @brief Constructor which copies a function object.
1288 * @param[in] object The object to copy.
1290 CallbackFunctorReturn1( const T& object )
1291 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1292 NULL, // uses operator() instead of member function
1293 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1294 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1298 * @brief Function object callback for connecting void() methods
1300 template< typename P1, typename R >
1301 class CallbackFunctorDelegateReturn1 : public CallbackBase
1306 * @brief Constructor which copies a function object.
1308 * This variant calls a void() member, ignoring any signal parameters.
1309 * @param[in] object The object to copy.
1311 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1312 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1313 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1314 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1315 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1319 * @brief Function object callback for matching callbacks to signal signature
1321 template< class T, typename P1, typename P2, typename R >
1322 class CallbackFunctorReturn2 : public CallbackBase
1327 * @brief Constructor which copies a function object.
1329 * @param[in] object The object to copy.
1331 CallbackFunctorReturn2( const T& object )
1332 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1333 NULL, // uses operator() instead of member function
1334 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1335 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1339 * @brief Function object callback for connecting void() methods
1341 template< typename P1, typename P2, typename R >
1342 class CallbackFunctorDelegateReturn2 : public CallbackBase
1347 * @brief Constructor which copies a function object.
1349 * This variant calls a void() member, ignoring any signal parameters.
1350 * @param[in] object The object to copy.
1352 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1353 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1354 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1355 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1356 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1360 * @brief Function object callback for matching callbacks to signal signature
1362 template< class T, typename P1, typename P2, typename P3, typename R >
1363 class CallbackFunctorReturn3 : public CallbackBase
1368 * @brief Constructor which copies a function object.
1370 * @param[in] object The object to copy.
1372 CallbackFunctorReturn3( const T& object )
1373 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1374 NULL, // uses operator() instead of member function
1375 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1376 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1380 * @brief Function object callback for connecting void() methods
1382 template< typename P1, typename P2, typename P3, typename R >
1383 class CallbackFunctorDelegateReturn3 : public CallbackBase
1388 * @brief Constructor which copies a function object.
1390 * This variant calls a void() member, ignoring any signal parameters.
1391 * @param[in] object The object to copy.
1393 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1394 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1395 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1396 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1397 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1400 // Callback creation thin templates
1403 * @brief Creates a callback from a C function or static member function with no parameters.
1405 * @param[in] function The function to call.
1406 * @return a newly allocated Callback object, ownership transferred to caller
1408 inline CallbackBase* MakeCallback( void(*function)(void) )
1410 return new CallbackFunction( function );
1414 * @brief Creates a callback from a C function or static member function with one parameter.
1416 * @param[in] function The function to call.
1417 * @return a newly allocated Callback object, ownership transferred to caller
1419 template< typename P1 >
1420 inline CallbackBase* MakeCallback( void(*function)(P1) )
1422 return new CallbackFunction( function );
1426 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1428 * @param[in] function The function to call.
1429 * @return a newly allocated Callback object, ownership transferred to caller
1431 template< typename R >
1432 inline CallbackBase* MakeCallback( R(*function)(void) )
1434 return new CallbackFunction( function );
1438 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1440 * @param[in] function The function to call.
1441 * @return a newly allocated Callback object, ownership transferred to caller
1443 template< typename R, typename P1 >
1444 inline CallbackBase* MakeCallback( R(*function)(P1) )
1446 return new CallbackFunction( function );
1450 * @brief Creates a callback from a C function or static member function with two parameters.
1452 * @param[in] function The function to call.
1453 * @return a newly allocated Callback object, ownership transferred to caller
1455 template< typename P1, typename P2 >
1456 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1458 return new CallbackFunction( function );
1462 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1464 * @param[in] function The function to call.
1465 * @return a newly allocated Callback object, ownership transferred to caller
1467 template< typename R, typename P1, typename P2 >
1468 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1470 return new CallbackFunction( function );
1474 * @brief Creates a callback from a C function or static member function with three parameters.
1476 * @param[in] function The function to call.
1477 * @return a newly allocated Callback object, ownership transferred to caller
1479 template< typename P1, typename P2, typename P3 >
1480 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1482 return new CallbackFunction( function );
1486 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1488 * @param[in] function The function to call.
1489 * @return a newly allocated Callback object, ownership transferred to caller
1491 template< typename R, typename P1, typename P2, typename P3 >
1492 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1494 return new CallbackFunction( function );
1498 * @brief Creates a callback from a class member function with no parameters.
1500 * requires the function to be member of the same class
1501 * @param[in] object The object to call.
1502 * @param[in] function The member function to call.
1503 * @return a newly allocated Callback object, ownership transferred to caller
1506 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1508 return new Callback< T >( object, function );
1512 * @brief Creates a callback from a class member function with one parameter.
1514 * requires the function to be member of the same class
1515 * @param[in] object The object to call.
1516 * @param[in] function The member function to call.
1517 * @return a newly allocated Callback object, ownership transferred to caller
1519 template< class T, typename P1 >
1520 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1522 return new Callback< T >( object, function );
1526 * @brief Creates a callback from a class member function with two parameters.
1528 * requires the function to be member of the same class
1529 * @param[in] object The object to call.
1530 * @param[in] function The member function to call.
1531 * @return a newly allocated Callback object, ownership transferred to caller
1533 template< class T, typename P1, typename P2 >
1534 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1536 return new Callback< T >( object, function );
1540 * @brief Creates a callback from a class member function with three parameters.
1542 * requires the function to be member of the same class
1543 * @param[in] object The object to call.
1544 * @param[in] function The member function to call.
1545 * @return a newly allocated Callback object, ownership transferred to caller
1547 template< class T, typename P1, typename P2, typename P3 >
1548 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1550 return new Callback< T >( object, function );
1554 * @brief Creates a callback from a class member function with no parameters and a return type.
1556 * requires the function to be member of the same class
1557 * @param[in] object The object to call.
1558 * @param[in] function The member function to call.
1559 * @return a newly allocated Callback object, ownership transferred to caller
1561 template< class T, typename R >
1562 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1564 return new Callback< T >( object, function );
1568 * @brief Creates a callback from a class member function with one parameter and a return type.
1570 * requires the function to be member of the same class
1571 * @param[in] object The object to call.
1572 * @param[in] function The member function to call.
1573 * @return a newly allocated Callback object, ownership transferred to caller
1575 template< class T, typename P1, typename R >
1576 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1578 return new Callback< T >( object, function );
1582 * @brief Creates a callback from a class member function with two parameters and a return type.
1584 * requires the function to be member of the same class
1585 * @param[in] object The object to call.
1586 * @param[in] function The member function to call.
1587 * @return a newly allocated Callback object, ownership transferred to caller
1589 template< class T, typename P1, typename P2, typename R >
1590 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1592 return new Callback< T >( object, function );
1596 * @brief Creates a callback from a class member function with three parameters and a return type.
1598 * requires the function to be member of the same class
1599 * @param[in] object The object to call.
1600 * @param[in] function The member function to call.
1601 * @return a newly allocated Callback object, ownership transferred to caller
1603 template< class T, typename P1, typename P2, typename P3, typename R >
1604 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1606 return new Callback< T >( object, function );
1610 * @brief Creates a callback from a class's parent member function with no parameters.
1612 * requires the function to be member of the same class
1613 * @param[in] object The object to call.
1614 * @param[in] function The member function to call.
1615 * @return a newly allocated Callback object, ownership transferred to caller
1617 template< class T, class Base >
1618 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1620 return new Callback< T >( object, function );
1623 * @brief Creates a callback from a class's parent member function with no parameters.
1625 * requires the function to be member of the same class
1626 * @param[in] object The object to call.
1627 * @param[in] function The member function to call.
1628 * @return a newly allocated Callback object, ownership transferred to caller
1630 template< class T, class Base >
1631 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1633 return new Callback< T >( object, function );
1638 #endif // __DALI_CALLBACK_H__