1 #ifndef __DALI_SIGNAL_H__
2 #define __DALI_SIGNAL_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.
22 * @brief The class should implement Dali::ConnectionTrackerInterface, or inherit from Dali::ConnectionTracker.
23 * This enforces automatic disconnection when an object is destroyed, so you don't have
24 * to manually disconnect from signals.
26 * Alternatively, you can use a Dali::SlotDelegate if you don't want to inherit.
30 * class MyClass : public ConnectionTracker
33 * void Callback( Actor actor, const TouchEvent& event )
40 * Actor actor = Actor::New();
42 * actor.TouchedSignal().Connect( this, &MyClass::Callback );
47 * // ConnectionTracker base class automatically disconnects
55 #include <dali/public-api/common/dali-common.h>
56 #include <dali/public-api/signals/callback.h>
57 #include <dali/public-api/signals/signal-slot-connections.h>
58 #include <dali/public-api/signals/slot-delegate.h>
59 #include <dali/public-api/signals/base-signal.h>
64 * @addtogroup dali_core_signals
69 * @brief Base Template class to provide signals.
71 * To create a signal for this class, you first have to define a typedef within your handle's scope:
73 * class MyHandle : public Handle
79 * typedef Signal< void ()> VoidSignalType; ///< For signals that require no parameters and no return value
80 * typedef Signal< bool ()> BoolSignalType; ///< For signals that do not need parameters but require a boolean return
81 * typedef Signal< void ( float )> ParamSignalType; ///< For signals that need a float as a parameter but no return value
89 * VoidSignalType& VoidSignal();
90 * BoolSignalType& BoolSignal();
91 * ParamSignalType& ParamSignal();
96 * The methods are required in the handle class so that the application writer can retrieve the Signal in order to connect/disconnect.
98 * In the implementation class, the members should be defined and the methods should be provided to retrieve the signal itself.
99 * These will be called by the equivalent methods in the MyHandle class.
101 * class MyObject : public Object
107 * MyHandle::VoidSignalType& VoidSignal()
109 * return mVoidSignal;
112 * MyHandle::BoolSignalType& BoolSignal()
114 * return mBoolSignal;
117 * MyHandle::ParamSignalType& ParamSignal()
119 * return mParamSignal;
125 * MyHandle::VoidSignalType mVoidSignal;
126 * MyHandle::BoolSignalType mBoolSignal;
127 * MyHandle::ParamSignalType mParamSignal;
134 template< typename _Signature >
140 * @brief A template for Signals with no parameters or return value.
144 class Signal< void () >
149 * @brief Default constructor.
157 * @brief Non-virtual destructor.
165 * @brief Query whether there are any connected slots.
168 * @return True if there are any slots connected to the signal.
172 return mImpl.Empty();
176 * @brief Query the number of slots.
179 * @return The number of slots connected to this signal.
181 std::size_t GetConnectionCount() const
183 return mImpl.GetConnectionCount();
187 * @brief Connect a function.
190 * @param[in] func The function to connect.
192 void Connect( void (*func)() )
194 mImpl.OnConnect( MakeCallback( func ) );
198 * @brief Disconnect a function.
201 * @param[in] func The function to disconnect.
203 void Disconnect( void (*func)() )
205 mImpl.OnDisconnect( MakeCallback( func ) );
209 * @brief Connect a member function.
212 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
213 * @param[in] func The member function to connect.
216 void Connect( X* obj, void (X::*func)() )
218 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
222 * @brief Disconnect a member function.
225 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
226 * @param[in] func The member function to disconnect.
229 void Disconnect( X* obj, void (X::*func)() )
231 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
235 * @brief Connect a member function.
238 * @param[in] delegate A slot delegate.
239 * @param[in] func The member function to connect.
242 void Connect( SlotDelegate<X>& delegate, void (X::*func)() )
244 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
248 * @brief Disconnect a member function.
251 * @param[in] delegate A slot delegate.
252 * @param[in] func The member function to disconnect.
255 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)() )
257 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
261 * @brief Connect a function object.
264 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
265 * @param[in] func The function object to copy.
268 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
270 mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) );
274 * @brief Connect a function object using FunctorDelegate.
277 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
278 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
280 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
282 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) );
286 * @brief Emit the signal.
296 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
297 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
301 // Use composition instead of inheritance (virtual methods don't mix well with templates)
302 BaseSignal mImpl; ///< The base signal implementation
306 * @brief A template for Signals with no parameters and a return value.
309 template < typename Ret >
310 class Signal< Ret() >
315 * @brief Default constructor.
323 * @brief Non-virtual destructor.
331 * @brief Query whether there are any connected slots.
334 * @return True if there are any slots connected to the signal.
338 return mImpl.Empty();
342 * @brief Query the number of slots.
345 * @return The number of slots connected to this signal.
347 std::size_t GetConnectionCount() const
349 return mImpl.GetConnectionCount();
352 * @brief Connect a function.
355 * @param[in] func The function to connect.
357 void Connect( Ret (*func)() )
359 mImpl.OnConnect( MakeCallback( func ) );
363 * @brief Disconnect a function.
366 * @param[in] func The function to disconnect.
368 void Disconnect( Ret (*func)() )
370 mImpl.OnDisconnect( MakeCallback( func ) );
374 * @brief Connect a member function.
377 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
378 * @param[in] func The member function to connect.
381 void Connect( X* obj, Ret (X::*func)() )
383 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
387 * @brief Disconnect a member function.
390 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
391 * @param[in] func The member function to disconnect.
394 void Disconnect( X* obj, Ret (X::*func)() )
396 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
400 * @brief Connect a member function.
403 * @param[in] delegate A slot delegate.
404 * @param[in] func The member function to connect.
407 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
409 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
413 * @brief Disconnect a member function.
416 * @param[in] delegate A slot delegate.
417 * @param[in] func The member function to disconnect.
420 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
422 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
426 * @brief Connect a function object.
429 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
430 * @param[in] func The function object to copy.
433 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
435 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
439 * @brief Connect a function object using FunctorDelegate.
442 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
443 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
445 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
447 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
451 * @brief Emit the signal.
454 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
458 return mImpl.EmitReturn< Ret >();
463 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
464 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
468 // Use composition instead of inheritance (virtual methods don't mix well with templates)
469 BaseSignal mImpl; ///< Implementation
473 * @brief A template for Signals with 1 parameter.
476 template < typename Arg0 >
477 class Signal< void ( Arg0 ) >
482 * @brief Default constructor.
490 * @brief Non-virtual destructor.
498 * @brief Query whether there are any connected slots.
501 * @return True if there are any slots connected to the signal.
505 return mImpl.Empty();
509 * @brief Query the number of slots.
512 * @return The number of slots connected to this signal.
514 std::size_t GetConnectionCount() const
516 return mImpl.GetConnectionCount();
519 * @brief Connect a function.
522 * @param[in] func The function to connect.
524 void Connect( void (*func)( Arg0 arg0 ) )
526 mImpl.OnConnect( MakeCallback( func ) );
530 * @brief Disconnect a function.
533 * @param[in] func The function to disconnect.
535 void Disconnect( void (*func)( Arg0 arg0 ) )
537 mImpl.OnDisconnect( MakeCallback( func ) );
541 * @brief Connect a member function.
544 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
545 * @param[in] func The member function to connect.
548 void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
550 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
554 * @brief Disconnect a member function.
557 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
558 * @param[in] func The member function to disconnect.
561 void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
563 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
567 * @brief Connect a member function.
570 * @param[in] delegate A slot delegate.
571 * @param[in] func The member function to connect.
574 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
576 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
580 * @brief Disconnect a member function.
583 * @param[in] delegate A slot delegate.
584 * @param[in] func The member function to disconnect.
587 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
589 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
593 * @brief Connect a function object.
596 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
597 * @param[in] func The function object to copy.
600 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
602 mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
606 * @brief Connect a function object using FunctorDelegate.
609 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
610 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
612 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
614 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
618 * @brief Emit the signal.
621 * @param[in] arg0 The first value to pass to callbacks.
623 void Emit( Arg0 arg0 )
625 mImpl.Emit< Arg0 >( arg0 );
630 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
631 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
635 // Use composition instead of inheritance (virtual methods don't mix well with templates)
636 BaseSignal mImpl; ///< Implementation
640 * @brief A template for Signals with 1 parameter and a return value.
643 template < typename Ret, typename Arg0 >
644 class Signal< Ret( Arg0 ) >
649 * @brief Default constructor.
657 * @brief Non-virtual destructor.
665 * @brief Query whether there are any connected slots.
668 * @return True if there are any slots connected to the signal.
672 return mImpl.Empty();
676 * @brief Query the number of slots.
679 * @return The number of slots connected to this signal.
681 std::size_t GetConnectionCount() const
683 return mImpl.GetConnectionCount();
686 * @brief Connect a function.
689 * @param[in] func The function to connect.
691 void Connect( Ret (*func)( Arg0 arg0 ) )
693 mImpl.OnConnect( MakeCallback( func ) );
697 * @brief Disconnect a function.
700 * @param[in] func The function to disconnect.
702 void Disconnect( Ret (*func)( Arg0 arg0 ) )
704 mImpl.OnDisconnect( MakeCallback( func ) );
708 * @brief Connect a member function.
711 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
712 * @param[in] func The member function to connect.
715 void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
717 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
721 * @brief Disconnect a member function.
724 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
725 * @param[in] func The member function to disconnect.
728 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
730 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
734 * @brief Connect a member function.
737 * @param[in] delegate A slot delegate.
738 * @param[in] func The member function to connect.
741 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
743 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
747 * @brief Disconnect a member function.
750 * @param[in] delegate A slot delegate.
751 * @param[in] func The member function to disconnect.
754 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
756 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
760 * @brief Connect a function object.
763 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
764 * @param[in] func The function object to copy.
767 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
769 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
773 * @brief Connect a function object using FunctorDelegate.
776 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
777 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
779 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
781 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
785 * @brief Emit the signal.
788 * @param[in] arg0 The first value to pass to callbacks.
789 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
791 Ret Emit( Arg0 arg0 )
793 return mImpl.EmitReturn< Ret,Arg0 >(arg0);
798 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
799 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
803 // Use composition instead of inheritance (virtual methods don't mix well with templates)
804 BaseSignal mImpl; ///< Implementation
808 * @brief A template for Signals with 2 parameters.
812 template < typename Arg0, typename Arg1 >
813 class Signal< void ( Arg0, Arg1 ) >
818 * @brief Default constructor.
827 * @brief Non-virtual destructor.
836 * @brief Query whether there are any connected slots.
839 * @return True if there are any slots connected to the signal.
843 return mImpl.Empty();
847 * @brief Query the number of slots.
850 * @return The number of slots connected to this signal.
852 std::size_t GetConnectionCount() const
854 return mImpl.GetConnectionCount();
857 * @brief Connect a function.
860 * @param[in] func The function to connect.
862 void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
864 mImpl.OnConnect( MakeCallback( func ) );
868 * @brief Disconnect a function.
871 * @param[in] func The function to disconnect.
873 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
875 mImpl.OnDisconnect( MakeCallback( func ) );
879 * @brief Connect a member function.
882 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
883 * @param[in] func The member function to connect.
886 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
888 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
892 * @brief Disconnect a member function.
895 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
896 * @param[in] func The member function to disconnect.
899 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
901 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
905 * @brief Connect a member function.
908 * @param[in] delegate A slot delegate.
909 * @param[in] func The member function to connect.
912 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
914 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
918 * @brief Disconnect a member function.
921 * @param[in] delegate A slot delegate.
922 * @param[in] func The member function to disconnect.
925 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
927 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
931 * @brief Connect a function object.
934 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
935 * @param[in] func The function object to copy.
938 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
940 mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
944 * @brief Connect a function object using FunctorDelegate.
947 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
948 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
950 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
952 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
956 * @brief Emit the signal.
959 * @param[in] arg0 The first value to pass to callbacks.
960 * @param[in] arg1 The second value to pass to callbacks.
962 void Emit( Arg0 arg0, Arg1 arg1 )
964 mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
969 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
970 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
974 // Use composition instead of inheritance (virtual methods don't mix well with templates)
975 BaseSignal mImpl; ///< Implementation
979 * @brief A template for Signals with 2 parameters and a return value.
982 template < typename Ret, typename Arg0, typename Arg1 >
983 class Signal< Ret( Arg0, Arg1 ) >
988 * @brief Default constructor.
996 * @brief Non-virtual destructor.
1004 * @brief Query whether there are any connected slots.
1007 * @return True if there are any slots connected to the signal.
1011 return mImpl.Empty();
1015 * @brief Query the number of slots.
1018 * @return The number of slots connected to this signal.
1020 std::size_t GetConnectionCount() const
1022 return mImpl.GetConnectionCount();
1025 * @brief Connect a function.
1027 * @param[in] func The function to connect.
1029 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1031 mImpl.OnConnect( MakeCallback( func ) );
1035 * @brief Disconnect a function.
1038 * @param[in] func The function to disconnect.
1040 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1042 mImpl.OnDisconnect( MakeCallback( func ) );
1046 * @brief Connect a member function.
1049 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1050 * @param[in] func The member function to connect.
1053 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1055 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1059 * @brief Disconnect a member function.
1062 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1063 * @param[in] func The member function to disconnect.
1066 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1068 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1072 * @brief Connect a member function.
1075 * @param[in] delegate A slot delegate.
1076 * @param[in] func The member function to connect.
1079 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1081 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1085 * @brief Disconnect a member function.
1088 * @param[in] delegate A slot delegate.
1089 * @param[in] func The member function to disconnect.
1092 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1094 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1098 * @brief Connect a function object.
1101 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1102 * @param[in] func The function object to copy.
1105 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1107 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
1111 * @brief Connect a function object using FunctorDelegate.
1114 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1115 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1117 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1119 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
1123 * @brief Emit the signal.
1126 * @param[in] arg0 The first value to pass to callbacks.
1127 * @param[in] arg1 The second value to pass to callbacks.
1128 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
1130 Ret Emit( Arg0 arg0, Arg1 arg1 )
1132 return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
1137 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1138 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1142 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1143 BaseSignal mImpl; ///< Implementation
1147 * @brief A template for Signals with 3 parameters.
1150 template < typename Arg0, typename Arg1, typename Arg2 >
1151 class Signal< void ( Arg0, Arg1, Arg2 ) >
1156 * @brief Default constructor.
1164 * @brief Non-virtual destructor.
1172 * @brief Query whether there are any connected slots.
1175 * @return True if there are any slots connected to the signal.
1179 return mImpl.Empty();
1183 * @brief Query the number of slots.
1186 * @return The number of slots connected to this signal.
1188 std::size_t GetConnectionCount() const
1190 return mImpl.GetConnectionCount();
1193 * @brief Connect a function.
1196 * @param[in] func The function to connect.
1198 void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1200 mImpl.OnConnect( MakeCallback( func ) );
1204 * @brief Disconnect a function.
1207 * @param[in] func The function to disconnect.
1209 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1211 mImpl.OnDisconnect( MakeCallback( func ) );
1215 * @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, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1224 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1228 * @brief Disconnect a member function.
1231 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1232 * @param[in] func The member function to disconnect.
1235 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1237 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1241 * @brief Connect a member function.
1244 * @param[in] delegate A slot delegate.
1245 * @param[in] func The member function to connect.
1248 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1250 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1254 * @brief Disconnect a member function.
1257 * @param[in] delegate A slot delegate.
1258 * @param[in] func The member function to disconnect.
1261 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1263 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1267 * @brief Connect a function object.
1270 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1271 * @param[in] func The function object to copy.
1274 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1276 mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
1280 * @brief Connect a function object using FunctorDelegate.
1283 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1284 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1286 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1288 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
1292 * @brief Emit the signal.
1295 * @param[in] arg0 The first value to pass to callbacks.
1296 * @param[in] arg1 The second value to pass to callbacks.
1297 * @param[in] arg2 The third value to pass to callbacks.
1299 void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1301 mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1306 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1307 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1311 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1312 BaseSignal mImpl; ///< Implementation
1316 * @brief A template for Signals with 2 parameters and a return value.
1319 template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
1320 class Signal< Ret( Arg0, Arg1, Arg2 ) >
1325 * @brief Default constructor.
1333 * @brief Non-virtual destructor.
1341 * @brief Query whether there are any connected slots.
1344 * @return True if there are any slots connected to the signal.
1348 return mImpl.Empty();
1352 * @brief Query the number of slots.
1355 * @return The number of slots connected to this signal.
1357 std::size_t GetConnectionCount() const
1359 return mImpl.GetConnectionCount();
1363 * @brief Connect a function.
1366 * @param[in] func The function to connect.
1368 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1370 mImpl.OnConnect( MakeCallback( func ) );
1374 * @brief Disconnect a function.
1377 * @param[in] func The function to disconnect.
1379 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1381 mImpl.OnDisconnect( MakeCallback( func ) );
1385 * @brief Connect a member function.
1388 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1389 * @param[in] func The member function to connect.
1392 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1394 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1398 * @brief Disconnect a member function.
1401 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1402 * @param[in] func The member function to disconnect.
1405 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1407 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1411 * @brief Connect a member function.
1414 * @param[in] delegate A slot delegate.
1415 * @param[in] func The member function to connect.
1418 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1420 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1424 * @brief Disconnect a member function.
1427 * @param[in] delegate A slot delegate.
1428 * @param[in] func The member function to disconnect.
1431 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1433 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1437 * @brief Connect a function object.
1440 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1441 * @param[in] func The function object to copy.
1444 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1446 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
1450 * @brief Connect a function object using FunctorDelegate.
1453 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1454 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1456 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1458 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
1462 * @brief Emit the signal.
1465 * @param[in] arg0 The first value to pass to callbacks.
1466 * @param[in] arg1 The second value to pass to callbacks.
1467 * @param[in] arg2 The third value to pass to callbacks.
1468 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
1470 Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1472 return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1477 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1478 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1482 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1483 BaseSignal mImpl; ///< Implementation
1491 #endif // __DALI_SIGNAL_H__