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.
22 * @brief The class should implement Dali::ConnectionTrackerInterface, or inherit from Dali::ConnectionTracker.
24 * This enforces automatic disconnection when an object is destroyed, so you don't have
25 * to manually disconnect from signals.
27 * Alternatively, you can use a Dali::SlotDelegate if you don't want to inherit.
31 * class MyClass : public ConnectionTracker
34 * void Callback( Actor actor, const TouchEvent& event )
41 * Actor actor = Actor::New();
43 * actor.TouchedSignal().Connect( this, &MyClass::Callback );
48 * // ConnectionTracker base class automatically disconnects
56 #include <dali/public-api/common/dali-common.h>
57 #include <dali/public-api/signals/callback.h>
58 #include <dali/public-api/signals/signal-slot-connections.h>
59 #include <dali/public-api/signals/slot-delegate.h>
60 #include <dali/public-api/signals/base-signal.h>
65 * @addtogroup dali_core_signals
70 * @brief Base Template class to provide signals.
72 * To create a signal for this class, you first have to define a typedef within your handle's scope:
74 * class MyHandle : public Handle
80 * typedef Signal< void ()> VoidSignalType; ///< For signals that require no parameters and no return value
81 * typedef Signal< bool ()> BoolSignalType; ///< For signals that do not need parameters but require a boolean return
82 * typedef Signal< void ( float )> ParamSignalType; ///< For signals that need a float as a parameter but no return value
90 * VoidSignalType& VoidSignal();
91 * BoolSignalType& BoolSignal();
92 * ParamSignalType& ParamSignal();
97 * The methods are required in the handle class so that the application writer can retrieve the Signal in order to connect/disconnect.
99 * In the implementation class, the members should be defined and the methods should be provided to retrieve the signal itself.
100 * These will be called by the equivalent methods in the MyHandle class.
102 * class MyObject : public Object
108 * MyHandle::VoidSignalType& VoidSignal()
110 * return mVoidSignal;
113 * MyHandle::BoolSignalType& BoolSignal()
115 * return mBoolSignal;
118 * MyHandle::ParamSignalType& ParamSignal()
120 * return mParamSignal;
126 * MyHandle::VoidSignalType mVoidSignal;
127 * MyHandle::BoolSignalType mBoolSignal;
128 * MyHandle::ParamSignalType mParamSignal;
135 template< typename _Signature >
141 * @brief A template for Signals with no parameters or return value.
145 class Signal< void () >
150 * @brief Default constructor.
158 * @brief Non-virtual destructor.
166 * @brief Queries whether there are any connected slots.
169 * @return True if there are any slots connected to the signal
173 return mImpl.Empty();
177 * @brief Queries the number of slots.
180 * @return The number of slots connected to this signal
182 std::size_t GetConnectionCount() const
184 return mImpl.GetConnectionCount();
188 * @brief Connects a function.
191 * @param[in] func The function to connect
193 void Connect( void (*func)() )
195 mImpl.OnConnect( MakeCallback( func ) );
199 * @brief Disconnects a function.
202 * @param[in] func The function to disconnect
204 void Disconnect( void (*func)() )
206 mImpl.OnDisconnect( MakeCallback( func ) );
210 * @brief Connects a member function.
213 * @param[in] obj An object which must implement the ConnectionTrackerInterface
214 * @param[in] func The member function to connect
217 void Connect( X* obj, void (X::*func)() )
219 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
223 * @brief Disconnects a member function.
226 * @param[in] obj An object which must implement the ConnectionTrackerInterface
227 * @param[in] func The member function to disconnect
230 void Disconnect( X* obj, void (X::*func)() )
232 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
236 * @brief Connects a member function.
239 * @param[in] delegate A slot delegate
240 * @param[in] func The member function to connect
243 void Connect( SlotDelegate<X>& delegate, void (X::*func)() )
245 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
249 * @brief Disconnects a member function.
252 * @param[in] delegate A slot delegate
253 * @param[in] func The member function to disconnect
256 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)() )
258 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
262 * @brief Connects a function object.
265 * @param[in] connectionTracker A connection tracker which can be used to disconnect
266 * @param[in] func The function object to copy
269 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
271 mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) );
275 * @brief Connects a function object using FunctorDelegate.
278 * @param[in] connectionTracker A connection tracker which can be used to disconnect
279 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
281 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
283 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) );
287 * @brief Emits the signal.
297 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
298 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
299 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
300 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
304 // Use composition instead of inheritance (virtual methods don't mix well with templates)
305 BaseSignal mImpl; ///< The base signal implementation
309 * @brief A template for Signals with no parameters and a return value.
312 template < typename Ret >
313 class Signal< Ret() >
318 * @brief Default constructor.
326 * @brief Non-virtual destructor.
334 * @brief Queries whether there are any connected slots.
337 * @return True if there are any slots connected to the signal
341 return mImpl.Empty();
345 * @brief Queries the number of slots.
348 * @return The number of slots connected to this signal
350 std::size_t GetConnectionCount() const
352 return mImpl.GetConnectionCount();
355 * @brief Connects a function.
358 * @param[in] func The function to connect
360 void Connect( Ret (*func)() )
362 mImpl.OnConnect( MakeCallback( func ) );
366 * @brief Disconnects a function.
369 * @param[in] func The function to disconnect
371 void Disconnect( Ret (*func)() )
373 mImpl.OnDisconnect( MakeCallback( func ) );
377 * @brief Connects a member function.
380 * @param[in] obj An object which must implement the ConnectionTrackerInterface
381 * @param[in] func The member function to connect
384 void Connect( X* obj, Ret (X::*func)() )
386 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
390 * @brief Disconnects a member function.
393 * @param[in] obj An object which must implement the ConnectionTrackerInterface
394 * @param[in] func The member function to disconnect
397 void Disconnect( X* obj, Ret (X::*func)() )
399 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
403 * @brief Connects a member function.
406 * @param[in] delegate A slot delegate
407 * @param[in] func The member function to connect
410 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
412 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
416 * @brief Disconnects a member function.
419 * @param[in] delegate A slot delegate
420 * @param[in] func The member function to disconnect
423 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
425 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
429 * @brief Connects a function object.
432 * @param[in] connectionTracker A connection tracker which can be used to disconnect
433 * @param[in] func The function object to copy
436 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
438 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
442 * @brief Connects a function object using FunctorDelegate.
445 * @param[in] connectionTracker A connection tracker which can be used to disconnect
446 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
448 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
450 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
454 * @brief Emits the signal.
457 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
461 return mImpl.EmitReturn< Ret >();
466 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
467 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
468 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
469 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
473 // Use composition instead of inheritance (virtual methods don't mix well with templates)
474 BaseSignal mImpl; ///< Implementation
478 * @brief A template for Signals with 1 parameter.
481 template < typename Arg0 >
482 class Signal< void ( Arg0 ) >
487 * @brief Default constructor.
495 * @brief Non-virtual destructor.
503 * @brief Queries whether there are any connected slots.
506 * @return True if there are any slots connected to the signal
510 return mImpl.Empty();
514 * @brief Queries the number of slots.
517 * @return The number of slots connected to this signal
519 std::size_t GetConnectionCount() const
521 return mImpl.GetConnectionCount();
524 * @brief Connects a function.
527 * @param[in] func The function to connect
529 void Connect( void (*func)( Arg0 arg0 ) )
531 mImpl.OnConnect( MakeCallback( func ) );
535 * @brief Disconnects a function.
538 * @param[in] func The function to disconnect
540 void Disconnect( void (*func)( Arg0 arg0 ) )
542 mImpl.OnDisconnect( MakeCallback( func ) );
546 * @brief Connects a member function.
549 * @param[in] obj An object which must implement the ConnectionTrackerInterface
550 * @param[in] func The member function to connect
553 void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
555 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
559 * @brief Disconnects a member function.
562 * @param[in] obj An object which must implement the ConnectionTrackerInterface
563 * @param[in] func The member function to disconnect
566 void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
568 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
572 * @brief Connects a member function.
575 * @param[in] delegate A slot delegate
576 * @param[in] func The member function to connect
579 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
581 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
585 * @brief Disconnects a member function.
588 * @param[in] delegate A slot delegate
589 * @param[in] func The member function to disconnect
592 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
594 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
598 * @brief Connects a function object.
601 * @param[in] connectionTracker A connection tracker which can be used to disconnect
602 * @param[in] func The function object to copy
605 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
607 mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
611 * @brief Connects a function object using FunctorDelegate.
614 * @param[in] connectionTracker A connection tracker which can be used to disconnect
615 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
617 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
619 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
623 * @brief Emits the signal.
626 * @param[in] arg0 The first value to pass to callbacks
628 void Emit( Arg0 arg0 )
630 mImpl.Emit< Arg0 >( arg0 );
635 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
636 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
637 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
638 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
642 // Use composition instead of inheritance (virtual methods don't mix well with templates)
643 BaseSignal mImpl; ///< Implementation
647 * @brief A template for Signals with 1 parameter and a return value.
650 template < typename Ret, typename Arg0 >
651 class Signal< Ret( Arg0 ) >
656 * @brief Default constructor.
664 * @brief Non-virtual destructor.
672 * @brief Queries whether there are any connected slots.
675 * @return True if there are any slots connected to the signal
679 return mImpl.Empty();
683 * @brief Queries the number of slots.
686 * @return The number of slots connected to this signal
688 std::size_t GetConnectionCount() const
690 return mImpl.GetConnectionCount();
693 * @brief Connects a function.
696 * @param[in] func The function to connect
698 void Connect( Ret (*func)( Arg0 arg0 ) )
700 mImpl.OnConnect( MakeCallback( func ) );
704 * @brief Disconnects a function.
707 * @param[in] func The function to disconnect
709 void Disconnect( Ret (*func)( Arg0 arg0 ) )
711 mImpl.OnDisconnect( MakeCallback( func ) );
715 * @brief Connects a member function.
718 * @param[in] obj An object which must implement the ConnectionTrackerInterface
719 * @param[in] func The member function to connect
722 void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
724 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
728 * @brief Disconnects a member function.
731 * @param[in] obj An object which must implement the ConnectionTrackerInterface
732 * @param[in] func The member function to disconnect
735 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
737 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
741 * @brief Connects a member function.
744 * @param[in] delegate A slot delegate
745 * @param[in] func The member function to connect
748 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
750 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
754 * @brief Disconnects a member function.
757 * @param[in] delegate A slot delegate
758 * @param[in] func The member function to disconnect
761 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
763 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
767 * @brief Connects a function object.
770 * @param[in] connectionTracker A connection tracker which can be used to disconnect
771 * @param[in] func The function object to copy
774 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
776 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
780 * @brief Connects a function object using FunctorDelegate.
783 * @param[in] connectionTracker A connection tracker which can be used to disconnect
784 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
786 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
788 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
792 * @brief Emits the signal.
795 * @param[in] arg0 The first value to pass to callbacks
796 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
798 Ret Emit( Arg0 arg0 )
800 return mImpl.EmitReturn< Ret,Arg0 >(arg0);
805 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
806 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
807 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
808 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
812 // Use composition instead of inheritance (virtual methods don't mix well with templates)
813 BaseSignal mImpl; ///< Implementation
817 * @brief A template for Signals with 2 parameters.
821 template < typename Arg0, typename Arg1 >
822 class Signal< void ( Arg0, Arg1 ) >
827 * @brief Default constructor.
836 * @brief Non-virtual destructor.
845 * @brief Queries whether there are any connected slots.
848 * @return True if there are any slots connected to the signal
852 return mImpl.Empty();
856 * @brief Queries the number of slots.
859 * @return The number of slots connected to this signal
861 std::size_t GetConnectionCount() const
863 return mImpl.GetConnectionCount();
866 * @brief Connects a function.
869 * @param[in] func The function to connect
871 void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
873 mImpl.OnConnect( MakeCallback( func ) );
877 * @brief Disconnects a function.
880 * @param[in] func The function to disconnect
882 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
884 mImpl.OnDisconnect( MakeCallback( func ) );
888 * @brief Connects a member function.
891 * @param[in] obj An object which must implement the ConnectionTrackerInterface
892 * @param[in] func The member function to connect
895 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
897 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
901 * @brief Disconnects a member function.
904 * @param[in] obj An object which must implement the ConnectionTrackerInterface
905 * @param[in] func The member function to disconnect
908 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
910 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
914 * @brief Connects a member function.
917 * @param[in] delegate A slot delegate
918 * @param[in] func The member function to connect
921 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
923 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
927 * @brief Disconnects a member function.
930 * @param[in] delegate A slot delegate
931 * @param[in] func The member function to disconnect
934 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
936 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
940 * @brief Connects a function object.
943 * @param[in] connectionTracker A connection tracker which can be used to disconnect
944 * @param[in] func The function object to copy
947 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
949 mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
953 * @brief Connects a function object using FunctorDelegate.
956 * @param[in] connectionTracker A connection tracker which can be used to disconnect
957 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
959 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
961 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
965 * @brief Emits the signal.
968 * @param[in] arg0 The first value to pass to callbacks
969 * @param[in] arg1 The second value to pass to callbacks
971 void Emit( Arg0 arg0, Arg1 arg1 )
973 mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
978 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
979 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
980 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
981 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
985 // Use composition instead of inheritance (virtual methods don't mix well with templates)
986 BaseSignal mImpl; ///< Implementation
990 * @brief A template for Signals with 2 parameters and a return value.
993 template < typename Ret, typename Arg0, typename Arg1 >
994 class Signal< Ret( Arg0, Arg1 ) >
999 * @brief Default constructor.
1007 * @brief Non-virtual destructor.
1015 * @brief Queries whether there are any connected slots.
1018 * @return True if there are any slots connected to the signal
1022 return mImpl.Empty();
1026 * @brief Queries the number of slots.
1029 * @return The number of slots connected to this signal
1031 std::size_t GetConnectionCount() const
1033 return mImpl.GetConnectionCount();
1036 * @brief Connects a function.
1038 * @param[in] func The function to connect
1040 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1042 mImpl.OnConnect( MakeCallback( func ) );
1046 * @brief Disconnects a function.
1049 * @param[in] func The function to disconnect
1051 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1053 mImpl.OnDisconnect( MakeCallback( func ) );
1057 * @brief Connects a member function.
1060 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1061 * @param[in] func The member function to connect
1064 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1066 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1070 * @brief Disconnects a member function.
1073 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1074 * @param[in] func The member function to disconnect
1077 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1079 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1083 * @brief Connects 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, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1092 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1096 * @brief Disconnects a member function.
1099 * @param[in] delegate A slot delegate
1100 * @param[in] func The member function to disconnect
1103 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1105 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1109 * @brief Connects a function object.
1112 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1113 * @param[in] func The function object to copy
1116 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1118 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
1122 * @brief Connects a function object using FunctorDelegate.
1125 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1126 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1128 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1130 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
1134 * @brief Emits the signal.
1137 * @param[in] arg0 The first value to pass to callbacks
1138 * @param[in] arg1 The second value to pass to callbacks
1139 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
1141 Ret Emit( Arg0 arg0, Arg1 arg1 )
1143 return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
1148 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1149 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1150 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1151 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1155 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1156 BaseSignal mImpl; ///< Implementation
1160 * @brief A template for Signals with 3 parameters.
1163 template < typename Arg0, typename Arg1, typename Arg2 >
1164 class Signal< void ( Arg0, Arg1, Arg2 ) >
1169 * @brief Default constructor.
1177 * @brief Non-virtual destructor.
1185 * @brief Queries whether there are any connected slots.
1188 * @return True if there are any slots connected to the signal
1192 return mImpl.Empty();
1196 * @brief Queries the number of slots.
1199 * @return The number of slots connected to this signal
1201 std::size_t GetConnectionCount() const
1203 return mImpl.GetConnectionCount();
1206 * @brief Connects a function.
1209 * @param[in] func The function to connect
1211 void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1213 mImpl.OnConnect( MakeCallback( func ) );
1217 * @brief Disconnects a function.
1220 * @param[in] func The function to disconnect
1222 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1224 mImpl.OnDisconnect( MakeCallback( func ) );
1228 * @brief Connects a member function.
1231 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1232 * @param[in] func The member function to connect
1235 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1237 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1241 * @brief Disconnects a member function.
1244 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1245 * @param[in] func The member function to disconnect
1248 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1250 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1254 * @brief Connects a member function.
1257 * @param[in] delegate A slot delegate
1258 * @param[in] func The member function to connect
1261 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1263 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1267 * @brief Disconnects a member function.
1270 * @param[in] delegate A slot delegate
1271 * @param[in] func The member function to disconnect
1274 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1276 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1280 * @brief Connects a function object.
1283 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1284 * @param[in] func The function object to copy
1287 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1289 mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
1293 * @brief Connects a function object using FunctorDelegate.
1296 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1297 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1299 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1301 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
1305 * @brief Emits the signal.
1308 * @param[in] arg0 The first value to pass to callbacks
1309 * @param[in] arg1 The second value to pass to callbacks
1310 * @param[in] arg2 The third value to pass to callbacks
1312 void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1314 mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1319 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1320 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1321 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1322 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1326 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1327 BaseSignal mImpl; ///< Implementation
1331 * @brief A template for Signals with 2 parameters and a return value.
1334 template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
1335 class Signal< Ret( Arg0, Arg1, Arg2 ) >
1340 * @brief Default constructor.
1348 * @brief Non-virtual destructor.
1356 * @brief Queries whether there are any connected slots.
1359 * @return True if there are any slots connected to the signal
1363 return mImpl.Empty();
1367 * @brief Queries the number of slots.
1370 * @return The number of slots connected to this signal
1372 std::size_t GetConnectionCount() const
1374 return mImpl.GetConnectionCount();
1378 * @brief Connects a function.
1381 * @param[in] func The function to connect
1383 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1385 mImpl.OnConnect( MakeCallback( func ) );
1389 * @brief Disconnects a function.
1392 * @param[in] func The function to disconnect
1394 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1396 mImpl.OnDisconnect( MakeCallback( func ) );
1400 * @brief Connects a member function.
1403 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1404 * @param[in] func The member function to connect
1407 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1409 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1413 * @brief Disconnects a member function.
1416 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1417 * @param[in] func The member function to disconnect
1420 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1422 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1426 * @brief Connects a member function.
1429 * @param[in] delegate A slot delegate
1430 * @param[in] func The member function to connect
1433 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1435 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1439 * @brief Disconnects a member function.
1442 * @param[in] delegate A slot delegate
1443 * @param[in] func The member function to disconnect
1446 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1448 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1452 * @brief Connects a function object.
1455 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1456 * @param[in] func The function object to copy
1459 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1461 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
1465 * @brief Connects a function object using FunctorDelegate.
1468 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1469 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1471 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1473 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
1477 * @brief Emits the signal.
1480 * @param[in] arg0 The first value to pass to callbacks
1481 * @param[in] arg1 The second value to pass to callbacks
1482 * @param[in] arg2 The third value to pass to callbacks
1483 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
1485 Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1487 return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1492 Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1493 Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1494 Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1495 Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1499 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1500 BaseSignal mImpl; ///< Implementation
1508 #endif // DALI_SIGNAL_H