1 #ifndef __DALI_CALLBACK_H__
2 #define __DALI_CALLBACK_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/signals/functor-delegate.h>
34 * @brief Callback base class to hold the data for callback function and member function calls.
36 class DALI_IMPORT_API CallbackBase
41 * @brief Default constructor
51 * @brief Resets the object pointer so that we know not to call methods of this object any more.
56 * @brief Function to call the function or member function dispatcher
58 * @param[in] callback The callback to call.
60 static void Execute( CallbackBase& callback )
62 // if we point to a function, we can call it directly
63 // otherwise call the dispatcher function that knows the real type of the object
64 // Note that this template dispatcher lives in client code so the library containing
65 // the code has to be loaded, otherwise we crash boom bang
66 if( callback.mImpl && callback.mImpl->mObjectPointer )
68 Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher;
69 (*dispatcher)( callback );
71 // its also possible to have a member function pointer to a CallbackProvider
72 // that has been deleted, so check if we have impl still
73 else if( !callback.mImpl && callback.mFunction )
75 (*(callback.mFunction))();
79 DALI_ASSERT_ALWAYS( 0 && "no function to execute" );
84 * @brief Function to call the function or member function dispatcher.
86 * @param[in] callback The callback to call.
87 * @return value from the function
89 template< typename R >
90 static R ExecuteReturn( CallbackBase& callback )
93 // if we point to a function, we can call it directly
94 // otherwise call the dispatcher function that knows the real type of the object
95 // Note that this template dispatcher lives in client code so the library containing
96 // the code has to be loaded, otherwise we crash boom bang
97 if( callback.mImpl && callback.mImpl->mObjectPointer )
99 typedef R(*Dispatcher)(CallbackBase& base);
100 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
101 returnVal = (*dispatcher)( callback );
103 else if( !callback.mImpl && callback.mFunction )
105 typedef R(*Function1)();
106 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))();
113 * @brief Function to call the function or member function dispatcher.
115 * This function template gets instantiated at the call site
116 * @param[in] callback The callback to call.
117 * @param[in] param1 The first parameter to pass into the function.
119 template< typename P1 >
120 static void Execute( CallbackBase& callback, P1 param1 )
122 // if we point to a function, we can call it directly
123 // otherwise call the dispatcher function that knows the real type of the object
124 // Note that this template dispatcher lives in client code (where the callback was created)
125 // so the library containing the code has to be loaded, otherwise we crash boom bang
126 if( callback.mImpl && callback.mImpl->mObjectPointer )
128 typedef void(*Dispatcher)(CallbackBase& base,P1);
129 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
130 (*dispatcher)( callback, param1 );
132 else if( !callback.mImpl && callback.mFunction )
134 // convert function type
135 typedef void(*Function1)(P1);
136 (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
141 * @brief Function to call the function or member function dispatcher.
143 * This function template gets instantiated at the call site
144 * @param[in] callback The callback to call.
145 * @param[in] param1 The first parameter to pass into the function.
146 * @return the value from the function
148 template< typename R, typename P1 >
149 static R ExecuteReturn( CallbackBase& callback, P1 param1 )
152 // if we point to a function, we can call it directly
153 // otherwise call the dispatcher function that knows the real type of the object
154 // Note that this template dispatcher lives in client code (where the callback was created)
155 // so the library containing the code has to be loaded, otherwise we crash boom bang
156 if( callback.mImpl && callback.mImpl->mObjectPointer )
158 typedef R(*Dispatcher)(CallbackBase& base,P1);
159 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
160 returnVal = (*dispatcher)( callback, param1 );
162 else if( !callback.mImpl && callback.mFunction )
164 // convert function type
165 typedef R(*Function1)(P1);
166 returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 );
173 * @brief Function to call the function or member function dispatcher.
175 * This function template gets instantiated at the call site.
176 * @param[in] callback The callback to call.
177 * @param[in] param1 The first parameter to pass into the function.
178 * @param[in] param2 The second parameter to pass into the function.
180 template< typename P1, typename P2 >
181 static void Execute( CallbackBase& callback, P1 param1, P2 param2 )
183 // if we point to a function, we can call it directly
184 // otherwise call the dispatcher function that knows the real type of the object
185 // Note that this template dispatcher lives in client code (where the callback was created)
186 // so the library containing the code has to be loaded, otherwise we crash boom bang
187 if( callback.mImpl && callback.mImpl->mObjectPointer )
189 typedef void(*Dispatcher)(CallbackBase& base,P1,P2);
190 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
191 (*dispatcher)( callback, param1, param2 );
193 else if( !callback.mImpl && callback.mFunction )
195 // convert function type
196 typedef void(*Function2)(P1,P2);
197 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
202 * @brief Function to call the function or member function dispatcher.
204 * This function template gets instantiated at the call site
205 * @param[in] callback The callback to call.
206 * @param[in] param1 The first parameter to pass into the function.
207 * @param[in] param2 The second parameter to pass into the function.
208 * @return The return value from the function
210 template< typename R, typename P1, typename P2 >
211 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 )
214 // if we point to a function, we can call it directly
215 // otherwise call the dispatcher function that knows the real type of the object
216 // Note that this template dispatcher lives in client code (where the callback was created)
217 // so the library containing the code has to be loaded, otherwise we crash boom bang
218 if( callback.mImpl && callback.mImpl->mObjectPointer )
220 typedef R(*Dispatcher)(CallbackBase& base,P1,P2);
221 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
222 returnVal = (*dispatcher)( callback, param1, param2 );
224 else if( !callback.mImpl && callback.mFunction )
226 // convert function type
227 typedef R(*Function2)(P1,P2);
228 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 );
235 * @brief Function to call the function or member function dispatcher.
237 * This function template gets instantiated at the call site.
238 * @param[in] callback The callback to call.
239 * @param[in] param1 The first parameter to pass into the function.
240 * @param[in] param2 The second parameter to pass into the function.
241 * @param[in] param3 The third parameter to pass into the function.
243 template< typename P1, typename P2, typename P3 >
244 static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
246 // if we point to a function, we can call it directly
247 // otherwise call the dispatcher function that knows the real type of the object
248 // Note that this template dispatcher lives in client code (where the callback was created)
249 // so the library containing the code has to be loaded, otherwise we crash boom bang
250 if( callback.mImpl && callback.mImpl->mObjectPointer )
252 typedef void(*Dispatcher)(CallbackBase& base,P1,P2,P3);
253 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
254 (*dispatcher)( callback, param1, param2, param3 );
256 else if( !callback.mImpl && callback.mFunction )
258 // convert function type
259 typedef void(*Function2)(P1,P2,P3);
260 (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
265 * @brief Function to call the function or member function dispatcher.
267 * This function template gets instantiated at the call site
268 * @param[in] callback The callback to call.
269 * @param[in] param1 The first parameter to pass into the function.
270 * @param[in] param2 The second parameter to pass into the function.
271 * @param[in] param3 The third parameter to pass into the function.
272 * @return The return value from the function
274 template< typename R, typename P1, typename P2, typename P3 >
275 static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
278 // if we point to a function, we can call it directly
279 // otherwise call the dispatcher function that knows the real type of the object
280 // Note that this template dispatcher lives in client code (where the callback was created)
281 // so the library containing the code has to be loaded, otherwise we crash boom bang
282 if( callback.mImpl && callback.mImpl->mObjectPointer )
284 typedef R(*Dispatcher)(CallbackBase& base,P1,P2,P3);
285 Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher );
286 returnVal = (*dispatcher)( callback, param1, param2, param3 );
288 else if( !callback.mImpl && callback.mFunction )
290 // convert function type
291 typedef R(*Function2)(P1,P2,P3);
292 returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 );
298 protected: // Constructors for deriving classes
301 * @brief Function with static linkage
303 typedef void(*Function)(void);
306 * @brief Member function
308 typedef void (CallbackBase::*MemberFunction)( void );
311 * @brief Used to call the correct member function
313 typedef void (*Dispatcher)( CallbackBase& base );
316 * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned)
318 typedef void(*Destructor)(void* object);
321 * @brief Copy constructor operator not declared.
323 CallbackBase( const CallbackBase& rhs );
325 * @brief assignment operator not declared.
327 const CallbackBase& operator=( const CallbackBase& rhs );
330 * @brief Constructor for function with static linkage.
332 * @param[in] function The function to call.
334 CallbackBase( Function function );
337 * @brief Constructor for member function.
339 * @param[in] object The object to call (not owned).
340 * @param[in] function The member function of the object.
341 * @param[in] dispatcher Used to call the actual object.
343 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher );
346 * @brief Constructor for member function.
348 * @param[in] object The object to call (owned).
349 * @param[in] function The member function of the object.
350 * @param dispatcher Used to call the actual object.
351 * @param destructor Used to delete the owned object.
353 CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor );
355 public: // Data for deriving classes & Dispatchers
358 * @brief struct to hold the extra data needed for member functions.
362 Impl(); ///< Default constructor
364 void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL.
365 Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions
366 Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned.
368 Impl* mImpl; ///< Implementation pointer
372 MemberFunction mMemberFunction; ///< Pointer to member function
373 Function mFunction; ///< Static function
378 * @brief Non-member equality operator
380 bool operator==( const CallbackBase& lhs, const CallbackBase& rhs );
383 * @brief Dispatcher to delete an object.
389 * @brief Dispatcher to delete an object.
391 static void Delete( void* object )
393 // CallbackBase owns the object but we're the only one who knows the real type so need
394 // to delete by "downcasting" from void* to the correct type
395 delete reinterpret_cast< T* >( object );
400 * @brief Dispatcher to call the actual member function.
406 * @brief Call an actual member function.
408 * @param[in] callback The callback information.
410 static void Dispatch( CallbackBase& callback )
412 // "downcast" the object and function type back to the correct ones
413 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
414 typedef void(T::*MemberFunction)(void);
415 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
416 (object->*function)();
421 * @brief Dispatcher to call the actual member function.
423 template< class T, typename P1 >
427 * @brief Call an actual member function.
429 * @param[in] callback The callback information.
430 * @param[in] param1 The first parameter to pass to the real member function.
432 static void Dispatch( CallbackBase& callback, P1 param1 )
434 // "downcast" the object and function type back to the correct ones
435 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
436 typedef void(T::*MemberFunction)(P1);
437 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
438 (object->*function)( param1 );
443 * @brief Dispatcher to call the actual member function.
445 template< class T, typename P1, typename P2 >
449 * @brief Call an actual member function.
451 * @param[in] callback The callback information.
452 * @param[in] param1 The first parameter to pass to the real member function.
453 * @param[in] param2 The second parameter to pass to the real member function.
455 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
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)(P1, P2);
460 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
461 (object->*function)( param1, param2 );
466 * @brief Dispatcher to call the actual member function.
468 template< class T, typename P1, typename P2, typename P3 >
472 * @brief Call an actual member function.
474 * @param[in] callback The callback information.
475 * @param[in] param1 The first parameter to pass to the real member function.
476 * @param[in] param2 The second parameter to pass to the real member function.
477 * @param[in] param3 The third parameter to pass to the real member function.
479 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
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, P2, P3);
484 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
485 (object->*function)( param1, param2, param3 );
490 * @brief Dispatcher to call the actual member function.
492 template< class T, typename R >
493 struct DispatcherReturn0
496 * @brief Call an actual member function.
498 * @param[in] callback The callback information.
501 static R Dispatch( CallbackBase& callback )
503 // "downcast" the object and function type back to the correct ones
504 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
505 typedef R(T::*MemberFunction)(void);
506 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
507 return (object->*function)();
512 * @brief Dispatcher to call the actual member function.
514 template< class T, typename R, typename P1 >
515 struct DispatcherReturn1
518 * @brief Call an actual member function.
520 * @param[in] callback The callback information.
521 * @param[in] param1 The first parameter to pass to the real member function.
522 * @return The return value from the function
524 static R Dispatch( CallbackBase& callback, P1 param1 )
526 // "downcast" the object and function type back to the correct ones
527 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
528 typedef R(T::*MemberFunction)(P1);
529 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
530 return (object->*function)( param1 );
535 * @brief Dispatcher to call the actual member function.
537 template< class T, typename R, typename P1, typename P2 >
538 struct DispatcherReturn2
541 * @brief Call an actual member function.
543 * @param[in] callback The callback information.
544 * @param[in] param1 The first parameter to pass to the real member function.
545 * @param[in] param2 The second parameter to pass to the real member function.
546 * @return The return value from the function
548 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
550 // "downcast" the object and function type back to the correct ones
551 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
552 typedef R(T::*MemberFunction)(P1, P2);
553 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
554 return (object->*function)( param1, param2 );
559 * @brief Dispatcher to call the actual member function.
561 template< class T, typename R, typename P1, typename P2, typename P3 >
562 struct DispatcherReturn3
565 * @brief Call an actual member function.
567 * @param[in] callback The callback information.
568 * @param[in] param1 The first parameter to pass to the real member function.
569 * @param[in] param2 The second parameter to pass to the real member function.
570 * @param[in] param3 The third parameter to pass to the real member function.
571 * @return The return value from the function
573 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
575 // "downcast" the object and function type back to the correct ones
576 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
577 typedef R(T::*MemberFunction)(P1, P2, P3);
578 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
579 return (object->*function)( param1, param2, param3 );
584 * @brief Dispatcher to call a functor.
587 struct FunctorDispatcher0
590 * @brief Call a function object.
592 * @param[in] callback The callback information.
594 static void Dispatch( CallbackBase& callback )
596 // "downcast" the object and function type back to the correct ones
597 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
603 * @brief Dispatcher to call a functor.
605 template< class T, typename P1 >
606 struct FunctorDispatcher1
609 * @brief Call a function object.
611 * @param[in] callback The callback information.
612 * @param[in] param1 The first parameter to pass to the real member function.
614 static void Dispatch( CallbackBase& callback, P1 param1 )
616 // "downcast" the object and function type back to the correct ones
617 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
623 * @brief Dispatcher to call a functor.
625 template< class T, typename P1, typename P2 >
626 struct FunctorDispatcher2
629 * @brief Call a function object.
631 * @param[in] callback The callback information.
632 * @param[in] param1 The first parameter to pass to the real member function.
633 * @param[in] param2 The second parameter to pass to the real member function.
635 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
637 // "downcast" the object and function type back to the correct ones
638 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
639 (*object)( param1, param2 );
644 * @brief Dispatcher to call a functor.
646 template< class T, typename P1, typename P2, typename P3 >
647 struct FunctorDispatcher3
650 * @brief Call a function object.
652 * @param[in] callback The callback information.
653 * @param[in] param1 The first parameter to pass to the real member function.
654 * @param[in] param2 The second parameter to pass to the real member function.
655 * @param[in] param3 The third parameter to pass to the real member function.
657 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
659 // "downcast" the object and function type back to the correct ones
660 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
661 (*object)( param1, param2, param3 );
666 * @brief Dispatcher to call a functor.
668 template< class T, typename R >
669 struct FunctorDispatcherReturn0
672 * @brief Call a function object.
674 * @param[in] callback The callback information.
677 static R Dispatch( CallbackBase& callback )
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.
688 template< class T, typename R, typename P1 >
689 struct FunctorDispatcherReturn1
692 * @brief Call a function object.
694 * @param[in] callback The callback information.
695 * @param[in] param1 The first parameter to pass to the real member function.
696 * @return The return value from the function
698 static R Dispatch( CallbackBase& callback, P1 param1 )
700 // "downcast" the object and function type back to the correct ones
701 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
702 return (*object)( param1 );
707 * @brief Dispatcher to call a functor.
709 template< class T, typename R, typename P1, typename P2 >
710 struct FunctorDispatcherReturn2
713 * @brief Call a function object.
715 * @param[in] callback The callback information.
716 * @param[in] param1 The first parameter to pass to the real member function.
717 * @param[in] param2 The second parameter to pass to the real member function.
718 * @return The return value from the function
720 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
722 // "downcast" the object and function type back to the correct ones
723 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
724 return (*object)( param1, param2 );
729 * @brief Dispatcher to call a functor.
731 template< class T, typename R, typename P1, typename P2, typename P3 >
732 struct FunctorDispatcherReturn3
735 * @brief Call a function object.
737 * @param[in] callback The callback information.
738 * @param[in] param1 The first parameter to pass to the real member function.
739 * @param[in] param2 The second parameter to pass to the real member function.
740 * @param[in] param3 The third parameter to pass to the real member function.
741 * @return The return value from the function
743 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
745 // "downcast" the object and function type back to the correct ones
746 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
747 return (*object)( param1, param2, param3 );
752 * @brief Dispatcher to call a functor.
753 * This variant calls a specific void() member function.
756 struct VoidFunctorDispatcher0
759 * @brief Call a function object.
761 * @param[in] callback The callback information.
763 static void Dispatch( CallbackBase& callback )
765 // "downcast" the object and function type back to the correct ones
766 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
767 typedef void(T::*MemberFunction)(void);
768 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
769 (object->*function)();
774 * @brief Dispatcher to call a functor.
776 * This variant calls a void() member, ignoring any signal parameters
778 template< class T, typename P1 >
779 struct VoidFunctorDispatcher1
782 * @brief Call a function object.
784 * @param[in] callback The callback information.
785 * @param[in] param1 The first parameter to pass to the real member function.
787 static void Dispatch( CallbackBase& callback, P1 param1 )
789 // "downcast" the object and function type back to the correct ones
790 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
791 typedef void(T::*MemberFunction)(void);
792 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
793 (object->*function)(/*ignore params*/);
798 * @brief Dispatcher to call a functor.
800 * This variant calls a void() member, ignoring any signal parameters
802 template< class T, typename P1, typename P2 >
803 struct VoidFunctorDispatcher2
806 * @brief Call a function object.
808 * @param[in] callback The callback information.
809 * @param[in] param1 The first parameter to pass to the real member function.
810 * @param[in] param2 The second parameter to pass to the real member function.
812 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
814 // "downcast" the object and function type back to the correct ones
815 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
816 typedef void(T::*MemberFunction)(void);
817 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
818 (object->*function)(/*ignore params*/);
823 * @brief Dispatcher to call a functor.
825 * This variant calls a void() member, ignoring any signal parameters
827 template< class T, typename P1, typename P2, typename P3 >
828 struct VoidFunctorDispatcher3
831 * @brief Call a function object.
833 * @param[in] callback The callback information.
834 * @param[in] param1 The first parameter to pass to the real member function.
835 * @param[in] param2 The second parameter to pass to the real member function.
836 * @param[in] param3 The third parameter to pass to the real member function.
838 static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
840 // "downcast" the object and function type back to the correct ones
841 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
842 typedef void(T::*MemberFunction)(void);
843 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
844 (object->*function)(/*ignore params*/);
849 * @brief Dispatcher to call a functor.
851 * This variant calls a void() member, and returns a default-constructed value
853 template< class T, typename R >
854 struct VoidFunctorDispatcherReturn0
857 * @brief Call a function object.
859 * @param[in] callback The callback information.
862 static R Dispatch( CallbackBase& callback )
864 // "downcast" the object and function type back to the correct ones
865 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
866 typedef void(T::*MemberFunction)(void);
867 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
868 (object->*function)(/*ignore params*/);
874 * @brief Dispatcher to call a functor.
876 * This variant calls a void() member, and returns a default-constructed value
878 template< class T, typename R, typename P1 >
879 struct VoidFunctorDispatcherReturn1
882 * @brief Call a function object.
884 * @param[in] callback The callback information.
885 * @param[in] param1 The first parameter to pass to the real member function.
886 * @return The return value from the function
888 static R Dispatch( CallbackBase& callback, P1 param1 )
890 // "downcast" the object and function type back to the correct ones
891 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
892 typedef void(T::*MemberFunction)(void);
893 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
894 (object->*function)(/*ignore params*/);
900 * @brief Dispatcher to call a functor.
902 * This variant calls a void() member, and returns a default-constructed value
904 template< class T, typename R, typename P1, typename P2 >
905 struct VoidFunctorDispatcherReturn2
908 * @brief Call a function object.
910 * @param[in] callback The callback information.
911 * @param[in] param1 The first parameter to pass to the real member function.
912 * @param[in] param2 The second parameter to pass to the real member function.
913 * @return The return value from the function
915 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 )
917 // "downcast" the object and function type back to the correct ones
918 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
919 typedef void(T::*MemberFunction)(void);
920 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
921 (object->*function)(/*ignore params*/);
927 * @brief Dispatcher to call a functor.
929 * This variant calls a void() member, and returns a default-constructed value
931 template< class T, typename R, typename P1, typename P2, typename P3 >
932 struct VoidFunctorDispatcherReturn3
935 * @brief Call a function object.
937 * @param[in] callback The callback information.
938 * @param[in] param1 The first parameter to pass to the real member function.
939 * @param[in] param2 The second parameter to pass to the real member function.
940 * @param[in] param3 The third parameter to pass to the real member function.
941 * @return The return value from the function
943 static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 )
945 // "downcast" the object and function type back to the correct ones
946 T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer );
947 typedef void(T::*MemberFunction)(void);
948 MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction );
949 (object->*function)(/*ignore params*/);
955 * @brief Thin template to provide type safety for member function callbacks.
957 * version with two parameters and return value
960 class Callback : public CallbackBase
965 * @brief Default constructor.
974 * @brief Constructor for member function.
976 * Copies the function object.
977 * @param[in] object The object to call.
978 * @param[in] memberFunction The member function of the object.
980 Callback( T* object, void(T::*memberFunction)(void) )
981 : CallbackBase( object,
982 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
983 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0<T>::Dispatch ) ) { }
984 template< typename P1 >
985 Callback( T* object, void(T::*memberFunction)(P1) )
986 : CallbackBase( object,
987 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
988 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1<T,P1>::Dispatch ) ) { }
989 template< typename P1, typename P2 >
990 Callback( T* object, void(T::*memberFunction)(P1, P2) )
991 : CallbackBase( object,
992 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
993 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2<T,P1,P2>::Dispatch ) ) { }
994 template< typename P1, typename P2, typename P3 >
995 Callback( T* object, void(T::*memberFunction)(P1, P2, P3) )
996 : CallbackBase( object,
997 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
998 reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3<T,P1,P2,P3>::Dispatch ) ) { }
999 template< typename R >
1000 Callback( T* object, R(T::*memberFunction)(void) )
1001 : CallbackBase( object,
1002 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1003 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0<T,R>::Dispatch ) ) { }
1004 template< typename R, typename P1 >
1005 Callback( T* object, R(T::*memberFunction)(P1) )
1006 : CallbackBase( object,
1007 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1008 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1<T,R,P1>::Dispatch ) ) { }
1009 template< typename R, typename P1, typename P2 >
1010 Callback( T* object, R(T::*memberFunction)(P1, P2) )
1011 : CallbackBase( object,
1012 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1013 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2<T,R,P1,P2>::Dispatch ) ) { }
1014 template< typename R, typename P1, typename P2, typename P3 >
1015 Callback( T* object, R(T::*memberFunction)(P1, P2, P3) )
1016 : CallbackBase( object,
1017 reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ),
1018 reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3<T,R,P1,P2,P3>::Dispatch ) ) { }
1023 * @brief Specializations for static function callbacks.
1025 class CallbackFunction : public CallbackBase
1030 * @brief Default constructor.
1038 * @brief Constructors for functions with static linkage.
1040 * @param[in] function The function to call.
1042 CallbackFunction( void(*function)() )
1043 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1045 template< typename R >
1046 CallbackFunction( R(*function)() )
1047 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1049 template< typename P1 >
1050 CallbackFunction( void(*function)(P1) )
1051 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1053 template< typename P1, typename R >
1054 CallbackFunction( R(*function)(P1) )
1055 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1057 template< typename P1, typename P2 >
1058 CallbackFunction( void(*function)(P1,P2) )
1059 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1061 template< typename P1, typename P2, typename R >
1062 CallbackFunction( R(*function)(P1,P2) )
1063 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1065 template< typename P1, typename P2, typename P3 >
1066 CallbackFunction( void(*function)(P1,P2,P3) )
1067 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1069 template< typename P1, typename P2, typename P3, typename R >
1070 CallbackFunction( R(*function)(P1,P2,P3) )
1071 : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) )
1077 * @brief Specializations for function object callbacks.
1080 class CallbackFunctor0 : public CallbackBase
1085 * @brief Constructor which copies a function object.
1087 * @param[in] object The object to copy.
1089 CallbackFunctor0( const T& object )
1090 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1091 NULL, // uses operator() instead of member function
1092 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0<T>::Dispatch ),
1093 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1097 * @brief Function object callback for connecting void() methods
1099 class CallbackFunctorDelegate0 : public CallbackBase
1104 * @brief Constructor which copies a function object.
1106 * This variant calls a void() member, ignoring any signal parameters.
1107 * @param[in] object A newly allocated object (ownership is transferred).
1109 CallbackFunctorDelegate0( FunctorDelegate* object )
1110 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1111 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1112 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0<FunctorDelegate>::Dispatch ),
1113 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1117 * @brief Function object callback for matching callbacks to signal signature.
1119 template< class T, typename P1 >
1120 class CallbackFunctor1 : public CallbackBase
1125 * @brief Constructor which copies a function object.
1127 * @param[in] object The object to copy.
1129 CallbackFunctor1( const T& object )
1130 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1131 NULL, // uses operator() instead of member function
1132 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1<T,P1>::Dispatch ),
1133 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1137 * @brief Function object callback for connecting void() methods.
1139 template< typename P1 >
1140 class CallbackFunctorDelegate1 : public CallbackBase
1145 * @brief Constructor which copies a function object.
1147 * This variant calls a void() member, ignoring any signal parameters.
1148 * @param[in] object The object to copy.
1150 CallbackFunctorDelegate1( FunctorDelegate* object )
1151 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1152 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1153 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1<FunctorDelegate,P1>::Dispatch ),
1154 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1158 * @brief Function object callback for matching callbacks to signal signature
1160 template< class T, typename P1, typename P2 >
1161 class CallbackFunctor2 : public CallbackBase
1166 * @brief Constructor which copies a function object.
1168 * @param[in] object The object to copy.
1170 CallbackFunctor2( const T& object )
1171 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1172 NULL, // uses operator() instead of member function
1173 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2<T,P1,P2>::Dispatch ),
1174 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1178 * @brief Function object callback for connecting void() methods
1180 template< typename P1, typename P2 >
1181 class CallbackFunctorDelegate2 : public CallbackBase
1186 * @brief Constructor which copies a function object.
1188 * This variant calls a void() member, ignoring any signal parameters.
1189 * @param[in] object The object to copy.
1191 CallbackFunctorDelegate2( FunctorDelegate* object )
1192 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1193 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1194 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2<FunctorDelegate,P1,P2>::Dispatch ),
1195 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1199 * @brief Function object callback for matching callbacks to signal signature
1201 template< class T, typename P1, typename P2, typename P3 >
1202 class CallbackFunctor3 : public CallbackBase
1207 * @brief Constructor which copies a function object.
1209 * @param[in] object The object to copy.
1211 CallbackFunctor3( const T& object )
1212 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1213 NULL, // uses operator() instead of member function
1214 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3<T,P1,P2,P3>::Dispatch ),
1215 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1219 * @brief Function object callback for connecting void() methods
1221 template< typename P1, typename P2, typename P3 >
1222 class CallbackFunctorDelegate3 : public CallbackBase
1228 * @brief Constructor which copies a function object.
1230 * This variant calls a void() member, ignoring any signal parameters.
1231 * @param[in] object The object to copy.
1233 CallbackFunctorDelegate3( FunctorDelegate* object )
1234 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1235 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1236 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3<FunctorDelegate,P1,P2,P3>::Dispatch ),
1237 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1241 * @brief Function object callback for matching callbacks to signal signature
1243 template< class T, typename R >
1244 class CallbackFunctorReturn0 : public CallbackBase
1249 * @brief Constructor which copies a function object.
1251 * @param[in] object The object to copy.
1253 CallbackFunctorReturn0( const T& object )
1254 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1255 NULL, // uses operator() instead of member function
1256 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0<T,R>::Dispatch ),
1257 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1261 * @brief Function object callback for connecting void() methods
1263 template< typename R >
1264 class CallbackFunctorDelegateReturn0 : public CallbackBase
1269 * @brief Constructor which copies a function object.
1271 * This variant calls a void() member, ignoring any signal parameters.
1272 * @param[in] object The object to copy.
1274 CallbackFunctorDelegateReturn0( FunctorDelegate* object )
1275 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1276 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1277 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0<FunctorDelegate,R>::Dispatch ),
1278 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1282 * @brief Function object callback for matching callbacks to signal signature
1284 template< class T, typename P1, typename R >
1285 class CallbackFunctorReturn1 : public CallbackBase
1290 * @brief Constructor which copies a function object.
1292 * @param[in] object The object to copy.
1294 CallbackFunctorReturn1( const T& object )
1295 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1296 NULL, // uses operator() instead of member function
1297 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1<T,R,P1>::Dispatch ),
1298 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1302 * @brief Function object callback for connecting void() methods
1304 template< typename P1, typename R >
1305 class CallbackFunctorDelegateReturn1 : public CallbackBase
1310 * @brief Constructor which copies a function object.
1312 * This variant calls a void() member, ignoring any signal parameters.
1313 * @param[in] object The object to copy.
1315 CallbackFunctorDelegateReturn1( FunctorDelegate* object )
1316 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1317 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1318 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1<FunctorDelegate,R,P1>::Dispatch ),
1319 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1323 * @brief Function object callback for matching callbacks to signal signature
1325 template< class T, typename P1, typename P2, typename R >
1326 class CallbackFunctorReturn2 : public CallbackBase
1331 * @brief Constructor which copies a function object.
1333 * @param[in] object The object to copy.
1335 CallbackFunctorReturn2( const T& object )
1336 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1337 NULL, // uses operator() instead of member function
1338 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2<T,R,P1,P2>::Dispatch ),
1339 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1343 * @brief Function object callback for connecting void() methods
1345 template< typename P1, typename P2, typename R >
1346 class CallbackFunctorDelegateReturn2 : public CallbackBase
1351 * @brief Constructor which copies a function object.
1353 * This variant calls a void() member, ignoring any signal parameters.
1354 * @param[in] object The object to copy.
1356 CallbackFunctorDelegateReturn2( FunctorDelegate* object )
1357 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1358 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1359 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2<FunctorDelegate,R,P1,P2>::Dispatch ),
1360 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1364 * @brief Function object callback for matching callbacks to signal signature
1366 template< class T, typename P1, typename P2, typename P3, typename R >
1367 class CallbackFunctorReturn3 : public CallbackBase
1372 * @brief Constructor which copies a function object.
1374 * @param[in] object The object to copy.
1376 CallbackFunctorReturn3( const T& object )
1377 : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object
1378 NULL, // uses operator() instead of member function
1379 reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3<T,R,P1,P2,P3>::Dispatch ),
1380 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<T>::Delete ) ) { }
1384 * @brief Function object callback for connecting void() methods
1386 template< typename P1, typename P2, typename P3, typename R >
1387 class CallbackFunctorDelegateReturn3 : public CallbackBase
1392 * @brief Constructor which copies a function object.
1394 * This variant calls a void() member, ignoring any signal parameters.
1395 * @param[in] object The object to copy.
1397 CallbackFunctorDelegateReturn3( FunctorDelegate* object )
1398 : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership
1399 reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ),
1400 reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3<FunctorDelegate,R,P1,P2,P3>::Dispatch ),
1401 reinterpret_cast< CallbackBase::Destructor >( &Destroyer<FunctorDelegate>::Delete ) ) { }
1404 // Callback creation thin templates
1407 * @brief Creates a callback from a C function or static member function with no parameters.
1409 * @param[in] function The function to call.
1410 * @return a newly allocated Callback object, ownership transferred to caller
1412 inline CallbackBase* MakeCallback( void(*function)(void) )
1414 return new CallbackFunction( function );
1418 * @brief Creates a callback from a C function or static member function with one parameter.
1420 * @param[in] function The function to call.
1421 * @return a newly allocated Callback object, ownership transferred to caller
1423 template< typename P1 >
1424 inline CallbackBase* MakeCallback( void(*function)(P1) )
1426 return new CallbackFunction( function );
1430 * @brief Creates a callback from a C function or static member function with no parameters and a return type.
1432 * @param[in] function The function to call.
1433 * @return a newly allocated Callback object, ownership transferred to caller
1435 template< typename R >
1436 inline CallbackBase* MakeCallback( R(*function)(void) )
1438 return new CallbackFunction( function );
1442 * @brief Creates a callback from a C function or static member function with one parameter and a return type.
1444 * @param[in] function The function to call.
1445 * @return a newly allocated Callback object, ownership transferred to caller
1447 template< typename R, typename P1 >
1448 inline CallbackBase* MakeCallback( R(*function)(P1) )
1450 return new CallbackFunction( function );
1454 * @brief Creates a callback from a C function or static member function with two parameters.
1456 * @param[in] function The function to call.
1457 * @return a newly allocated Callback object, ownership transferred to caller
1459 template< typename P1, typename P2 >
1460 inline CallbackBase* MakeCallback( void(*function)(P1,P2) )
1462 return new CallbackFunction( function );
1466 * @brief Creates a callback from a C function or static member function with two parameters and a return type.
1468 * @param[in] function The function to call.
1469 * @return a newly allocated Callback object, ownership transferred to caller
1471 template< typename R, typename P1, typename P2 >
1472 inline CallbackBase* MakeCallback( R(*function)(P1,P2) )
1474 return new CallbackFunction( function );
1478 * @brief Creates a callback from a C function or static member function with three parameters.
1480 * @param[in] function The function to call.
1481 * @return a newly allocated Callback object, ownership transferred to caller
1483 template< typename P1, typename P2, typename P3 >
1484 inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) )
1486 return new CallbackFunction( function );
1490 * @brief Creates a callback from a C function or static member function with three parameters and a return type.
1492 * @param[in] function The function to call.
1493 * @return a newly allocated Callback object, ownership transferred to caller
1495 template< typename R, typename P1, typename P2, typename P3 >
1496 inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) )
1498 return new CallbackFunction( function );
1502 * @brief Creates a callback from a class member function with no parameters.
1504 * requires the function to be member of the same class
1505 * @param[in] object The object to call.
1506 * @param[in] function The member function to call.
1507 * @return a newly allocated Callback object, ownership transferred to caller
1510 inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) )
1512 return new Callback< T >( object, function );
1516 * @brief Creates a callback from a class member function with one parameter.
1518 * requires the function to be member of the same class
1519 * @param[in] object The object to call.
1520 * @param[in] function The member function to call.
1521 * @return a newly allocated Callback object, ownership transferred to caller
1523 template< class T, typename P1 >
1524 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) )
1526 return new Callback< T >( object, function );
1530 * @brief Creates a callback from a class member function with two parameters.
1532 * requires the function to be member of the same class
1533 * @param[in] object The object to call.
1534 * @param[in] function The member function to call.
1535 * @return a newly allocated Callback object, ownership transferred to caller
1537 template< class T, typename P1, typename P2 >
1538 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) )
1540 return new Callback< T >( object, function );
1544 * @brief Creates a callback from a class member function with three parameters.
1546 * requires the function to be member of the same class
1547 * @param[in] object The object to call.
1548 * @param[in] function The member function to call.
1549 * @return a newly allocated Callback object, ownership transferred to caller
1551 template< class T, typename P1, typename P2, typename P3 >
1552 inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) )
1554 return new Callback< T >( object, function );
1558 * @brief Creates a callback from a class member function with no parameters and a return type.
1560 * requires the function to be member of the same class
1561 * @param[in] object The object to call.
1562 * @param[in] function The member function to call.
1563 * @return a newly allocated Callback object, ownership transferred to caller
1565 template< class T, typename R >
1566 inline CallbackBase* MakeCallback( T* object, R(T::*function)() )
1568 return new Callback< T >( object, function );
1572 * @brief Creates a callback from a class member function with one parameter and a return type.
1574 * requires the function to be member of the same class
1575 * @param[in] object The object to call.
1576 * @param[in] function The member function to call.
1577 * @return a newly allocated Callback object, ownership transferred to caller
1579 template< class T, typename P1, typename R >
1580 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) )
1582 return new Callback< T >( object, function );
1586 * @brief Creates a callback from a class member function with two parameters and a return type.
1588 * requires the function to be member of the same class
1589 * @param[in] object The object to call.
1590 * @param[in] function The member function to call.
1591 * @return a newly allocated Callback object, ownership transferred to caller
1593 template< class T, typename P1, typename P2, typename R >
1594 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) )
1596 return new Callback< T >( object, function );
1600 * @brief Creates a callback from a class member function with three parameters and a return type.
1602 * requires the function to be member of the same class
1603 * @param[in] object The object to call.
1604 * @param[in] function The member function to call.
1605 * @return a newly allocated Callback object, ownership transferred to caller
1607 template< class T, typename P1, typename P2, typename P3, typename R >
1608 inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) )
1610 return new Callback< T >( object, function );
1614 * @brief Creates a callback from a class's parent member function with no parameters.
1616 * requires the function to be member of the same class
1617 * @param[in] object The object to call.
1618 * @param[in] function The member function to call.
1619 * @return a newly allocated Callback object, ownership transferred to caller
1621 template< class T, class Base >
1622 inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) )
1624 return new Callback< T >( object, function );
1627 * @brief Creates a callback from a class's parent member function with no parameters.
1629 * requires the function to be member of the same class
1630 * @param[in] object The object to call.
1631 * @param[in] function The member function to call.
1632 * @return a newly allocated Callback object, ownership transferred to caller
1634 template< class T, class Base >
1635 inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) )
1637 return new Callback< T >( object, function );
1642 #endif // __DALI_CALLBACK_H__