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.
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 Query whether there are any connected slots.
169 * @return True if there are any slots connected to the signal.
173 return mImpl.Empty();
177 * @brief Query 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 Connect a function.
191 * @param[in] func The function to connect.
193 void Connect( void (*func)() )
195 mImpl.OnConnect( MakeCallback( func ) );
199 * @brief Disconnect a function.
202 * @param[in] func The function to disconnect.
204 void Disconnect( void (*func)() )
206 mImpl.OnDisconnect( MakeCallback( func ) );
210 * @brief Connect 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 Disconnect 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 Connect 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 Disconnect 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 Connect 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 Connect 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 Emit the signal.
297 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
298 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
302 // Use composition instead of inheritance (virtual methods don't mix well with templates)
303 BaseSignal mImpl; ///< The base signal implementation
307 * @brief A template for Signals with no parameters and a return value.
310 template < typename Ret >
311 class Signal< Ret() >
316 * @brief Default constructor.
324 * @brief Non-virtual destructor.
332 * @brief Query whether there are any connected slots.
335 * @return True if there are any slots connected to the signal.
339 return mImpl.Empty();
343 * @brief Query the number of slots.
346 * @return The number of slots connected to this signal.
348 std::size_t GetConnectionCount() const
350 return mImpl.GetConnectionCount();
353 * @brief Connect a function.
356 * @param[in] func The function to connect.
358 void Connect( Ret (*func)() )
360 mImpl.OnConnect( MakeCallback( func ) );
364 * @brief Disconnect a function.
367 * @param[in] func The function to disconnect.
369 void Disconnect( Ret (*func)() )
371 mImpl.OnDisconnect( MakeCallback( func ) );
375 * @brief Connect a member function.
378 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
379 * @param[in] func The member function to connect.
382 void Connect( X* obj, Ret (X::*func)() )
384 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
388 * @brief Disconnect a member function.
391 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
392 * @param[in] func The member function to disconnect.
395 void Disconnect( X* obj, Ret (X::*func)() )
397 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
401 * @brief Connect a member function.
404 * @param[in] delegate A slot delegate.
405 * @param[in] func The member function to connect.
408 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)() )
410 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
414 * @brief Disconnect a member function.
417 * @param[in] delegate A slot delegate.
418 * @param[in] func The member function to disconnect.
421 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)() )
423 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
427 * @brief Connect a function object.
430 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
431 * @param[in] func The function object to copy.
434 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
436 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) );
440 * @brief Connect a function object using FunctorDelegate.
443 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
444 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
446 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
448 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) );
452 * @brief Emit the signal.
455 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
459 return mImpl.EmitReturn< Ret >();
464 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
465 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
469 // Use composition instead of inheritance (virtual methods don't mix well with templates)
470 BaseSignal mImpl; ///< Implementation
474 * @brief A template for Signals with 1 parameter.
477 template < typename Arg0 >
478 class Signal< void ( Arg0 ) >
483 * @brief Default constructor.
491 * @brief Non-virtual destructor.
499 * @brief Query whether there are any connected slots.
502 * @return True if there are any slots connected to the signal.
506 return mImpl.Empty();
510 * @brief Query the number of slots.
513 * @return The number of slots connected to this signal.
515 std::size_t GetConnectionCount() const
517 return mImpl.GetConnectionCount();
520 * @brief Connect a function.
523 * @param[in] func The function to connect.
525 void Connect( void (*func)( Arg0 arg0 ) )
527 mImpl.OnConnect( MakeCallback( func ) );
531 * @brief Disconnect a function.
534 * @param[in] func The function to disconnect.
536 void Disconnect( void (*func)( Arg0 arg0 ) )
538 mImpl.OnDisconnect( MakeCallback( func ) );
542 * @brief Connect a member function.
545 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
546 * @param[in] func The member function to connect.
549 void Connect( X* obj, void (X::*func)( Arg0 arg0 ) )
551 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
555 * @brief Disconnect a member function.
558 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
559 * @param[in] func The member function to disconnect.
562 void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) )
564 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
568 * @brief Connect a member function.
571 * @param[in] delegate A slot delegate.
572 * @param[in] func The member function to connect.
575 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
577 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
581 * @brief Disconnect a member function.
584 * @param[in] delegate A slot delegate.
585 * @param[in] func The member function to disconnect.
588 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0 ) )
590 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
594 * @brief Connect a function object.
597 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
598 * @param[in] func The function object to copy.
601 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
603 mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) );
607 * @brief Connect a function object using FunctorDelegate.
610 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
611 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
613 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
615 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) );
619 * @brief Emit the signal.
622 * @param[in] arg0 The first value to pass to callbacks.
624 void Emit( Arg0 arg0 )
626 mImpl.Emit< Arg0 >( arg0 );
631 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
632 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
636 // Use composition instead of inheritance (virtual methods don't mix well with templates)
637 BaseSignal mImpl; ///< Implementation
641 * @brief A template for Signals with 1 parameter and a return value.
644 template < typename Ret, typename Arg0 >
645 class Signal< Ret( Arg0 ) >
650 * @brief Default constructor.
658 * @brief Non-virtual destructor.
666 * @brief Query whether there are any connected slots.
669 * @return True if there are any slots connected to the signal.
673 return mImpl.Empty();
677 * @brief Query the number of slots.
680 * @return The number of slots connected to this signal.
682 std::size_t GetConnectionCount() const
684 return mImpl.GetConnectionCount();
687 * @brief Connect a function.
690 * @param[in] func The function to connect.
692 void Connect( Ret (*func)( Arg0 arg0 ) )
694 mImpl.OnConnect( MakeCallback( func ) );
698 * @brief Disconnect a function.
701 * @param[in] func The function to disconnect.
703 void Disconnect( Ret (*func)( Arg0 arg0 ) )
705 mImpl.OnDisconnect( MakeCallback( func ) );
709 * @brief Connect a member function.
712 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
713 * @param[in] func The member function to connect.
716 void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
718 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
722 * @brief Disconnect a member function.
725 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
726 * @param[in] func The member function to disconnect.
729 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) )
731 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
735 * @brief Connect a member function.
738 * @param[in] delegate A slot delegate.
739 * @param[in] func The member function to connect.
742 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
744 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
748 * @brief Disconnect a member function.
751 * @param[in] delegate A slot delegate.
752 * @param[in] func The member function to disconnect.
755 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0 ) )
757 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
761 * @brief Connect a function object.
764 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
765 * @param[in] func The function object to copy.
768 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
770 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) );
774 * @brief Connect a function object using FunctorDelegate.
777 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
778 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
780 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
782 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) );
786 * @brief Emit the signal.
789 * @param[in] arg0 The first value to pass to callbacks.
790 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
792 Ret Emit( Arg0 arg0 )
794 return mImpl.EmitReturn< Ret,Arg0 >(arg0);
799 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
800 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
804 // Use composition instead of inheritance (virtual methods don't mix well with templates)
805 BaseSignal mImpl; ///< Implementation
809 * @brief A template for Signals with 2 parameters.
813 template < typename Arg0, typename Arg1 >
814 class Signal< void ( Arg0, Arg1 ) >
819 * @brief Default constructor.
828 * @brief Non-virtual destructor.
837 * @brief Query whether there are any connected slots.
840 * @return True if there are any slots connected to the signal.
844 return mImpl.Empty();
848 * @brief Query the number of slots.
851 * @return The number of slots connected to this signal.
853 std::size_t GetConnectionCount() const
855 return mImpl.GetConnectionCount();
858 * @brief Connect a function.
861 * @param[in] func The function to connect.
863 void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
865 mImpl.OnConnect( MakeCallback( func ) );
869 * @brief Disconnect a function.
872 * @param[in] func The function to disconnect.
874 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) )
876 mImpl.OnDisconnect( MakeCallback( func ) );
880 * @brief Connect a member function.
883 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
884 * @param[in] func The member function to connect.
887 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
889 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
893 * @brief Disconnect a member function.
896 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
897 * @param[in] func The member function to disconnect.
900 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
902 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
906 * @brief Connect a member function.
909 * @param[in] delegate A slot delegate.
910 * @param[in] func The member function to connect.
913 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
915 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
919 * @brief Disconnect a member function.
922 * @param[in] delegate A slot delegate.
923 * @param[in] func The member function to disconnect.
926 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) )
928 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
932 * @brief Connect a function object.
935 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
936 * @param[in] func The function object to copy.
939 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
941 mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) );
945 * @brief Connect a function object using FunctorDelegate.
948 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
949 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
951 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
953 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) );
957 * @brief Emit the signal.
960 * @param[in] arg0 The first value to pass to callbacks.
961 * @param[in] arg1 The second value to pass to callbacks.
963 void Emit( Arg0 arg0, Arg1 arg1 )
965 mImpl.Emit< Arg0,Arg1 >( arg0, arg1 );
970 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
971 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
975 // Use composition instead of inheritance (virtual methods don't mix well with templates)
976 BaseSignal mImpl; ///< Implementation
980 * @brief A template for Signals with 2 parameters and a return value.
983 template < typename Ret, typename Arg0, typename Arg1 >
984 class Signal< Ret( Arg0, Arg1 ) >
989 * @brief Default constructor.
997 * @brief Non-virtual destructor.
1005 * @brief Query whether there are any connected slots.
1008 * @return True if there are any slots connected to the signal.
1012 return mImpl.Empty();
1016 * @brief Query the number of slots.
1019 * @return The number of slots connected to this signal.
1021 std::size_t GetConnectionCount() const
1023 return mImpl.GetConnectionCount();
1026 * @brief Connect a function.
1028 * @param[in] func The function to connect.
1030 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1032 mImpl.OnConnect( MakeCallback( func ) );
1036 * @brief Disconnect a function.
1039 * @param[in] func The function to disconnect.
1041 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) )
1043 mImpl.OnDisconnect( MakeCallback( func ) );
1047 * @brief Connect a member function.
1050 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1051 * @param[in] func The member function to connect.
1054 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1056 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1060 * @brief Disconnect a member function.
1063 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1064 * @param[in] func The member function to disconnect.
1067 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1069 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1073 * @brief Connect a member function.
1076 * @param[in] delegate A slot delegate.
1077 * @param[in] func The member function to connect.
1080 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1082 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1086 * @brief Disconnect a member function.
1089 * @param[in] delegate A slot delegate.
1090 * @param[in] func The member function to disconnect.
1093 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) )
1095 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1099 * @brief Connect a function object.
1102 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1103 * @param[in] func The function object to copy.
1106 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1108 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) );
1112 * @brief Connect a function object using FunctorDelegate.
1115 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1116 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1118 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1120 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) );
1124 * @brief Emit the signal.
1127 * @param[in] arg0 The first value to pass to callbacks.
1128 * @param[in] arg1 The second value to pass to callbacks.
1129 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
1131 Ret Emit( Arg0 arg0, Arg1 arg1 )
1133 return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 );
1138 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1139 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1143 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1144 BaseSignal mImpl; ///< Implementation
1148 * @brief A template for Signals with 3 parameters.
1151 template < typename Arg0, typename Arg1, typename Arg2 >
1152 class Signal< void ( Arg0, Arg1, Arg2 ) >
1157 * @brief Default constructor.
1165 * @brief Non-virtual destructor.
1173 * @brief Query whether there are any connected slots.
1176 * @return True if there are any slots connected to the signal.
1180 return mImpl.Empty();
1184 * @brief Query the number of slots.
1187 * @return The number of slots connected to this signal.
1189 std::size_t GetConnectionCount() const
1191 return mImpl.GetConnectionCount();
1194 * @brief Connect a function.
1197 * @param[in] func The function to connect.
1199 void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1201 mImpl.OnConnect( MakeCallback( func ) );
1205 * @brief Disconnect a function.
1208 * @param[in] func The function to disconnect.
1210 void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1212 mImpl.OnDisconnect( MakeCallback( func ) );
1216 * @brief Connect a member function.
1219 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1220 * @param[in] func The member function to connect.
1223 void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1225 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1229 * @brief Disconnect a member function.
1232 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1233 * @param[in] func The member function to disconnect.
1236 void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1238 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1242 * @brief Connect a member function.
1245 * @param[in] delegate A slot delegate.
1246 * @param[in] func The member function to connect.
1249 void Connect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1251 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1255 * @brief Disconnect a member function.
1258 * @param[in] delegate A slot delegate.
1259 * @param[in] func The member function to disconnect.
1262 void Disconnect( SlotDelegate<X>& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1264 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1268 * @brief Connect a function object.
1271 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1272 * @param[in] func The function object to copy.
1275 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1277 mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) );
1281 * @brief Connect a function object using FunctorDelegate.
1284 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1285 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1287 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1289 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) );
1293 * @brief Emit the signal.
1296 * @param[in] arg0 The first value to pass to callbacks.
1297 * @param[in] arg1 The second value to pass to callbacks.
1298 * @param[in] arg2 The third value to pass to callbacks.
1300 void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1302 mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1307 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1308 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1312 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1313 BaseSignal mImpl; ///< Implementation
1317 * @brief A template for Signals with 2 parameters and a return value.
1320 template < typename Ret, typename Arg0, typename Arg1, typename Arg2 >
1321 class Signal< Ret( Arg0, Arg1, Arg2 ) >
1326 * @brief Default constructor.
1334 * @brief Non-virtual destructor.
1342 * @brief Query whether there are any connected slots.
1345 * @return True if there are any slots connected to the signal.
1349 return mImpl.Empty();
1353 * @brief Query the number of slots.
1356 * @return The number of slots connected to this signal.
1358 std::size_t GetConnectionCount() const
1360 return mImpl.GetConnectionCount();
1364 * @brief Connect a function.
1367 * @param[in] func The function to connect.
1369 void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1371 mImpl.OnConnect( MakeCallback( func ) );
1375 * @brief Disconnect a function.
1378 * @param[in] func The function to disconnect.
1380 void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1382 mImpl.OnDisconnect( MakeCallback( func ) );
1386 * @brief Connect a member function.
1389 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1390 * @param[in] func The member function to connect.
1393 void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1395 mImpl.OnConnect( obj, MakeCallback( obj, func ) );
1399 * @brief Disconnect a member function.
1402 * @param[in] obj An object which must implement the ConnectionTrackerInterface.
1403 * @param[in] func The member function to disconnect.
1406 void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1408 mImpl.OnDisconnect( obj, MakeCallback( obj, func ) );
1412 * @brief Connect a member function.
1415 * @param[in] delegate A slot delegate.
1416 * @param[in] func The member function to connect.
1419 void Connect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1421 mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1425 * @brief Disconnect a member function.
1428 * @param[in] delegate A slot delegate.
1429 * @param[in] func The member function to disconnect.
1432 void Disconnect( SlotDelegate<X>& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) )
1434 mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) );
1438 * @brief Connect a function object.
1441 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1442 * @param[in] func The function object to copy.
1445 void Connect( ConnectionTrackerInterface* connectionTracker, const X& func )
1447 mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) );
1451 * @brief Connect a function object using FunctorDelegate.
1454 * @param[in] connectionTracker A connection tracker which can be used to disconnect.
1455 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken).
1457 void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate )
1459 mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) );
1463 * @brief Emit the signal.
1466 * @param[in] arg0 The first value to pass to callbacks.
1467 * @param[in] arg1 The second value to pass to callbacks.
1468 * @param[in] arg2 The third value to pass to callbacks.
1469 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected.
1471 Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 )
1473 return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 );
1478 Signal( const Signal& ); ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
1479 Signal& operator=( const Signal& ); ///< undefined assignment operator @SINCE_1_0.0
1483 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1484 BaseSignal mImpl; ///< Implementation
1492 #endif // __DALI_SIGNAL_H__