1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/functor-delegate.h>
29 #define STDCALL __stdcall
37 * @addtogroup dali_core_signals
44 * @brief Callback base class to hold the data for callback function and member function calls.
47 class DALI_CORE_API CallbackBase
52 * @brief Default constructor.
64 * @brief Resets the object pointer so that we know not to call methods of this object any more.
70 * @brief Function to call the function or member function dispatcher.
73 * @param[in] callback The callback to call
75 static void Execute( CallbackBase& callback )
77 // if we point to a function, we can call it directly
78 // otherwise call the dispatcher function that knows the real type of the object
79 // Note that this template dispatcher lives in client code so the library containing
80 // the code has to be loaded, otherwise we crash boom bang
81 if( callback.mImpl && callback.mImpl->mObjectPointer )
83 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
84 (*dispatcher)( callback );
86 // its also possible to have a member function pointer to a CallbackProvider
87 // that has been deleted, so check if we have impl still
88 else if( !callback.mImpl && callback.mFunction )
90 (*(callback.mFunction))();
94 DALI_ASSERT_ALWAYS( 0 && "no function to execute" );
99 * @brief Function to call the function or member function dispatcher.
102 * @param[in] callback The callback to call
103 * @return The value from the function
105 template< typename R >
106 static R ExecuteReturn( CallbackBase& callback )
109 // if we point to a function, we can call it directly
110 // otherwise call the dispatcher function that knows the real type of the object
111 // Note that this template dispatcher lives in client code so the library containing
112 // the code has to be loaded, otherwise we crash boom bang
113 if( callback.mImpl && callback.mImpl->mObjectPointer )
115 typedef R(*Dispatcher)(CallbackBase& base);
116 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
117 returnVal = (*dispatcher)( callback );
119 else if( !callback.mImpl && callback.mFunction )
121 typedef R(STDCALL *Function1)();
122 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
129 * @brief Function to call the function or member function dispatcher.
131 * This function template gets instantiated at the call site.
133 * @param[in] callback The callback to call
134 * @param[in] param1 The first parameter to pass into the function
136 template< typename P1 >
137 static void Execute( CallbackBase& callback, P1 param1 )
139 // if we point to a function, we can call it directly
140 // otherwise call the dispatcher function that knows the real type of the object
141 // Note that this template dispatcher lives in client code (where the callback was created)
142 // so the library containing the code has to be loaded, otherwise we crash boom bang
143 if( callback.mImpl && callback.mImpl->mObjectPointer )
145 typedef void(*Dispatcher)(CallbackBase& base,P1);
146 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
147 (*dispatcher)( callback, param1 );
149 else if( !callback.mImpl && callback.mFunction )
151 // convert function type
152 typedef void(STDCALL *Function1)(P1);
153 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
158 * @brief Function to call the function or member function dispatcher.
160 * This function template gets instantiated at the call site.
162 * @param[in] callback The callback to call
163 * @param[in] param1 The first parameter to pass into the function
164 * @return The value from the function
166 template< typename R, typename P1 >
167 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
170 // if we point to a function, we can call it directly
171 // otherwise call the dispatcher function that knows the real type of the object
172 // Note that this template dispatcher lives in client code (where the callback was created)
173 // so the library containing the code has to be loaded, otherwise we crash boom bang
174 if( callback.mImpl && callback.mImpl->mObjectPointer )
176 typedef R(*Dispatcher)(CallbackBase& base,P1);
177 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
178 returnVal = (*dispatcher)( callback, param1 );
180 else if( !callback.mImpl && callback.mFunction )
182 // convert function type
183 typedef R(STDCALL *Function1)(P1);
184 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
191 * @brief Function to call the function or member function dispatcher.
193 * This function template gets instantiated at the call site.
195 * @param[in] callback The callback to call
196 * @param[in] param1 The first parameter to pass into the function
197 * @param[in] param2 The second parameter to pass into the function
199 template< typename P1, typename P2 >
200 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
202 // if we point to a function, we can call it directly
203 // otherwise call the dispatcher function that knows the real type of the object
204 // Note that this template dispatcher lives in client code (where the callback was created)
205 // so the library containing the code has to be loaded, otherwise we crash boom bang
206 if( callback.mImpl && callback.mImpl->mObjectPointer )
208 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
209 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
210 (*dispatcher)( callback, param1, param2 );
212 else if( !callback.mImpl && callback.mFunction )
214 // convert function type
215 typedef void(STDCALL *Function2)(P1,P2);
216 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
221 * @brief Function to call the function or member function dispatcher.
223 * This function template gets instantiated at the call site.
225 * @param[in] callback The callback to call
226 * @param[in] param1 The first parameter to pass into the function
227 * @param[in] param2 The second parameter to pass into the function
228 * @return The return value from the function
230 template< typename R, typename P1, typename P2 >
231 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
234 // if we point to a function, we can call it directly
235 // otherwise call the dispatcher function that knows the real type of the object
236 // Note that this template dispatcher lives in client code (where the callback was created)
237 // so the library containing the code has to be loaded, otherwise we crash boom bang
238 if( callback.mImpl && callback.mImpl->mObjectPointer )
240 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
241 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
242 returnVal = (*dispatcher)( callback, param1, param2 );
244 else if( !callback.mImpl && callback.mFunction )
246 // convert function type
247 typedef R(STDCALL *Function2)(P1,P2);
248 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
255 * @brief Function to call the function or member function dispatcher.
257 * This function template gets instantiated at the call site.
259 * @param[in] callback The callback to call
260 * @param[in] param1 The first parameter to pass into the function
261 * @param[in] param2 The second parameter to pass into the function
262 * @param[in] param3 The third parameter to pass into the function
264 template< typename P1, typename P2, typename P3 >
265 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
267 // if we point to a function, we can call it directly
268 // otherwise call the dispatcher function that knows the real type of the object
269 // Note that this template dispatcher lives in client code (where the callback was created)
270 // so the library containing the code has to be loaded, otherwise we crash boom bang
271 if( callback.mImpl && callback.mImpl->mObjectPointer )
273 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
274 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
275 (*dispatcher)( callback, param1, param2, param3 );
277 else if( !callback.mImpl && callback.mFunction )
279 // convert function type
280 typedef void(STDCALL *Function2)(P1,P2,P3);
281 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
286 * @brief Function to call the function or member function dispatcher.
288 * This function template gets instantiated at the call site.
290 * @param[in] callback The callback to call
291 * @param[in] param1 The first parameter to pass into the function
292 * @param[in] param2 The second parameter to pass into the function
293 * @param[in] param3 The third parameter to pass into the function
294 * @return The return value from the function
296 template< typename R, typename P1, typename P2, typename P3 >
297 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
300 // if we point to a function, we can call it directly
301 // otherwise call the dispatcher function that knows the real type of the object
302 // Note that this template dispatcher lives in client code (where the callback was created)
303 // so the library containing the code has to be loaded, otherwise we crash boom bang
304 if( callback.mImpl && callback.mImpl->mObjectPointer )
306 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
307 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
308 returnVal = (*dispatcher)( callback, param1, param2, param3 );
310 else if( !callback.mImpl && callback.mFunction )
312 // convert function type
313 typedef R(STDCALL *Function2)(P1,P2,P3);
314 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
320 protected: // Constructors for deriving classes
323 * @brief Function with static linkage.
326 typedef void(STDCALL *Function)(void);
329 * @brief Member function.
332 typedef void (STDCALL CallbackBase::*MemberFunction)( void );
335 * @brief Used to call the correct member function.
338 typedef void (*Dispatcher)( CallbackBase& base );
341 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned).
344 typedef void(*Destructor)(void* object);
347 * @brief Copy constructor operator not declared.
349 * @param[in] rhs Handle to an object
351 CallbackBase( const CallbackBase& rhs );
354 * @brief Assignment operator not declared.
356 * @param[in] rhs Handle to an object
357 * @return A reference to this
359 CallbackBase& operator=( const CallbackBase& rhs );
362 * @brief Constructor for function with static linkage.
365 * @param[in] function The function to call
367 CallbackBase( Function function );
370 * @brief Constructor for member function.
373 * @param[in] object The object to call (not owned)
374 * @param[in] function The member function of the object
375 * @param[in] dispatcher Used to call the actual object
377 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
380 * @brief Constructor for member function.
383 * @param[in] object The object to call (owned)
384 * @param[in] function The member function of the object
385 * @param dispatcher Used to call the actual object
386 * @param destructor Used to delete the owned object
388 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
390 public: // Data for deriving classes & Dispatchers
393 * @brief Struct to hold the extra data needed for member functions.
398 Impl(); ///< Default constructor @SINCE_1_0.0
400 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
401 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
402 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
404 Impl* mImpl; ///< Implementation pointer
408 MemberFunction mMemberFunction; ///< Pointer to member function
409 Function mFunction; ///< Static function
414 * @brief Non-member equality operator.
416 * @param[in] lhs A reference to compare
417 * @param[in] rhs A reference to compare to
418 * @return True if lhs is same as rhs
420 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
423 * @brief Dispatcher to delete an object.
430 * @brief Dispatcher to delete an object.
432 * @param[in] object An object to delete
434 static void Delete( void* object )
436 // CallbackBase owns the object but we're the only one who knows the real type so need
437 // to delete by "downcasting" from void* to the correct type
438 delete reinterpret_cast< T* >( object );
443 * @brief Dispatcher to call the actual member function.
450 * @brief Calls an actual member function.
453 * @param[in] callback The callback information
455 static void Dispatch( CallbackBase& callback )
457 // "downcast" the object and function type back to the correct ones
458 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
459 typedef void(T::*MemberFunction)(void);
460 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
461 (object->*function)();
466 * @brief Dispatcher to call the actual member function.
469 template< class T, typename P1 >
473 * @brief Calls an actual member function.
476 * @param[in] callback The callback information
477 * @param[in] param1 The first parameter to pass to the real member function
479 static void Dispatch( CallbackBase& callback, P1 param1 )
481 // "downcast" the object and function type back to the correct ones
482 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
483 typedef void(T::*MemberFunction)(P1);
484 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
485 (object->*function)( param1 );
490 * @brief Dispatcher to call the actual member function.
493 template< class T, typename P1, typename P2 >
497 * @brief Call an actual member function.
500 * @param[in] callback The callback information
501 * @param[in] param1 The first parameter to pass to the real member function
502 * @param[in] param2 The second parameter to pass to the real member function
504 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
506 // "downcast" the object and function type back to the correct ones
507 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
508 typedef void(T::*MemberFunction)(P1, P2);
509 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
510 (object->*function)( param1, param2 );
515 * @brief Dispatcher to call the actual member function.
518 template< class T, typename P1, typename P2, typename P3 >
522 * @brief Call an actual member function.
525 * @param[in] callback The callback information
526 * @param[in] param1 The first parameter to pass to the real member function
527 * @param[in] param2 The second parameter to pass to the real member function
528 * @param[in] param3 The third parameter to pass to the real member function
530 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
532 // "downcast" the object and function type back to the correct ones
533 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
534 typedef void(T::*MemberFunction)(P1, P2, P3);
535 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
536 (object->*function)( param1, param2, param3 );
541 * @brief Dispatcher to call the actual member function.
544 template< class T, typename R >
545 struct DispatcherReturn0
548 * @brief Calls an actual member function.
551 * @param[in] callback The callback information
554 static R Dispatch( CallbackBase& callback )
556 // "downcast" the object and function type back to the correct ones
557 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
558 typedef R(T::*MemberFunction)(void);
559 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
560 return (object->*function)();
565 * @brief Dispatcher to call the actual member function.
568 template< class T, typename R, typename P1 >
569 struct DispatcherReturn1
572 * @brief Calls an actual member function.
575 * @param[in] callback The callback information
576 * @param[in] param1 The first parameter to pass to the real member function
577 * @return The return value from the function
579 static R Dispatch( CallbackBase& callback, P1 param1 )
581 // "downcast" the object and function type back to the correct ones
582 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
583 typedef R(T::*MemberFunction)(P1);
584 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
585 return (object->*function)( param1 );
590 * @brief Dispatcher to call the actual member function.
593 template< class T, typename R, typename P1, typename P2 >
594 struct DispatcherReturn2
597 * @brief Calls an actual member function.
600 * @param[in] callback The callback information
601 * @param[in] param1 The first parameter to pass to the real member function
602 * @param[in] param2 The second parameter to pass to the real member function
603 * @return The return value from the function
605 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
607 // "downcast" the object and function type back to the correct ones
608 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
609 typedef R(T::*MemberFunction)(P1, P2);
610 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
611 return (object->*function)( param1, param2 );
616 * @brief Dispatcher to call the actual member function.
619 template< class T, typename R, typename P1, typename P2, typename P3 >
620 struct DispatcherReturn3
623 * @brief Calls an actual member function.
626 * @param[in] callback The callback information
627 * @param[in] param1 The first parameter to pass to the real member function
628 * @param[in] param2 The second parameter to pass to the real member function
629 * @param[in] param3 The third parameter to pass to the real member function
630 * @return The return value from the function
632 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
634 // "downcast" the object and function type back to the correct ones
635 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
636 typedef R(T::*MemberFunction)(P1, P2, P3);
637 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
638 return (object->*function)( param1, param2, param3 );
643 * @brief Dispatcher to call a functor.
647 struct FunctorDispatcher0
650 * @brief Calls a function object.
653 * @param[in] callback The callback information
655 static void Dispatch( CallbackBase& callback )
657 // "downcast" the object and function type back to the correct ones
658 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
664 * @brief Dispatcher to call a functor.
667 template< class T, typename P1 >
668 struct FunctorDispatcher1
671 * @brief Calls a function object.
674 * @param[in] callback The callback information
675 * @param[in] param1 The first parameter to pass to the real member function.
677 static void Dispatch( CallbackBase& callback, P1 param1 )
679 // "downcast" the object and function type back to the correct ones
680 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
686 * @brief Dispatcher to call a functor.
689 template< class T, typename P1, typename P2 >
690 struct FunctorDispatcher2
693 * @brief Calls a function object.
696 * @param[in] callback The callback information
697 * @param[in] param1 The first parameter to pass to the real member function
698 * @param[in] param2 The second parameter to pass to the real member function
700 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
702 // "downcast" the object and function type back to the correct ones
703 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
704 (*object)( param1, param2 );
709 * @brief Dispatcher to call a functor.
712 template< class T, typename P1, typename P2, typename P3 >
713 struct FunctorDispatcher3
716 * @brief Calls a function object.
719 * @param[in] callback The callback information
720 * @param[in] param1 The first parameter to pass to the real member function
721 * @param[in] param2 The second parameter to pass to the real member function
722 * @param[in] param3 The third parameter to pass to the real member function
724 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
726 // "downcast" the object and function type back to the correct ones
727 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
728 (*object)( param1, param2, param3 );
733 * @brief Dispatcher to call a functor.
736 template< class T, typename R >
737 struct FunctorDispatcherReturn0
740 * @brief Calls a function object.
743 * @param[in] callback The callback information
746 static R Dispatch( CallbackBase& callback )
748 // "downcast" the object and function type back to the correct ones
749 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
755 * @brief Dispatcher to call a functor.
758 template< class T, typename R, typename P1 >
759 struct FunctorDispatcherReturn1
762 * @brief Calls a function object.
765 * @param[in] callback The callback information
766 * @param[in] param1 The first parameter to pass to the real member function
767 * @return The return value from the function
769 static R Dispatch( CallbackBase& callback, P1 param1 )
771 // "downcast" the object and function type back to the correct ones
772 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
773 return (*object)( param1 );
778 * @brief Dispatcher to call a functor.
781 template< class T, typename R, typename P1, typename P2 >
782 struct FunctorDispatcherReturn2
785 * @brief Calls a function object.
788 * @param[in] callback The callback information
789 * @param[in] param1 The first parameter to pass to the real member function
790 * @param[in] param2 The second parameter to pass to the real member function
791 * @return The return value from the function
793 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
795 // "downcast" the object and function type back to the correct ones
796 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
797 return (*object)( param1, param2 );
802 * @brief Dispatcher to call a functor.
805 template< class T, typename R, typename P1, typename P2, typename P3 >
806 struct FunctorDispatcherReturn3
809 * @brief Calls a function object.
812 * @param[in] callback The callback information
813 * @param[in] param1 The first parameter to pass to the real member function
814 * @param[in] param2 The second parameter to pass to the real member function
815 * @param[in] param3 The third parameter to pass to the real member function
816 * @return The return value from the function
818 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
820 // "downcast" the object and function type back to the correct ones
821 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
822 return (*object)( param1, param2, param3 );
827 * @brief Dispatcher to call a functor.
829 * This variant calls a specific void() member function.
833 struct VoidFunctorDispatcher0
836 * @brief Calls a function object.
839 * @param[in] callback The callback information
841 static void Dispatch( CallbackBase& callback )
843 // "downcast" the object and function type back to the correct ones
844 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
845 typedef void(T::*MemberFunction)(void);
846 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
847 (object->*function)();
852 * @brief Dispatcher to call a functor.
854 * This variant calls a void() member, ignoring any signal parameters.
857 template< class T, typename P1 >
858 struct VoidFunctorDispatcher1
861 * @brief Calls a function object.
864 * @param[in] callback The callback information
865 * @param[in] param1 The first parameter to pass to the real member function
867 static void Dispatch( CallbackBase& callback, P1 param1 )
869 // "downcast" the object and function type back to the correct ones
870 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
871 typedef void(T::*MemberFunction)(void);
872 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
873 (object->*function)(/*ignore params*/);
878 * @brief Dispatcher to call a functor.
880 * This variant calls a void() member, ignoring any signal parameters.
883 template< class T, typename P1, typename P2 >
884 struct VoidFunctorDispatcher2
887 * @brief Calls a function object.
890 * @param[in] callback The callback information
891 * @param[in] param1 The first parameter to pass to the real member function
892 * @param[in] param2 The second parameter to pass to the real member function
894 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
896 // "downcast" the object and function type back to the correct ones
897 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
898 typedef void(T::*MemberFunction)(void);
899 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
900 (object->*function)(/*ignore params*/);
905 * @brief Dispatcher to call a functor.
907 * This variant calls a void() member, ignoring any signal parameters.
910 template< class T, typename P1, typename P2, typename P3 >
911 struct VoidFunctorDispatcher3
914 * @brief Calls a function object.
917 * @param[in] callback The callback information
918 * @param[in] param1 The first parameter to pass to the real member function
919 * @param[in] param2 The second parameter to pass to the real member function
920 * @param[in] param3 The third parameter to pass to the real member function
922 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
924 // "downcast" the object and function type back to the correct ones
925 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
926 typedef void(T::*MemberFunction)(void);
927 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
928 (object->*function)(/*ignore params*/);
933 * @brief Dispatcher to call a functor.
935 * This variant calls a void() member, and returns a default-constructed value.
938 template< class T, typename R >
939 struct VoidFunctorDispatcherReturn0
942 * @brief Calls a function object.
945 * @param[in] callback The callback information
948 static R Dispatch( CallbackBase& callback )
950 // "downcast" the object and function type back to the correct ones
951 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
952 typedef void(T::*MemberFunction)(void);
953 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
954 (object->*function)(/*ignore params*/);
960 * @brief Dispatcher to call a functor.
962 * This variant calls a void() member, and returns a default-constructed value.
965 template< class T, typename R, typename P1 >
966 struct VoidFunctorDispatcherReturn1
969 * @brief Calls a function object.
972 * @param[in] callback The callback information
973 * @param[in] param1 The first parameter to pass to the real member function
974 * @return The return value from the function
976 static R Dispatch( CallbackBase& callback, P1 param1 )
978 // "downcast" the object and function type back to the correct ones
979 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
980 typedef void(T::*MemberFunction)(void);
981 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
982 (object->*function)(/*ignore params*/);
988 * @brief Dispatcher to call a functor.
990 * This variant calls a void() member, and returns a default-constructed value.
993 template< class T, typename R, typename P1, typename P2 >
994 struct VoidFunctorDispatcherReturn2
997 * @brief Calls a function object.
1000 * @param[in] callback The callback information
1001 * @param[in] param1 The first parameter to pass to the real member function
1002 * @param[in] param2 The second parameter to pass to the real member function
1003 * @return The return value from the function
1005 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
1007 // "downcast" the object and function type back to the correct ones
1008 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1009 typedef void(T::*MemberFunction)(void);
1010 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1011 (object->*function)(/*ignore params*/);
1017 * @brief Dispatcher to call a functor.
1019 * This variant calls a void() member, and returns a default-constructed value.
1022 template< class T, typename R, typename P1, typename P2, typename P3 >
1023 struct VoidFunctorDispatcherReturn3
1026 * @brief Calls a function object.
1029 * @param[in] callback The callback information
1030 * @param[in] param1 The first parameter to pass to the real member function
1031 * @param[in] param2 The second parameter to pass to the real member function
1032 * @param[in] param3 The third parameter to pass to the real member function
1033 * @return The return value from the function
1035 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
1037 // "downcast" the object and function type back to the correct ones
1038 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
1039 typedef void(T::*MemberFunction)(void);
1040 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
1041 (object->*function)(/*ignore params*/);
1047 * @brief Thin template to provide type safety for member function callbacks.
1049 * Version with two parameters and return value.
1053 class Callback : public CallbackBase
1058 * @brief Default constructor.
1068 * @brief Constructor for member function.
1070 * Copies the function object.
1072 * @param[in] object The object to call
1073 * @param[in] memberFunction The member function of the object
1075 Callback( T* object, void(T::*memberFunction)(void) )
1076 : CallbackBase( object,
1077 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1078 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
1079 template< typename P1 >
1080 Callback( T* object, void(T::*memberFunction)(P1) )
1081 : CallbackBase( object,
1082 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1083 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
1084 template< typename P1, typename P2 >
1085 Callback( T* object, void(T::*memberFunction)(P1, P2) )
1086 : CallbackBase( object,
1087 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1088 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
1089 template< typename P1, typename P2, typename P3 >
1090 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
1091 : CallbackBase( object,
1092 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1093 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
1094 template< typename R >
1095 Callback( T* object, R(T::*memberFunction)(void) )
1096 : CallbackBase( object,
1097 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1098 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1099 template< typename R, typename P1 >
1100 Callback( T* object, R(T::*memberFunction)(P1) )
1101 : CallbackBase( object,
1102 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1103 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1104 template< typename R, typename P1, typename P2 >
1105 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1106 : CallbackBase( object,
1107 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1108 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1109 template< typename R, typename P1, typename P2, typename P3 >
1110 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1111 : CallbackBase( object,
1112 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1113 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1118 * @brief Specializations for static function callbacks.
1121 class CallbackFunction : public CallbackBase
1126 * @brief Default constructor.
1135 * @brief Constructors for functions with static linkage.
1138 * @param[in] function The function to call
1140 CallbackFunction( void(*function)() )
1141 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1143 template< typename R >
1144 CallbackFunction( R(*function)() )
1145 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1147 template< typename P1 >
1148 CallbackFunction( void(*function)(P1) )
1149 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1151 template< typename P1, typename R >
1152 CallbackFunction( R(*function)(P1) )
1153 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1155 template< typename P1, typename P2 >
1156 CallbackFunction( void(*function)(P1,P2) )
1157 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1159 template< typename P1, typename P2, typename R >
1160 CallbackFunction( R(*function)(P1,P2) )
1161 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1163 template< typename P1, typename P2, typename P3 >
1164 CallbackFunction( void(*function)(P1,P2,P3) )
1165 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1167 template< typename P1, typename P2, typename P3, typename R >
1168 CallbackFunction( R(*function)(P1,P2,P3) )
1169 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1175 * @brief Specializations for function object callbacks.
1179 class CallbackFunctor0 : public CallbackBase
1184 * @brief Constructor which copies a function object.
1187 * @param[in] object The object to copy
1189 CallbackFunctor0( const T& object )
1190 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1191 NULL, // uses operator() instead of member function
1192 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1193 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1197 * @brief Function object callback for connecting void() methods.
1200 class CallbackFunctorDelegate0 : public CallbackBase
1205 * @brief Constructor which copies a function object.
1207 * This variant calls a void() member, ignoring any signal parameters.
1209 * @param[in] object A newly allocated object (ownership is transferred)
1211 CallbackFunctorDelegate0( FunctorDelegate* object )
1212 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1213 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1214 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1215 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1219 * @brief Function object callback for matching callbacks to signal signature.
1222 template< class T, typename P1 >
1223 class CallbackFunctor1 : public CallbackBase
1228 * @brief Constructor which copies a function object.
1231 * @param[in] object The object to copy
1233 CallbackFunctor1( const T& object )
1234 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1235 NULL, // uses operator() instead of member function
1236 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1237 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1241 * @brief Function object callback for connecting void() methods.
1244 template< typename P1 >
1245 class CallbackFunctorDelegate1 : public CallbackBase
1250 * @brief Constructor which copies a function object.
1252 * This variant calls a void() member, ignoring any signal parameters.
1254 * @param[in] object The object to copy
1256 CallbackFunctorDelegate1( FunctorDelegate* object )
1257 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1258 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1259 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1260 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1264 * @brief Function object callback for matching callbacks to signal signature.
1267 template< class T, typename P1, typename P2 >
1268 class CallbackFunctor2 : public CallbackBase
1273 * @brief Constructor which copies a function object.
1276 * @param[in] object The object to copy
1278 CallbackFunctor2( const T& object )
1279 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1280 NULL, // uses operator() instead of member function
1281 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1282 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1286 * @brief Function object callback for connecting void() methods.
1289 template< typename P1, typename P2 >
1290 class CallbackFunctorDelegate2 : public CallbackBase
1295 * @brief Constructor which copies a function object.
1297 * This variant calls a void() member, ignoring any signal parameters.
1299 * @param[in] object The object to copy
1301 CallbackFunctorDelegate2( FunctorDelegate* object )
1302 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1303 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1304 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1305 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1309 * @brief Function object callback for matching callbacks to signal signature.
1312 template< class T, typename P1, typename P2, typename P3 >
1313 class CallbackFunctor3 : public CallbackBase
1318 * @brief Constructor which copies a function object.
1321 * @param[in] object The object to copy
1323 CallbackFunctor3( const T& object )
1324 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1325 NULL, // uses operator() instead of member function
1326 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1327 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1331 * @brief Function object callback for connecting void() methods.
1334 template< typename P1, typename P2, typename P3 >
1335 class CallbackFunctorDelegate3 : public CallbackBase
1341 * @brief Constructor which copies a function object.
1343 * This variant calls a void() member, ignoring any signal parameters.
1345 * @param[in] object The object to copy
1347 CallbackFunctorDelegate3( FunctorDelegate* object )
1348 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1349 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1350 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1351 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1355 * @brief Function object callback for matching callbacks to signal signature.
1358 template< class T, typename R >
1359 class CallbackFunctorReturn0 : public CallbackBase
1364 * @brief Constructor which copies a function object.
1367 * @param[in] object The object to copy
1369 CallbackFunctorReturn0( const T& object )
1370 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1371 NULL, // uses operator() instead of member function
1372 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1373 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1377 * @brief Function object callback for connecting void() methods.
1380 template< typename R >
1381 class CallbackFunctorDelegateReturn0 : public CallbackBase
1386 * @brief Constructor which copies a function object.
1388 * This variant calls a void() member, ignoring any signal parameters.
1390 * @param[in] object The object to copy
1392 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1393 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1394 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1395 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1396 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1400 * @brief Function object callback for matching callbacks to signal signature.
1403 template< class T, typename P1, typename R >
1404 class CallbackFunctorReturn1 : public CallbackBase
1409 * @brief Constructor which copies a function object.
1412 * @param[in] object The object to copy
1414 CallbackFunctorReturn1( const T& object )
1415 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1416 NULL, // uses operator() instead of member function
1417 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1418 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1422 * @brief Function object callback for connecting void() methods.
1425 template< typename P1, typename R >
1426 class CallbackFunctorDelegateReturn1 : public CallbackBase
1431 * @brief Constructor which copies a function object.
1433 * This variant calls a void() member, ignoring any signal parameters.
1435 * @param[in] object The object to copy
1437 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1438 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1439 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1440 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1441 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1445 * @brief Function object callback for matching callbacks to signal signature.
1448 template< class T, typename P1, typename P2, typename R >
1449 class CallbackFunctorReturn2 : public CallbackBase
1454 * @brief Constructor which copies a function object.
1457 * @param[in] object The object to copy
1459 CallbackFunctorReturn2( const T& object )
1460 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1461 NULL, // uses operator() instead of member function
1462 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1463 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1467 * @brief Function object callback for connecting void() methods.
1470 template< typename P1, typename P2, typename R >
1471 class CallbackFunctorDelegateReturn2 : public CallbackBase
1476 * @brief Constructor which copies a function object.
1478 * This variant calls a void() member, ignoring any signal parameters.
1480 * @param[in] object The object to copy
1482 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1483 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1484 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1485 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1486 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1490 * @brief Function object callback for matching callbacks to signal signature.
1493 template< class T, typename P1, typename P2, typename P3, typename R >
1494 class CallbackFunctorReturn3 : public CallbackBase
1499 * @brief Constructor which copies a function object.
1502 * @param[in] object The object to copy
1504 CallbackFunctorReturn3( const T& object )
1505 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1506 NULL, // uses operator() instead of member function
1507 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1508 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1512 * @brief Function object callback for connecting void() methods.
1515 template< typename P1, typename P2, typename P3, typename R >
1516 class CallbackFunctorDelegateReturn3 : public CallbackBase
1521 * @brief Constructor which copies a function object.
1523 * This variant calls a void() member, ignoring any signal parameters.
1525 * @param[in] object The object to copy
1527 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1528 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1529 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1530 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1531 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1534 // Callback creation thin templates
1537 * @brief Creates a callback from a C function or static member function with no parameters.
1540 * @param[in] function The function to call
1541 * @return A newly allocated Callback object, ownership transferred to caller
1543 inline CallbackBase* MakeCallback( void(*function)(void) )
1545 return new CallbackFunction( function );
1549 * @brief Creates a callback from a C function or static member function with one parameter.
1552 * @param[in] function The function to call
1553 * @return A newly allocated Callback object, ownership transferred to caller
1555 template< typename P1 >
1556 inline CallbackBase* MakeCallback( void(*function)(P1) )
1558 return new CallbackFunction( function );
1562 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1565 * @param[in] function The function to call
1566 * @return A newly allocated Callback object, ownership transferred to caller
1568 template< typename R >
1569 inline CallbackBase* MakeCallback( R(*function)(void) )
1571 return new CallbackFunction( function );
1575 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1578 * @param[in] function The function to call
1579 * @return A newly allocated Callback object, ownership transferred to caller
1581 template< typename R, typename P1 >
1582 inline CallbackBase* MakeCallback( R(*function)(P1) )
1584 return new CallbackFunction( function );
1588 * @brief Creates a callback from a C function or static member function with two parameters.
1591 * @param[in] function The function to call
1592 * @return A newly allocated Callback object, ownership transferred to caller
1594 template< typename P1, typename P2 >
1595 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1597 return new CallbackFunction( function );
1601 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1604 * @param[in] function The function to call
1605 * @return A newly allocated Callback object, ownership transferred to caller
1607 template< typename R, typename P1, typename P2 >
1608 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1610 return new CallbackFunction( function );
1614 * @brief Creates a callback from a C function or static member function with three parameters.
1617 * @param[in] function The function to call
1618 * @return A newly allocated Callback object, ownership transferred to caller
1620 template< typename P1, typename P2, typename P3 >
1621 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1623 return new CallbackFunction( function );
1627 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1630 * @param[in] function The function to call
1631 * @return A newly allocated Callback object, ownership transferred to caller
1633 template< typename R, typename P1, typename P2, typename P3 >
1634 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1636 return new CallbackFunction( function );
1640 * @brief Creates a callback from a class member function with no parameters.
1642 * Requires the function to be member of the same class.
1644 * @param[in] object The object to call
1645 * @param[in] function The member function to call
1646 * @return A newly allocated Callback object, ownership transferred to caller
1649 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1651 return new Callback< T >( object, function );
1655 * @brief Creates a callback from a class member function with one parameter.
1657 * Requires the function to be member of the same class.
1659 * @param[in] object The object to call
1660 * @param[in] function The member function to call
1661 * @return A newly allocated Callback object, ownership transferred to caller
1663 template< class T, typename P1 >
1664 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1666 return new Callback< T >( object, function );
1670 * @brief Creates a callback from a class member function with two parameters.
1672 * Requires the function to be member of the same class.
1674 * @param[in] object The object to call
1675 * @param[in] function The member function to call
1676 * @return A newly allocated Callback object, ownership transferred to caller
1678 template< class T, typename P1, typename P2 >
1679 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1681 return new Callback< T >( object, function );
1685 * @brief Creates a callback from a class member function with three parameters.
1687 * Requires the function to be member of the same class.
1689 * @param[in] object The object to call
1690 * @param[in] function The member function to call
1691 * @return A newly allocated Callback object, ownership transferred to caller
1693 template< class T, typename P1, typename P2, typename P3 >
1694 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1696 return new Callback< T >( object, function );
1700 * @brief Creates a callback from a class member function with no parameters and a return type.
1702 * Requires the function to be member of the same class.
1704 * @param[in] object The object to call
1705 * @param[in] function The member function to call
1706 * @return A newly allocated Callback object, ownership transferred to caller
1708 template< class T, typename R >
1709 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1711 return new Callback< T >( object, function );
1715 * @brief Creates a callback from a class member function with one parameter and a return type.
1717 * Requires the function to be member of the same class.
1719 * @param[in] object The object to call
1720 * @param[in] function The member function to call
1721 * @return A newly allocated Callback object, ownership transferred to caller
1723 template< class T, typename P1, typename R >
1724 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1726 return new Callback< T >( object, function );
1730 * @brief Creates a callback from a class member function with two parameters and a return type.
1732 * Requires the function to be member of the same class.
1734 * @param[in] object The object to call
1735 * @param[in] function The member function to call
1736 * @return A newly allocated Callback object, ownership transferred to caller
1738 template< class T, typename P1, typename P2, typename R >
1739 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1741 return new Callback< T >( object, function );
1745 * @brief Creates a callback from a class member function with three parameters and a return type.
1747 * Requires the function to be member of the same class.
1749 * @param[in] object The object to call
1750 * @param[in] function The member function to call
1751 * @return A newly allocated Callback object, ownership transferred to caller
1753 template< class T, typename P1, typename P2, typename P3, typename R >
1754 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1756 return new Callback< T >( object, function );
1760 * @brief Creates a callback from a class's parent member function with no parameters.
1762 * Requires the function to be member of the same class.
1764 * @param[in] object The object to call
1765 * @param[in] function The member function to call
1766 * @return A newly allocated Callback object, ownership transferred to caller
1768 template< class T, class Base >
1769 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1771 return new Callback< T >( object, function );
1774 * @brief Creates a callback from a class's parent member function with no parameters.
1776 * Requires the function to be member of the same class.
1778 * @param[in] object The object to call
1779 * @param[in] function The member function to call
1780 * @return A newly allocated Callback object, ownership transferred to caller
1782 template< class T, class Base >
1783 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1785 return new Callback< T >( object, function );
1793 #endif // __DALI_CALLBACK_H__