1 #ifndef DALI_CALLBACK_H
2 #define DALI_CALLBACK_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/functor-delegate.h>
31 * @addtogroup dali_core_signals
38 * @brief Callback base class to hold the data for callback function and member function calls.
41 class DALI_CORE_API CallbackBase
45 * @brief Default constructor.
57 * @brief Resets the object pointer so that we know not to call methods of this object any more.
63 * @brief Function to call the function or member function dispatcher.
66 * @param[in] callback The callback to call
68 static void Execute(CallbackBase& callback)
70 // if we point to a function, we can call it directly
71 // otherwise call the dispatcher function that knows the real type of the object
72 // Note that this template dispatcher lives in client code so the library containing
73 // the code has to be loaded, otherwise we crash boom bang
74 if(callback.mImpl && callback.mImpl->mObjectPointer)
76 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
77 (*dispatcher)(callback);
79 // its also possible to have a member function pointer to a CallbackProvider
80 // that has been deleted, so check if we have impl still
81 else if(!callback.mImpl && callback.mFunction)
83 (*(callback.mFunction))();
87 DALI_ASSERT_ALWAYS(0 && "no function to execute");
92 * @brief Function to call the function or member function dispatcher.
95 * @param[in] callback The callback to call
96 * @return The value from the function
99 static R ExecuteReturn(CallbackBase& callback)
102 // if we point to a function, we can call it directly
103 // otherwise call the dispatcher function that knows the real type of the object
104 // Note that this template dispatcher lives in client code so the library containing
105 // the code has to be loaded, otherwise we crash boom bang
106 if(callback.mImpl && callback.mImpl->mObjectPointer)
108 using Dispatcher = R (*)(CallbackBase&);
109 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
110 returnVal = (*dispatcher)(callback);
112 else if(!callback.mImpl && callback.mFunction)
114 using Function1 = R (*)();
115 returnVal = (*(reinterpret_cast<Function1>(callback.mFunction)))();
122 * @brief Function to call the function or member function dispatcher.
124 * This function template gets instantiated at the call site.
126 * @param[in] callback The callback to call
127 * @param[in] param1 The first parameter to pass into the function
129 template<typename P1>
130 static void Execute(CallbackBase& callback, P1 param1)
132 // if we point to a function, we can call it directly
133 // otherwise call the dispatcher function that knows the real type of the object
134 // Note that this template dispatcher lives in client code (where the callback was created)
135 // so the library containing the code has to be loaded, otherwise we crash boom bang
136 if(callback.mImpl && callback.mImpl->mObjectPointer)
138 using Dispatcher = void (*)(CallbackBase&, P1);
139 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
140 (*dispatcher)(callback, param1);
142 else if(!callback.mImpl && callback.mFunction)
144 // convert function type
145 using Function1 = void (*)(P1);
146 (*(reinterpret_cast<Function1>(callback.mFunction)))(param1);
151 * @brief Function to call the function or member function dispatcher.
153 * This function template gets instantiated at the call site.
155 * @param[in] callback The callback to call
156 * @param[in] param1 The first parameter to pass into the function
157 * @return The value from the function
159 template<typename R, typename P1>
160 static R ExecuteReturn(CallbackBase& callback, P1 param1)
163 // if we point to a function, we can call it directly
164 // otherwise call the dispatcher function that knows the real type of the object
165 // Note that this template dispatcher lives in client code (where the callback was created)
166 // so the library containing the code has to be loaded, otherwise we crash boom bang
167 if(callback.mImpl && callback.mImpl->mObjectPointer)
169 using Dispatcher = R (*)(CallbackBase&, P1);
170 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
171 returnVal = (*dispatcher)(callback, param1);
173 else if(!callback.mImpl && callback.mFunction)
175 // convert function type
176 using Function1 = R (*)(P1);
177 returnVal = (*(reinterpret_cast<Function1>(callback.mFunction)))(param1);
184 * @brief Function to call the function or member function dispatcher.
186 * This function template gets instantiated at the call site.
188 * @param[in] callback The callback to call
189 * @param[in] param1 The first parameter to pass into the function
190 * @param[in] param2 The second parameter to pass into the function
192 template<typename P1, typename P2>
193 static void Execute(CallbackBase& callback, P1 param1, P2 param2)
195 // if we point to a function, we can call it directly
196 // otherwise call the dispatcher function that knows the real type of the object
197 // Note that this template dispatcher lives in client code (where the callback was created)
198 // so the library containing the code has to be loaded, otherwise we crash boom bang
199 if(callback.mImpl && callback.mImpl->mObjectPointer)
201 using Dispatcher = void (*)(CallbackBase&, P1, P2);
202 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
203 (*dispatcher)(callback, param1, param2);
205 else if(!callback.mImpl && callback.mFunction)
207 // convert function type
208 using Function2 = void (*)(P1, P2);
209 (*(reinterpret_cast<Function2>(callback.mFunction)))(param1, param2);
214 * @brief Function to call the function or member function dispatcher.
216 * This function template gets instantiated at the call site.
218 * @param[in] callback The callback to call
219 * @param[in] param1 The first parameter to pass into the function
220 * @param[in] param2 The second parameter to pass into the function
221 * @return The return value from the function
223 template<typename R, typename P1, typename P2>
224 static R ExecuteReturn(CallbackBase& callback, P1 param1, P2 param2)
227 // if we point to a function, we can call it directly
228 // otherwise call the dispatcher function that knows the real type of the object
229 // Note that this template dispatcher lives in client code (where the callback was created)
230 // so the library containing the code has to be loaded, otherwise we crash boom bang
231 if(callback.mImpl && callback.mImpl->mObjectPointer)
233 using Dispatcher = R (*)(CallbackBase&, P1, P2);
234 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
235 returnVal = (*dispatcher)(callback, param1, param2);
237 else if(!callback.mImpl && callback.mFunction)
239 // convert function type
240 using Function2 = R (*)(P1, P2);
241 returnVal = (*(reinterpret_cast<Function2>(callback.mFunction)))(param1, param2);
248 * @brief Function to call the function or member function dispatcher.
250 * This function template gets instantiated at the call site.
252 * @param[in] callback The callback to call
253 * @param[in] param1 The first parameter to pass into the function
254 * @param[in] param2 The second parameter to pass into the function
255 * @param[in] param3 The third parameter to pass into the function
257 template<typename P1, typename P2, typename P3>
258 static void Execute(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
260 // if we point to a function, we can call it directly
261 // otherwise call the dispatcher function that knows the real type of the object
262 // Note that this template dispatcher lives in client code (where the callback was created)
263 // so the library containing the code has to be loaded, otherwise we crash boom bang
264 if(callback.mImpl && callback.mImpl->mObjectPointer)
266 using Dispatcher = void (*)(CallbackBase&, P1, P2, P3);
267 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
268 (*dispatcher)(callback, param1, param2, param3);
270 else if(!callback.mImpl && callback.mFunction)
272 // convert function type
273 using Function2 = void (*)(P1, P2, P3);
274 (*(reinterpret_cast<Function2>(callback.mFunction)))(param1, param2, param3);
279 * @brief Function to call the function or member function dispatcher.
281 * This function template gets instantiated at the call site.
283 * @param[in] callback The callback to call
284 * @param[in] param1 The first parameter to pass into the function
285 * @param[in] param2 The second parameter to pass into the function
286 * @param[in] param3 The third parameter to pass into the function
287 * @return The return value from the function
289 template<typename R, typename P1, typename P2, typename P3>
290 static R ExecuteReturn(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
293 // if we point to a function, we can call it directly
294 // otherwise call the dispatcher function that knows the real type of the object
295 // Note that this template dispatcher lives in client code (where the callback was created)
296 // so the library containing the code has to be loaded, otherwise we crash boom bang
297 if(callback.mImpl && callback.mImpl->mObjectPointer)
299 using Dispatcher = R (*)(CallbackBase&, P1, P2, P3);
300 Dispatcher dispatcher = reinterpret_cast<Dispatcher>(callback.mImpl->mMemberFunctionDispatcher);
301 returnVal = (*dispatcher)(callback, param1, param2, param3);
303 else if(!callback.mImpl && callback.mFunction)
305 // convert function type
306 using Function2 = R (*)(P1, P2, P3);
307 returnVal = (*(reinterpret_cast<Function2>(callback.mFunction)))(param1, param2, param3);
313 protected: // Constructors for deriving classes
315 * @brief Function with static linkage.
318 using Function = void (*)();
321 * @brief Member function.
324 using MemberFunction = void (CallbackBase::*)();
327 * @brief Used to call the correct member function.
330 using Dispatcher = void (*)(CallbackBase&);
333 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned).
336 using Destructor = void (*)(void*);
339 * @brief Copy constructor operator not declared.
341 * @param[in] rhs Handle to an object
343 CallbackBase(const CallbackBase& rhs);
346 * @brief Assignment operator not declared.
348 * @param[in] rhs Handle to an object
349 * @return A reference to this
351 CallbackBase& operator=(const CallbackBase& rhs);
354 * @brief Constructor for function with static linkage.
357 * @param[in] function The function to call
359 CallbackBase(Function function);
362 * @brief Constructor for member function.
365 * @param[in] object The object to call (not owned)
366 * @param[in] function The member function of the object
367 * @param[in] dispatcher Used to call the actual object
369 CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher);
372 * @brief Constructor for member function.
375 * @param[in] object The object to call (owned)
376 * @param[in] function The member function of the object
377 * @param dispatcher Used to call the actual object
378 * @param destructor Used to delete the owned object
380 CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor);
382 public: // Data for deriving classes & Dispatchers
384 * @brief Struct to hold the extra data needed for member functions.
389 Impl(); ///< Default constructor @SINCE_1_0.0
391 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
392 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
393 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
395 Impl* mImpl; ///< Implementation pointer
399 MemberFunction mMemberFunction; ///< Pointer to member function
400 Function mFunction; ///< Static function
405 * @brief Non-member equality operator.
407 * @param[in] lhs A reference to compare
408 * @param[in] rhs A reference to compare to
409 * @return True if lhs is same as rhs
411 bool operator==(const CallbackBase& lhs, const CallbackBase& rhs);
414 * @brief Dispatcher to delete an object.
421 * @brief Dispatcher to delete an object.
423 * @param[in] object An object to delete
425 static void Delete(void* object)
427 // CallbackBase owns the object but we're the only one who knows the real type so need
428 // to delete by "downcasting" from void* to the correct type
429 delete reinterpret_cast<T*>(object);
434 * @brief Dispatcher to call the actual member function.
441 * @brief Calls an actual member function.
444 * @param[in] callback The callback information
446 static void Dispatch(CallbackBase& callback)
448 // "downcast" the object and function type back to the correct ones
449 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
450 using MemberFunction = void (T::*)();
451 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
452 (object->*function)();
457 * @brief Dispatcher to call the actual member function.
460 template<class T, typename P1>
464 * @brief Calls an actual member function.
467 * @param[in] callback The callback information
468 * @param[in] param1 The first parameter to pass to the real member function
470 static void Dispatch(CallbackBase& callback, P1 param1)
472 // "downcast" the object and function type back to the correct ones
473 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
474 using MemberFunction = void (T::*)(P1);
475 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
476 (object->*function)(param1);
481 * @brief Dispatcher to call the actual member function.
484 template<class T, typename P1, typename P2>
488 * @brief Call an actual member function.
491 * @param[in] callback The callback information
492 * @param[in] param1 The first parameter to pass to the real member function
493 * @param[in] param2 The second parameter to pass to the real member function
495 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2)
497 // "downcast" the object and function type back to the correct ones
498 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
499 using MemberFunction = void (T::*)(P1, P2);
500 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
501 (object->*function)(param1, param2);
506 * @brief Dispatcher to call the actual member function.
509 template<class T, typename P1, typename P2, typename P3>
513 * @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 * @param[in] param2 The second parameter to pass to the real member function
519 * @param[in] param3 The third parameter to pass to the real member function
521 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
523 // "downcast" the object and function type back to the correct ones
524 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
525 using MemberFunction = void (T::*)(P1, P2, P3);
526 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
527 (object->*function)(param1, param2, param3);
532 * @brief Dispatcher to call the actual member function.
535 template<class T, typename R>
536 struct DispatcherReturn0
539 * @brief Calls an actual member function.
542 * @param[in] callback The callback information
545 static R Dispatch(CallbackBase& callback)
547 // "downcast" the object and function type back to the correct ones
548 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
549 using MemberFunction = R (T::*)();
550 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
551 return (object->*function)();
556 * @brief Dispatcher to call the actual member function.
559 template<class T, typename R, typename P1>
560 struct DispatcherReturn1
563 * @brief Calls an actual member function.
566 * @param[in] callback The callback information
567 * @param[in] param1 The first parameter to pass to the real member function
568 * @return The return value from the function
570 static R Dispatch(CallbackBase& callback, P1 param1)
572 // "downcast" the object and function type back to the correct ones
573 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
574 using MemberFunction = R (T::*)(P1);
575 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
576 return (object->*function)(param1);
581 * @brief Dispatcher to call the actual member function.
584 template<class T, typename R, typename P1, typename P2>
585 struct DispatcherReturn2
588 * @brief Calls an actual member function.
591 * @param[in] callback The callback information
592 * @param[in] param1 The first parameter to pass to the real member function
593 * @param[in] param2 The second parameter to pass to the real member function
594 * @return The return value from the function
596 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2)
598 // "downcast" the object and function type back to the correct ones
599 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
600 using MemberFunction = R (T::*)(P1, P2);
601 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
602 return (object->*function)(param1, param2);
607 * @brief Dispatcher to call the actual member function.
610 template<class T, typename R, typename P1, typename P2, typename P3>
611 struct DispatcherReturn3
614 * @brief Calls an actual member function.
617 * @param[in] callback The callback information
618 * @param[in] param1 The first parameter to pass to the real member function
619 * @param[in] param2 The second parameter to pass to the real member function
620 * @param[in] param3 The third parameter to pass to the real member function
621 * @return The return value from the function
623 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
625 // "downcast" the object and function type back to the correct ones
626 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
627 using MemberFunction = R (T::*)(P1, P2, P3);
628 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
629 return (object->*function)(param1, param2, param3);
634 * @brief Dispatcher to call a functor.
638 struct FunctorDispatcher0
641 * @brief Calls a function object.
644 * @param[in] callback The callback information
646 static void Dispatch(CallbackBase& callback)
648 // "downcast" the object and function type back to the correct ones
649 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
655 * @brief Dispatcher to call a functor.
658 template<class T, typename P1>
659 struct FunctorDispatcher1
662 * @brief Calls a function object.
665 * @param[in] callback The callback information
666 * @param[in] param1 The first parameter to pass to the real member function.
668 static void Dispatch(CallbackBase& callback, P1 param1)
670 // "downcast" the object and function type back to the correct ones
671 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
677 * @brief Dispatcher to call a functor.
680 template<class T, typename P1, typename P2>
681 struct FunctorDispatcher2
684 * @brief Calls a function object.
687 * @param[in] callback The callback information
688 * @param[in] param1 The first parameter to pass to the real member function
689 * @param[in] param2 The second parameter to pass to the real member function
691 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2)
693 // "downcast" the object and function type back to the correct ones
694 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
695 (*object)(param1, param2);
700 * @brief Dispatcher to call a functor.
703 template<class T, typename P1, typename P2, typename P3>
704 struct FunctorDispatcher3
707 * @brief Calls a function object.
710 * @param[in] callback The callback information
711 * @param[in] param1 The first parameter to pass to the real member function
712 * @param[in] param2 The second parameter to pass to the real member function
713 * @param[in] param3 The third parameter to pass to the real member function
715 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
717 // "downcast" the object and function type back to the correct ones
718 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
719 (*object)(param1, param2, param3);
724 * @brief Dispatcher to call a functor.
727 template<class T, typename R>
728 struct FunctorDispatcherReturn0
731 * @brief Calls a function object.
734 * @param[in] callback The callback information
737 static R Dispatch(CallbackBase& callback)
739 // "downcast" the object and function type back to the correct ones
740 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
746 * @brief Dispatcher to call a functor.
749 template<class T, typename R, typename P1>
750 struct FunctorDispatcherReturn1
753 * @brief Calls a function object.
756 * @param[in] callback The callback information
757 * @param[in] param1 The first parameter to pass to the real member function
758 * @return The return value from the function
760 static R Dispatch(CallbackBase& callback, P1 param1)
762 // "downcast" the object and function type back to the correct ones
763 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
764 return (*object)(param1);
769 * @brief Dispatcher to call a functor.
772 template<class T, typename R, typename P1, typename P2>
773 struct FunctorDispatcherReturn2
776 * @brief Calls a function object.
779 * @param[in] callback The callback information
780 * @param[in] param1 The first parameter to pass to the real member function
781 * @param[in] param2 The second parameter to pass to the real member function
782 * @return The return value from the function
784 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2)
786 // "downcast" the object and function type back to the correct ones
787 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
788 return (*object)(param1, param2);
793 * @brief Dispatcher to call a functor.
796 template<class T, typename R, typename P1, typename P2, typename P3>
797 struct FunctorDispatcherReturn3
800 * @brief Calls a function object.
803 * @param[in] callback The callback information
804 * @param[in] param1 The first parameter to pass to the real member function
805 * @param[in] param2 The second parameter to pass to the real member function
806 * @param[in] param3 The third parameter to pass to the real member function
807 * @return The return value from the function
809 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
811 // "downcast" the object and function type back to the correct ones
812 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
813 return (*object)(param1, param2, param3);
818 * @brief Dispatcher to call a functor.
820 * This variant calls a specific void() member function.
824 struct VoidFunctorDispatcher0
827 * @brief Calls a function object.
830 * @param[in] callback The callback information
832 static void Dispatch(CallbackBase& callback)
834 // "downcast" the object and function type back to the correct ones
835 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
836 using MemberFunction = void (T::*)();
837 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
838 (object->*function)();
843 * @brief Dispatcher to call a functor.
845 * This variant calls a void() member, ignoring any signal parameters.
848 template<class T, typename P1>
849 struct VoidFunctorDispatcher1
852 * @brief Calls a function object.
855 * @param[in] callback The callback information
856 * @param[in] param1 The first parameter to pass to the real member function
858 static void Dispatch(CallbackBase& callback, P1 param1)
860 // "downcast" the object and function type back to the correct ones
861 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
862 using MemberFunction = void (T::*)();
863 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
864 (object->*function)(/*ignore params*/);
869 * @brief Dispatcher to call a functor.
871 * This variant calls a void() member, ignoring any signal parameters.
874 template<class T, typename P1, typename P2>
875 struct VoidFunctorDispatcher2
878 * @brief Calls a function object.
881 * @param[in] callback The callback information
882 * @param[in] param1 The first parameter to pass to the real member function
883 * @param[in] param2 The second parameter to pass to the real member function
885 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2)
887 // "downcast" the object and function type back to the correct ones
888 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
889 using MemberFunction = void (T::*)();
890 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
891 (object->*function)(/*ignore params*/);
896 * @brief Dispatcher to call a functor.
898 * This variant calls a void() member, ignoring any signal parameters.
901 template<class T, typename P1, typename P2, typename P3>
902 struct VoidFunctorDispatcher3
905 * @brief Calls a function object.
908 * @param[in] callback The callback information
909 * @param[in] param1 The first parameter to pass to the real member function
910 * @param[in] param2 The second parameter to pass to the real member function
911 * @param[in] param3 The third parameter to pass to the real member function
913 static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
915 // "downcast" the object and function type back to the correct ones
916 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
917 using MemberFunction = void (T::*)();
918 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
919 (object->*function)(/*ignore params*/);
924 * @brief Dispatcher to call a functor.
926 * This variant calls a void() member, and returns a default-constructed value.
929 template<class T, typename R>
930 struct VoidFunctorDispatcherReturn0
933 * @brief Calls a function object.
936 * @param[in] callback The callback information
939 static R Dispatch(CallbackBase& callback)
941 // "downcast" the object and function type back to the correct ones
942 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
943 using MemberFunction = void (T::*)();
944 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
945 (object->*function)(/*ignore params*/);
951 * @brief Dispatcher to call a functor.
953 * This variant calls a void() member, and returns a default-constructed value.
956 template<class T, typename R, typename P1>
957 struct VoidFunctorDispatcherReturn1
960 * @brief Calls a function object.
963 * @param[in] callback The callback information
964 * @param[in] param1 The first parameter to pass to the real member function
965 * @return The return value from the function
967 static R Dispatch(CallbackBase& callback, P1 param1)
969 // "downcast" the object and function type back to the correct ones
970 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
971 using MemberFunction = void (T::*)();
972 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
973 (object->*function)(/*ignore params*/);
979 * @brief Dispatcher to call a functor.
981 * This variant calls a void() member, and returns a default-constructed value.
984 template<class T, typename R, typename P1, typename P2>
985 struct VoidFunctorDispatcherReturn2
988 * @brief Calls a function object.
991 * @param[in] callback The callback information
992 * @param[in] param1 The first parameter to pass to the real member function
993 * @param[in] param2 The second parameter to pass to the real member function
994 * @return The return value from the function
996 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2)
998 // "downcast" the object and function type back to the correct ones
999 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
1000 using MemberFunction = void (T::*)();
1001 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
1002 (object->*function)(/*ignore params*/);
1008 * @brief Dispatcher to call a functor.
1010 * This variant calls a void() member, and returns a default-constructed value.
1013 template<class T, typename R, typename P1, typename P2, typename P3>
1014 struct VoidFunctorDispatcherReturn3
1017 * @brief Calls a function object.
1020 * @param[in] callback The callback information
1021 * @param[in] param1 The first parameter to pass to the real member function
1022 * @param[in] param2 The second parameter to pass to the real member function
1023 * @param[in] param3 The third parameter to pass to the real member function
1024 * @return The return value from the function
1026 static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3)
1028 // "downcast" the object and function type back to the correct ones
1029 T* object = reinterpret_cast<T*>(callback.mImpl->mObjectPointer);
1030 using MemberFunction = void (T::*)();
1031 MemberFunction function = reinterpret_cast<MemberFunction>(callback.mMemberFunction);
1032 (object->*function)(/*ignore params*/);
1038 * @brief Thin template to provide type safety for member function callbacks.
1040 * Version with two parameters and return value.
1044 class Callback : public CallbackBase
1048 * @brief Default constructor.
1058 * @brief Constructor for member function.
1060 * Copies the function object.
1062 * @param[in] object The object to call
1063 * @param[in] memberFunction The member function of the object
1065 Callback(T* object, void (T::*memberFunction)(void))
1066 : CallbackBase(object,
1067 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1068 reinterpret_cast<CallbackBase::Dispatcher>(&Dispatcher0<T>::Dispatch))
1071 template<typename P1>
1072 Callback(T* object, void (T::*memberFunction)(P1))
1073 : CallbackBase(object,
1074 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1075 reinterpret_cast<CallbackBase::Dispatcher>(&Dispatcher1<T, P1>::Dispatch))
1078 template<typename P1, typename P2>
1079 Callback(T* object, void (T::*memberFunction)(P1, P2))
1080 : CallbackBase(object,
1081 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1082 reinterpret_cast<CallbackBase::Dispatcher>(&Dispatcher2<T, P1, P2>::Dispatch))
1085 template<typename P1, typename P2, typename P3>
1086 Callback(T* object, void (T::*memberFunction)(P1, P2, P3))
1087 : CallbackBase(object,
1088 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1089 reinterpret_cast<CallbackBase::Dispatcher>(&Dispatcher3<T, P1, P2, P3>::Dispatch))
1092 template<typename R>
1093 Callback(T* object, R (T::*memberFunction)(void))
1094 : CallbackBase(object,
1095 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1096 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))
1106 template<typename R, typename P1, typename P2>
1107 Callback(T* object, R (T::*memberFunction)(P1, P2))
1108 : CallbackBase(object,
1109 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1110 reinterpret_cast<CallbackBase::Dispatcher>(&DispatcherReturn2<T, R, P1, P2>::Dispatch))
1113 template<typename R, typename P1, typename P2, typename P3>
1114 Callback(T* object, R (T::*memberFunction)(P1, P2, P3))
1115 : CallbackBase(object,
1116 reinterpret_cast<CallbackBase::MemberFunction>(memberFunction),
1117 reinterpret_cast<CallbackBase::Dispatcher>(&DispatcherReturn3<T, R, P1, P2, P3>::Dispatch))
1123 * @brief Specializations for static function callbacks.
1126 class CallbackFunction : public CallbackBase
1130 * @brief Default constructor.
1139 * @brief Constructors for functions with static linkage.
1142 * @param[in] function The function to call
1144 CallbackFunction(void (*function)())
1145 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1148 template<typename R>
1149 CallbackFunction(R (*function)())
1150 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1153 template<typename P1>
1154 CallbackFunction(void (*function)(P1))
1155 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1158 template<typename P1, typename R>
1159 CallbackFunction(R (*function)(P1))
1160 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1163 template<typename P1, typename P2>
1164 CallbackFunction(void (*function)(P1, P2))
1165 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1168 template<typename P1, typename P2, typename R>
1169 CallbackFunction(R (*function)(P1, P2))
1170 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1173 template<typename P1, typename P2, typename P3>
1174 CallbackFunction(void (*function)(P1, P2, P3))
1175 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1178 template<typename P1, typename P2, typename P3, typename R>
1179 CallbackFunction(R (*function)(P1, P2, P3))
1180 : CallbackBase(reinterpret_cast<CallbackBase::Function>(function))
1186 * @brief Specializations for function object callbacks.
1190 class CallbackFunctor0 : public CallbackBase
1194 * @brief Constructor which copies a function object.
1197 * @param[in] object The object to copy
1199 CallbackFunctor0(const T& object)
1200 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1201 NULL, // uses operator() instead of member function
1202 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcher0<T>::Dispatch),
1203 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1209 * @brief Function object callback for connecting void() methods.
1212 class CallbackFunctorDelegate0 : public CallbackBase
1216 * @brief Constructor which copies a function object.
1218 * This variant calls a void() member, ignoring any signal parameters.
1220 * @param[in] object A newly allocated object (ownership is transferred)
1222 CallbackFunctorDelegate0(FunctorDelegate* object)
1223 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1224 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1225 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcher0<FunctorDelegate>::Dispatch),
1226 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1232 * @brief Function object callback for matching callbacks to signal signature.
1235 template<class T, typename P1>
1236 class CallbackFunctor1 : public CallbackBase
1240 * @brief Constructor which copies a function object.
1243 * @param[in] object The object to copy
1245 CallbackFunctor1(const T& object)
1246 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1247 NULL, // uses operator() instead of member function
1248 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcher1<T, P1>::Dispatch),
1249 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1255 * @brief Function object callback for connecting void() methods.
1258 template<typename P1>
1259 class CallbackFunctorDelegate1 : public CallbackBase
1263 * @brief Constructor which copies a function object.
1265 * This variant calls a void() member, ignoring any signal parameters.
1267 * @param[in] object The object to copy
1269 CallbackFunctorDelegate1(FunctorDelegate* object)
1270 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1271 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1272 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcher1<FunctorDelegate, P1>::Dispatch),
1273 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1279 * @brief Function object callback for matching callbacks to signal signature.
1282 template<class T, typename P1, typename P2>
1283 class CallbackFunctor2 : public CallbackBase
1287 * @brief Constructor which copies a function object.
1290 * @param[in] object The object to copy
1292 CallbackFunctor2(const T& object)
1293 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1294 NULL, // uses operator() instead of member function
1295 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcher2<T, P1, P2>::Dispatch),
1296 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1302 * @brief Function object callback for connecting void() methods.
1305 template<typename P1, typename P2>
1306 class CallbackFunctorDelegate2 : public CallbackBase
1310 * @brief Constructor which copies a function object.
1312 * This variant calls a void() member, ignoring any signal parameters.
1314 * @param[in] object The object to copy
1316 CallbackFunctorDelegate2(FunctorDelegate* object)
1317 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1318 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1319 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcher2<FunctorDelegate, P1, P2>::Dispatch),
1320 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1326 * @brief Function object callback for matching callbacks to signal signature.
1329 template<class T, typename P1, typename P2, typename P3>
1330 class CallbackFunctor3 : public CallbackBase
1334 * @brief Constructor which copies a function object.
1337 * @param[in] object The object to copy
1339 CallbackFunctor3(const T& object)
1340 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1341 NULL, // uses operator() instead of member function
1342 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcher3<T, P1, P2, P3>::Dispatch),
1343 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1349 * @brief Function object callback for connecting void() methods.
1352 template<typename P1, typename P2, typename P3>
1353 class CallbackFunctorDelegate3 : public CallbackBase
1357 * @brief Constructor which copies a function object.
1359 * This variant calls a void() member, ignoring any signal parameters.
1361 * @param[in] object The object to copy
1363 CallbackFunctorDelegate3(FunctorDelegate* object)
1364 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1365 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1366 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcher3<FunctorDelegate, P1, P2, P3>::Dispatch),
1367 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1373 * @brief Function object callback for matching callbacks to signal signature.
1376 template<class T, typename R>
1377 class CallbackFunctorReturn0 : public CallbackBase
1381 * @brief Constructor which copies a function object.
1384 * @param[in] object The object to copy
1386 CallbackFunctorReturn0(const T& object)
1387 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1388 NULL, // uses operator() instead of member function
1389 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcherReturn0<T, R>::Dispatch),
1390 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1396 * @brief Function object callback for connecting void() methods.
1399 template<typename R>
1400 class CallbackFunctorDelegateReturn0 : public CallbackBase
1404 * @brief Constructor which copies a function object.
1406 * This variant calls a void() member, ignoring any signal parameters.
1408 * @param[in] object The object to copy
1410 CallbackFunctorDelegateReturn0(FunctorDelegate* object)
1411 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1412 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1413 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcherReturn0<FunctorDelegate, R>::Dispatch),
1414 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1420 * @brief Function object callback for matching callbacks to signal signature.
1423 template<class T, typename P1, typename R>
1424 class CallbackFunctorReturn1 : public CallbackBase
1428 * @brief Constructor which copies a function object.
1431 * @param[in] object The object to copy
1433 CallbackFunctorReturn1(const T& object)
1434 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1435 NULL, // uses operator() instead of member function
1436 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcherReturn1<T, R, P1>::Dispatch),
1437 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1443 * @brief Function object callback for connecting void() methods.
1446 template<typename P1, typename R>
1447 class CallbackFunctorDelegateReturn1 : public CallbackBase
1451 * @brief Constructor which copies a function object.
1453 * This variant calls a void() member, ignoring any signal parameters.
1455 * @param[in] object The object to copy
1457 CallbackFunctorDelegateReturn1(FunctorDelegate* object)
1458 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1459 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1460 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcherReturn1<FunctorDelegate, R, P1>::Dispatch),
1461 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1467 * @brief Function object callback for matching callbacks to signal signature.
1470 template<class T, typename P1, typename P2, typename R>
1471 class CallbackFunctorReturn2 : public CallbackBase
1475 * @brief Constructor which copies a function object.
1478 * @param[in] object The object to copy
1480 CallbackFunctorReturn2(const T& object)
1481 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1482 NULL, // uses operator() instead of member function
1483 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcherReturn2<T, R, P1, P2>::Dispatch),
1484 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1490 * @brief Function object callback for connecting void() methods.
1493 template<typename P1, typename P2, typename R>
1494 class CallbackFunctorDelegateReturn2 : public CallbackBase
1498 * @brief Constructor which copies a function object.
1500 * This variant calls a void() member, ignoring any signal parameters.
1502 * @param[in] object The object to copy
1504 CallbackFunctorDelegateReturn2(FunctorDelegate* object)
1505 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1506 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1507 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcherReturn2<FunctorDelegate, R, P1, P2>::Dispatch),
1508 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1514 * @brief Function object callback for matching callbacks to signal signature.
1517 template<class T, typename P1, typename P2, typename P3, typename R>
1518 class CallbackFunctorReturn3 : public CallbackBase
1522 * @brief Constructor which copies a function object.
1525 * @param[in] object The object to copy
1527 CallbackFunctorReturn3(const T& object)
1528 : CallbackBase(reinterpret_cast<void*>(new T(object)), // copy the object
1529 NULL, // uses operator() instead of member function
1530 reinterpret_cast<CallbackBase::Dispatcher>(&FunctorDispatcherReturn3<T, R, P1, P2, P3>::Dispatch),
1531 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<T>::Delete))
1537 * @brief Function object callback for connecting void() methods.
1540 template<typename P1, typename P2, typename P3, typename R>
1541 class CallbackFunctorDelegateReturn3 : public CallbackBase
1545 * @brief Constructor which copies a function object.
1547 * This variant calls a void() member, ignoring any signal parameters.
1549 * @param[in] object The object to copy
1551 CallbackFunctorDelegateReturn3(FunctorDelegate* object)
1552 : CallbackBase(reinterpret_cast<void*>(object), // transfer ownership
1553 reinterpret_cast<CallbackBase::MemberFunction>(&FunctorDelegate::Execute),
1554 reinterpret_cast<CallbackBase::Dispatcher>(&VoidFunctorDispatcherReturn3<FunctorDelegate, R, P1, P2, P3>::Dispatch),
1555 reinterpret_cast<CallbackBase::Destructor>(&Destroyer<FunctorDelegate>::Delete))
1560 // Callback creation thin templates
1563 * @brief Creates a callback from a C function or static member function with no parameters.
1566 * @param[in] function The function to call
1567 * @return A newly allocated Callback object, ownership transferred to caller
1569 inline CallbackBase* MakeCallback(void (*function)(void))
1571 return new CallbackFunction(function);
1575 * @brief Creates a callback from a C function or static member function with one parameter.
1578 * @param[in] function The function to call
1579 * @return A newly allocated Callback object, ownership transferred to caller
1581 template<typename P1>
1582 inline CallbackBase* MakeCallback(void (*function)(P1))
1584 return new CallbackFunction(function);
1588 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1591 * @param[in] function The function to call
1592 * @return A newly allocated Callback object, ownership transferred to caller
1594 template<typename R>
1595 inline CallbackBase* MakeCallback(R (*function)(void))
1597 return new CallbackFunction(function);
1601 * @brief Creates a callback from a C function or static member function with one parameter 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>
1608 inline CallbackBase* MakeCallback(R (*function)(P1))
1610 return new CallbackFunction(function);
1614 * @brief Creates a callback from a C function or static member function with two 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>
1621 inline CallbackBase* MakeCallback(void (*function)(P1, P2))
1623 return new CallbackFunction(function);
1627 * @brief Creates a callback from a C function or static member function with two 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>
1634 inline CallbackBase* MakeCallback(R (*function)(P1, P2))
1636 return new CallbackFunction(function);
1640 * @brief Creates a callback from a C function or static member function with three parameters.
1643 * @param[in] function The function to call
1644 * @return A newly allocated Callback object, ownership transferred to caller
1646 template<typename P1, typename P2, typename P3>
1647 inline CallbackBase* MakeCallback(void (*function)(P1, P2, P3))
1649 return new CallbackFunction(function);
1653 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1656 * @param[in] function The function to call
1657 * @return A newly allocated Callback object, ownership transferred to caller
1659 template<typename R, typename P1, typename P2, typename P3>
1660 inline CallbackBase* MakeCallback(R (*function)(P1, P2, P3))
1662 return new CallbackFunction(function);
1666 * @brief Creates a callback from a class member function with no parameters.
1668 * Requires the function to be member of the same class.
1670 * @param[in] object The object to call
1671 * @param[in] function The member function to call
1672 * @return A newly allocated Callback object, ownership transferred to caller
1675 inline CallbackBase* MakeCallback(T* object, void (T::*function)(void))
1677 return new Callback<T>(object, function);
1681 * @brief Creates a callback from a class member function with one parameter.
1683 * Requires the function to be member of the same class.
1685 * @param[in] object The object to call
1686 * @param[in] function The member function to call
1687 * @return A newly allocated Callback object, ownership transferred to caller
1689 template<class T, typename P1>
1690 inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1))
1692 return new Callback<T>(object, function);
1696 * @brief Creates a callback from a class member function with two parameters.
1698 * Requires the function to be member of the same class.
1700 * @param[in] object The object to call
1701 * @param[in] function The member function to call
1702 * @return A newly allocated Callback object, ownership transferred to caller
1704 template<class T, typename P1, typename P2>
1705 inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1, P2))
1707 return new Callback<T>(object, function);
1711 * @brief Creates a callback from a class member function with three parameters.
1713 * Requires the function to be member of the same class.
1715 * @param[in] object The object to call
1716 * @param[in] function The member function to call
1717 * @return A newly allocated Callback object, ownership transferred to caller
1719 template<class T, typename P1, typename P2, typename P3>
1720 inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1, P2, P3))
1722 return new Callback<T>(object, function);
1726 * @brief Creates a callback from a class member function with no parameters and a return type.
1728 * Requires the function to be member of the same class.
1730 * @param[in] object The object to call
1731 * @param[in] function The member function to call
1732 * @return A newly allocated Callback object, ownership transferred to caller
1734 template<class T, typename R>
1735 inline CallbackBase* MakeCallback(T* object, R (T::*function)())
1737 return new Callback<T>(object, function);
1741 * @brief Creates a callback from a class member function with one parameter and a return type.
1743 * Requires the function to be member of the same class.
1745 * @param[in] object The object to call
1746 * @param[in] function The member function to call
1747 * @return A newly allocated Callback object, ownership transferred to caller
1749 template<class T, typename P1, typename R>
1750 inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1))
1752 return new Callback<T>(object, function);
1756 * @brief Creates a callback from a class member function with two parameters and a return type.
1758 * Requires the function to be member of the same class.
1760 * @param[in] object The object to call
1761 * @param[in] function The member function to call
1762 * @return A newly allocated Callback object, ownership transferred to caller
1764 template<class T, typename P1, typename P2, typename R>
1765 inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1, P2))
1767 return new Callback<T>(object, function);
1771 * @brief Creates a callback from a class member function with three parameters and a return type.
1773 * Requires the function to be member of the same class.
1775 * @param[in] object The object to call
1776 * @param[in] function The member function to call
1777 * @return A newly allocated Callback object, ownership transferred to caller
1779 template<class T, typename P1, typename P2, typename P3, typename R>
1780 inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1, P2, P3))
1782 return new Callback<T>(object, function);
1786 * @brief Creates a callback from a class's parent member function with no parameters.
1788 * Requires the function to be member of the same class.
1790 * @param[in] object The object to call
1791 * @param[in] function The member function to call
1792 * @return A newly allocated Callback object, ownership transferred to caller
1794 template<class T, class Base>
1795 inline CallbackBase* MakeCallback(T* object, void (Base::*function)(void))
1797 return new Callback<T>(object, function);
1800 * @brief Creates a callback from a class's parent member function with no parameters.
1802 * Requires the function to be member of the same class.
1804 * @param[in] object The object to call
1805 * @param[in] function The member function to call
1806 * @return A newly allocated Callback object, ownership transferred to caller
1808 template<class T, class Base>
1809 inline CallbackBase* MakeCallback(T& object, void (Base::*function)(void))
1811 return new Callback<T>(object, function);
1819 #endif // DALI_CALLBACK_H