1 #ifndef __DALI_SIGNAL_V2_H__
2 #define __DALI_SIGNAL_V2_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 * @addtogroup CAPI_DALI_SIGNALS_MODULE
25 * @section CAPI_DALI_SIGNALS_MODULE_CONNECTION Connecting signals to C++ member functions
26 * The class should implement Dali::ConnectionTrackerInterface, or inherit from Dali::ConnectionTracker.
27 * This enforces automatic disconnection when an object is destroyed, so you don't have
28 * to manually disconnect from signals.
30 * Alternatively, you can use a Dali::SlotDelegate if you don't want to inherit.
34 * class MyClass : public ConnectionTracker
37 * void Callback( Actor actor, const TouchEvent& event )
44 * Actor actor = Actor::New();
46 * actor.TouchedSignal().Connect( this, &MyClass::Callback );
51 * // ConnectionTracker base class automatically disconnects
58 #include <dali/public-api/common/dali-common.h>
59 #include <dali/public-api/signals/callback.h>
60 #include <dali/public-api/signals/signal-slot-connections.h>
61 #include <dali/public-api/signals/slot-delegate.h>
62 #include <dali/public-api/signals/base-signal.h>
64 namespace Dali DALI_IMPORT_API
68 * @brief Base Template class to provide signals.
70 template< typename _Signature >
76 * @brief A template for Signals with no parameters or return value.
79 class SignalV2< void () >
84 * @brief Default constructor.
91 * @brief Non-virtual destructor.
98 * @brief Query whether there are any connected slots.
100 * @return True if there are any slots connected to the signal.
104 return mImpl.Empty();
108 * @brief Query the number of slots.
110 * @return The number of slots connected to this signal.
112 std::size_t GetConnectionCount() const
114 return mImpl.GetConnectionCount();
118 * @brief Connect a function.
120 * @param[in] func The function to connect.
122 void Connect( void (*func)() )
124 mImpl.OnConnect( MakeCallback( func ) );
128 * @brief Disconnect a function.
130 * @param[in] func The function to disconnect.
132 void Disconnect( void (*func)() )
134 mImpl.OnDisconnect( MakeCallback( func ) );
138 * @brief Connect a member function.
140 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
141 * @param[in] func The member function to connect.
144 void Connect( X* obj, void (X::*func)() )
146 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
150 * @brief Disconnect a member function.
152 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
153 * @param[in] func The member function to disconnect.
156 void Disconnect( X* obj, void (X::*func)() )
158 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
162 * @brief Connect a member function.
164 * @param[in] delegate A slot delegate.
165 * @param[in] func The member function to connect.
168 void Connect( SlotDelegate<X>& delegate, void (X::*func)() )
170 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
174 * @brief Disconnect a member function.
176 * @param[in] delegate A slot delegate.
177 * @param[in] func The member function to disconnect.
180 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)() )
182 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
186 * @brief Connect a function object.
188 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
189 * @param[in] func The function object to copy.
192 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
194 mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) );
198 * @brief Connect a function object using FunctorDelegate.
200 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
201 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
203 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
205 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) );
209 * @brief Emit the signal.
218 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
219 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
223 // Use composition instead of inheritance (virtual methods don't mix well with templates)
224 BaseSignal mImpl; ///< The base signal implementation
228 * @brief A template for Signals with no parameters and a return value.
230 template < typename Ret >
231 class SignalV2< Ret() >
236 * @brief Default constructor.
243 * @brief Non-virtual destructor.
250 * @brief Query whether there are any connected slots.
252 * @return True if there are any slots connected to the signal.
256 return mImpl.Empty();
260 * @brief Query the number of slots.
262 * @return The number of slots connected to this signal.
264 std::size_t GetConnectionCount() const
266 return mImpl.GetConnectionCount();
269 * @brief Connect a function.
271 * @param[in] func The function to connect.
273 void Connect( Ret (*func)() )
275 mImpl.OnConnect( MakeCallback( func ) );
279 * @brief Disconnect a function.
281 * @param[in] func The function to disconnect.
283 void Disconnect( Ret (*func)() )
285 mImpl.OnDisconnect( MakeCallback( func ) );
289 * @brief Connect a member function.
291 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
292 * @param[in] func The member function to connect.
295 void Connect( X* obj, Ret (X::*func)() )
297 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
301 * @brief Disconnect a member function.
303 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
304 * @param[in] func The member function to disconnect.
307 void Disconnect( X* obj, Ret (X::*func)() )
309 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
313 * @brief Connect a member function.
315 * @param[in] delegate A slot delegate.
316 * @param[in] func The member function to connect.
319 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
321 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
325 * @brief Disconnect a member function.
327 * @param[in] delegate A slot delegate.
328 * @param[in] func The member function to disconnect.
331 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
333 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
337 * @brief Connect a function object.
339 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
340 * @param[in] func The function object to copy.
343 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
345 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
349 * @brief Connect a function object using FunctorDelegate.
351 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
352 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
354 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
356 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
360 * @brief Emit the signal.
362 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
366 return mImpl.EmitReturn< Ret >();
371 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
372 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
376 // Use composition instead of inheritance (virtual methods don't mix well with templates)
377 BaseSignal mImpl; ///< Implementation
381 * @brief A template for Signals with 1 parameter.
383 template < typename Arg0 >
384 class SignalV2< void ( Arg0 ) >
389 * @brief Default constructor.
396 * @brief Non-virtual destructor.
403 * @brief Query whether there are any connected slots.
405 * @return True if there are any slots connected to the signal.
409 return mImpl.Empty();
413 * @brief Query the number of slots.
415 * @return The number of slots connected to this signal.
417 std::size_t GetConnectionCount() const
419 return mImpl.GetConnectionCount();
422 * @brief Connect a function.
424 * @param[in] func The function to connect.
426 void Connect( void (*func)( Arg0 arg0 ) )
428 mImpl.OnConnect( MakeCallback( func ) );
432 * @brief Disconnect a function.
434 * @param[in] func The function to disconnect.
436 void Disconnect( void (*func)( Arg0 arg0 ) )
438 mImpl.OnDisconnect( MakeCallback( func ) );
442 * @brief Connect a member function.
444 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
445 * @param[in] func The member function to connect.
448 void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
450 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
454 * @brief Disconnect a member function.
456 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
457 * @param[in] func The member function to disconnect.
460 void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
462 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
466 * @brief Connect a member function.
468 * @param[in] delegate A slot delegate.
469 * @param[in] func The member function to connect.
472 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
474 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
478 * @brief Disconnect a member function.
480 * @param[in] delegate A slot delegate.
481 * @param[in] func The member function to disconnect.
484 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
486 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
490 * @brief Connect a function object.
492 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
493 * @param[in] func The function object to copy.
496 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
498 mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
502 * @brief Connect a function object using FunctorDelegate.
504 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
505 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
507 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
509 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
513 * @brief Emit the signal.
515 * @param[in] arg0 The first value to pass to callbacks.
517 void Emit( Arg0 arg0 )
519 mImpl.Emit< Arg0 >( arg0 );
524 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
525 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
529 // Use composition instead of inheritance (virtual methods don't mix well with templates)
530 BaseSignal mImpl; ///< Implementation
534 * @brief A template for Signals with 1 parameter and a return value.
536 template < typename Ret, typename Arg0 >
537 class SignalV2< Ret( Arg0 ) >
542 * @brief Default constructor.
549 * @brief Non-virtual destructor.
556 * @brief Query whether there are any connected slots.
558 * @return True if there are any slots connected to the signal.
562 return mImpl.Empty();
566 * @brief Query the number of slots.
568 * @return The number of slots connected to this signal.
570 std::size_t GetConnectionCount() const
572 return mImpl.GetConnectionCount();
575 * @brief Connect a function.
577 * @param[in] func The function to connect.
579 void Connect( Ret (*func)( Arg0 arg0 ) )
581 mImpl.OnConnect( MakeCallback( func ) );
585 * @brief Disconnect a function.
587 * @param[in] func The function to disconnect.
589 void Disconnect( Ret (*func)( Arg0 arg0 ) )
591 mImpl.OnDisconnect( MakeCallback( func ) );
595 * @brief Connect a member function.
597 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
598 * @param[in] func The member function to connect.
601 void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
603 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
607 * @brief Disconnect a member function.
609 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
610 * @param[in] func The member function to disconnect.
613 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
615 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
619 * @brief Connect a member function.
621 * @param[in] delegate A slot delegate.
622 * @param[in] func The member function to connect.
625 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
627 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
631 * @brief Disconnect a member function.
633 * @param[in] delegate A slot delegate.
634 * @param[in] func The member function to disconnect.
637 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
639 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
643 * @brief Connect a function object.
645 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
646 * @param[in] func The function object to copy.
649 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
651 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
655 * @brief Connect a function object using FunctorDelegate.
657 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
658 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
660 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
662 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
666 * @brief Emit the signal.
668 * @param[in] arg0 The first value to pass to callbacks.
669 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
671 Ret Emit( Arg0 arg0 )
673 return mImpl.EmitReturn< Ret,Arg0 >(arg0);
678 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
679 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
683 // Use composition instead of inheritance (virtual methods don't mix well with templates)
684 BaseSignal mImpl; ///< Implementation
688 * @brief A template for Signals with 2 parameters.
691 template < typename Arg0, typename Arg1 >
692 class SignalV2< void ( Arg0, Arg1 ) >
697 * @brief Default constructor.
705 * @brief Non-virtual destructor.
713 * @brief Query whether there are any connected slots.
715 * @return True if there are any slots connected to the signal.
719 return mImpl.Empty();
723 * @brief Query the number of slots.
725 * @return The number of slots connected to this signal.
727 std::size_t GetConnectionCount() const
729 return mImpl.GetConnectionCount();
732 * @brief Connect a function.
734 * @param[in] func The function to connect.
736 void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
738 mImpl.OnConnect( MakeCallback( func ) );
742 * @brief Disconnect a function.
744 * @param[in] func The function to disconnect.
746 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
748 mImpl.OnDisconnect( MakeCallback( func ) );
752 * @brief Connect a member function.
754 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
755 * @param[in] func The member function to connect.
758 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
760 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
764 * @brief Disconnect a member function.
766 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
767 * @param[in] func The member function to disconnect.
770 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
772 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
776 * @brief Connect a member function.
778 * @param[in] delegate A slot delegate.
779 * @param[in] func The member function to connect.
782 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
784 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
788 * @brief Disconnect a member function.
790 * @param[in] delegate A slot delegate.
791 * @param[in] func The member function to disconnect.
794 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
796 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
800 * @brief Connect a function object.
802 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
803 * @param[in] func The function object to copy.
806 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
808 mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
812 * @brief Connect a function object using FunctorDelegate.
814 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
815 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
817 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
819 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
823 * @brief Emit the signal.
825 * @param[in] arg0 The first value to pass to callbacks.
826 * @param[in] arg1 The second value to pass to callbacks.
828 void Emit( Arg0 arg0, Arg1 arg1 )
830 mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
835 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
836 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
840 // Use composition instead of inheritance (virtual methods don't mix well with templates)
841 BaseSignal mImpl; ///< Implementation
845 * @brief A template for Signals with 2 parameters and a return value.
847 template < typename Ret, typename Arg0, typename Arg1 >
848 class SignalV2< Ret( Arg0, Arg1 ) >
853 * @brief Default constructor.
860 * @brief Non-virtual destructor.
867 * @brief Query whether there are any connected slots.
869 * @return True if there are any slots connected to the signal.
873 return mImpl.Empty();
877 * @brief Query the number of slots.
879 * @return The number of slots connected to this signal.
881 std::size_t GetConnectionCount() const
883 return mImpl.GetConnectionCount();
886 * @brief Connect a function.
887 * @param[in] func The function to connect.
889 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
891 mImpl.OnConnect( MakeCallback( func ) );
895 * @brief Disconnect a function.
897 * @param[in] func The function to disconnect.
899 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
901 mImpl.OnDisconnect( MakeCallback( func ) );
905 * @brief Connect a member function.
907 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
908 * @param[in] func The member function to connect.
911 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
913 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
917 * @brief Disconnect a member function.
919 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
920 * @param[in] func The member function to disconnect.
923 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
925 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
929 * @brief Connect a member function.
931 * @param[in] delegate A slot delegate.
932 * @param[in] func The member function to connect.
935 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
937 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
941 * @brief Disconnect a member function.
943 * @param[in] delegate A slot delegate.
944 * @param[in] func The member function to disconnect.
947 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
949 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
953 * @brief Connect a function object.
955 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
956 * @param[in] func The function object to copy.
959 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
961 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
965 * @brief Connect a function object using FunctorDelegate.
967 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
968 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
970 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
972 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
976 * @brief Emit the signal.
978 * @param[in] arg0 The first value to pass to callbacks.
979 * @param[in] arg1 The second value to pass to callbacks.
980 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
982 Ret Emit( Arg0 arg0, Arg1 arg1 )
984 return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
989 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
990 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
994 // Use composition instead of inheritance (virtual methods don't mix well with templates)
995 BaseSignal mImpl; ///< Implementation
999 * @brief A template for Signals with 3 parameters.
1001 template < typename Arg0, typename Arg1, typename Arg2 >
1002 class SignalV2< void ( Arg0, Arg1, Arg2 ) >
1007 * @brief Default constructor.
1014 * @brief Non-virtual destructor.
1021 * @brief Query whether there are any connected slots.
1023 * @return True if there are any slots connected to the signal.
1027 return mImpl.Empty();
1031 * @brief Query the number of slots.
1033 * @return The number of slots connected to this signal.
1035 std::size_t GetConnectionCount() const
1037 return mImpl.GetConnectionCount();
1040 * @brief Connect a function.
1042 * @param[in] func The function to connect.
1044 void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1046 mImpl.OnConnect( MakeCallback( func ) );
1050 * @brief Disconnect a function.
1052 * @param[in] func The function to disconnect.
1054 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1056 mImpl.OnDisconnect( MakeCallback( func ) );
1060 * @brief Connect a member function.
1062 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1063 * @param[in] func The member function to connect.
1066 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1068 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1072 * @brief Disconnect a member function.
1074 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1075 * @param[in] func The member function to disconnect.
1078 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1080 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1084 * @brief Connect a member function.
1086 * @param[in] delegate A slot delegate.
1087 * @param[in] func The member function to connect.
1090 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1092 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1096 * @brief Disconnect a member function.
1098 * @param[in] delegate A slot delegate.
1099 * @param[in] func The member function to disconnect.
1102 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1104 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1108 * @brief Connect a function object.
1110 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1111 * @param[in] func The function object to copy.
1114 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1116 mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
1120 * @brief Connect a function object using FunctorDelegate.
1122 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1123 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1125 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1127 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
1131 * @brief Emit the signal.
1133 * @param[in] arg0 The first value to pass to callbacks.
1134 * @param[in] arg1 The second value to pass to callbacks.
1135 * @param[in] arg2 The third value to pass to callbacks.
1137 void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1139 mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1144 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
1145 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
1149 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1150 BaseSignal mImpl; ///< Implementation
1154 * @brief A template for Signals with 2 parameters and a return value.
1156 template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
1157 class SignalV2< Ret( Arg0, Arg1, Arg2 ) >
1162 * @brief Default constructor.
1169 * @brief Non-virtual destructor.
1176 * @brief Query whether there are any connected slots.
1178 * @return True if there are any slots connected to the signal.
1182 return mImpl.Empty();
1186 * @brief Query the number of slots.
1188 * @return The number of slots connected to this signal.
1190 std::size_t GetConnectionCount() const
1192 return mImpl.GetConnectionCount();
1196 * @brief Connect a function.
1198 * @param[in] func The function to connect.
1200 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1202 mImpl.OnConnect( MakeCallback( func ) );
1206 * @brief Disconnect a function.
1208 * @param[in] func The function to disconnect.
1210 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1212 mImpl.OnDisconnect( MakeCallback( func ) );
1216 * @brief Connect a member function.
1218 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1219 * @param[in] func The member function to connect.
1222 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1224 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1228 * @brief Disconnect a member function.
1230 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1231 * @param[in] func The member function to disconnect.
1234 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1236 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1240 * @brief Connect a member function.
1242 * @param[in] delegate A slot delegate.
1243 * @param[in] func The member function to connect.
1246 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1248 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1252 * @brief Disconnect a member function.
1254 * @param[in] delegate A slot delegate.
1255 * @param[in] func The member function to disconnect.
1258 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1260 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1264 * @brief Connect a function object.
1266 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1267 * @param[in] func The function object to copy.
1270 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1272 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
1276 * @brief Connect a function object using FunctorDelegate.
1278 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1279 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1281 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1283 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
1287 * @brief Emit the signal.
1289 * @param[in] arg0 The first value to pass to callbacks.
1290 * @param[in] arg1 The second value to pass to callbacks.
1291 * @param[in] arg2 The third value to pass to callbacks.
1292 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
1294 Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1296 return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1301 SignalV2( const SignalV2& ); ///< undefined copy constructor, signals don't support copying.
1302 SignalV2& operator=( const SignalV2& ); ///< undefined assignment operator
1306 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1307 BaseSignal mImpl; ///< Implementation
1315 #endif // __DALI_SIGNAL_V2_H__