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/base-signal.h>
58 #include <dali/public-api/signals/callback.h>
59 #include <dali/public-api/signals/signal-slot-connections.h>
60 #include <dali/public-api/signals/slot-delegate.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.
149 * @brief Default constructor.
157 * @brief Non-virtual destructor.
165 * @brief Queries whether there are any connected slots.
168 * @return True if there are any slots connected to the signal
172 return mImpl.Empty();
176 * @brief Queries 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 Connects a function.
190 * @param[in] func The function to connect
192 void Connect(void (*func)())
194 mImpl.OnConnect(MakeCallback(func));
198 * @brief Disconnects a function.
201 * @param[in] func The function to disconnect
203 void Disconnect(void (*func)())
205 mImpl.OnDisconnect(MakeCallback(func));
209 * @brief Connects 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 Disconnects 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 Connects 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 Disconnects 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 Connects 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 Connects 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 Emits the signal.
295 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
296 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
297 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
298 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
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>
314 * @brief Default constructor.
322 * @brief Non-virtual destructor.
330 * @brief Queries whether there are any connected slots.
333 * @return True if there are any slots connected to the signal
337 return mImpl.Empty();
341 * @brief Queries the number of slots.
344 * @return The number of slots connected to this signal
346 std::size_t GetConnectionCount() const
348 return mImpl.GetConnectionCount();
351 * @brief Connects a function.
354 * @param[in] func The function to connect
356 void Connect(Ret (*func)())
358 mImpl.OnConnect(MakeCallback(func));
362 * @brief Disconnects a function.
365 * @param[in] func The function to disconnect
367 void Disconnect(Ret (*func)())
369 mImpl.OnDisconnect(MakeCallback(func));
373 * @brief Connects a member function.
376 * @param[in] obj An object which must implement the ConnectionTrackerInterface
377 * @param[in] func The member function to connect
380 void Connect(X* obj, Ret (X::*func)())
382 mImpl.OnConnect(obj, MakeCallback(obj, func));
386 * @brief Disconnects a member function.
389 * @param[in] obj An object which must implement the ConnectionTrackerInterface
390 * @param[in] func The member function to disconnect
393 void Disconnect(X* obj, Ret (X::*func)())
395 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
399 * @brief Connects a member function.
402 * @param[in] delegate A slot delegate
403 * @param[in] func The member function to connect
406 void Connect(SlotDelegate<X>& delegate, Ret (X::*func)())
408 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
412 * @brief Disconnects a member function.
415 * @param[in] delegate A slot delegate
416 * @param[in] func The member function to disconnect
419 void Disconnect(SlotDelegate<X>& delegate, Ret (X::*func)())
421 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
425 * @brief Connects a function object.
428 * @param[in] connectionTracker A connection tracker which can be used to disconnect
429 * @param[in] func The function object to copy
432 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
434 mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn0<X, Ret>(func));
438 * @brief Connects a function object using FunctorDelegate.
441 * @param[in] connectionTracker A connection tracker which can be used to disconnect
442 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
444 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
446 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn0<Ret>(delegate));
450 * @brief Emits the signal.
453 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
457 return mImpl.EmitReturn<Ret>();
461 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
462 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
463 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
464 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
467 // Use composition instead of inheritance (virtual methods don't mix well with templates)
468 BaseSignal mImpl; ///< Implementation
472 * @brief A template for Signals with 1 parameter.
475 template<typename Arg0>
476 class Signal<void(Arg0)>
480 * @brief Default constructor.
488 * @brief Non-virtual destructor.
496 * @brief Queries whether there are any connected slots.
499 * @return True if there are any slots connected to the signal
503 return mImpl.Empty();
507 * @brief Queries the number of slots.
510 * @return The number of slots connected to this signal
512 std::size_t GetConnectionCount() const
514 return mImpl.GetConnectionCount();
517 * @brief Connects a function.
520 * @param[in] func The function to connect
522 void Connect(void (*func)(Arg0 arg0))
524 mImpl.OnConnect(MakeCallback(func));
528 * @brief Disconnects a function.
531 * @param[in] func The function to disconnect
533 void Disconnect(void (*func)(Arg0 arg0))
535 mImpl.OnDisconnect(MakeCallback(func));
539 * @brief Connects a member function.
542 * @param[in] obj An object which must implement the ConnectionTrackerInterface
543 * @param[in] func The member function to connect
546 void Connect(X* obj, void (X::*func)(Arg0 arg0))
548 mImpl.OnConnect(obj, MakeCallback(obj, func));
552 * @brief Disconnects a member function.
555 * @param[in] obj An object which must implement the ConnectionTrackerInterface
556 * @param[in] func The member function to disconnect
559 void Disconnect(X* obj, void (X::*func)(Arg0 arg0))
561 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
565 * @brief Connects a member function.
568 * @param[in] delegate A slot delegate
569 * @param[in] func The member function to connect
572 void Connect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0))
574 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
578 * @brief Disconnects a member function.
581 * @param[in] delegate A slot delegate
582 * @param[in] func The member function to disconnect
585 void Disconnect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0))
587 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
591 * @brief Connects a function object.
594 * @param[in] connectionTracker A connection tracker which can be used to disconnect
595 * @param[in] func The function object to copy
598 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
600 mImpl.OnConnect(connectionTracker, new CallbackFunctor1<X, Arg0>(func));
604 * @brief Connects a function object using FunctorDelegate.
607 * @param[in] connectionTracker A connection tracker which can be used to disconnect
608 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
610 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
612 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate1<Arg0>(delegate));
616 * @brief Emits the signal.
619 * @param[in] arg0 The first value to pass to callbacks
623 mImpl.Emit<Arg0>(arg0);
627 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
628 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
629 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
630 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
633 // Use composition instead of inheritance (virtual methods don't mix well with templates)
634 BaseSignal mImpl; ///< Implementation
638 * @brief A template for Signals with 1 parameter and a return value.
641 template<typename Ret, typename Arg0>
642 class Signal<Ret(Arg0)>
646 * @brief Default constructor.
654 * @brief Non-virtual destructor.
662 * @brief Queries whether there are any connected slots.
665 * @return True if there are any slots connected to the signal
669 return mImpl.Empty();
673 * @brief Queries the number of slots.
676 * @return The number of slots connected to this signal
678 std::size_t GetConnectionCount() const
680 return mImpl.GetConnectionCount();
683 * @brief Connects a function.
686 * @param[in] func The function to connect
688 void Connect(Ret (*func)(Arg0 arg0))
690 mImpl.OnConnect(MakeCallback(func));
694 * @brief Disconnects a function.
697 * @param[in] func The function to disconnect
699 void Disconnect(Ret (*func)(Arg0 arg0))
701 mImpl.OnDisconnect(MakeCallback(func));
705 * @brief Connects a member function.
708 * @param[in] obj An object which must implement the ConnectionTrackerInterface
709 * @param[in] func The member function to connect
712 void Connect(X* obj, Ret (X::*func)(Arg0 arg0))
714 mImpl.OnConnect(obj, MakeCallback(obj, func));
718 * @brief Disconnects a member function.
721 * @param[in] obj An object which must implement the ConnectionTrackerInterface
722 * @param[in] func The member function to disconnect
725 void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0))
727 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
731 * @brief Connects a member function.
734 * @param[in] delegate A slot delegate
735 * @param[in] func The member function to connect
738 void Connect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0))
740 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
744 * @brief Disconnects a member function.
747 * @param[in] delegate A slot delegate
748 * @param[in] func The member function to disconnect
751 void Disconnect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0))
753 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
757 * @brief Connects a function object.
760 * @param[in] connectionTracker A connection tracker which can be used to disconnect
761 * @param[in] func The function object to copy
764 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
766 mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn1<X, Arg0, Ret>(func));
770 * @brief Connects a function object using FunctorDelegate.
773 * @param[in] connectionTracker A connection tracker which can be used to disconnect
774 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
776 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
778 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn1<Arg0, Ret>(delegate));
782 * @brief Emits the signal.
785 * @param[in] arg0 The first value to pass to callbacks
786 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
790 return mImpl.EmitReturn<Ret, Arg0>(arg0);
794 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
795 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
796 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
797 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
800 // Use composition instead of inheritance (virtual methods don't mix well with templates)
801 BaseSignal mImpl; ///< Implementation
805 * @brief A template for Signals with 2 parameters.
809 template<typename Arg0, typename Arg1>
810 class Signal<void(Arg0, Arg1)>
814 * @brief Default constructor.
823 * @brief Non-virtual destructor.
832 * @brief Queries whether there are any connected slots.
835 * @return True if there are any slots connected to the signal
839 return mImpl.Empty();
843 * @brief Queries the number of slots.
846 * @return The number of slots connected to this signal
848 std::size_t GetConnectionCount() const
850 return mImpl.GetConnectionCount();
853 * @brief Connects a function.
856 * @param[in] func The function to connect
858 void Connect(void (*func)(Arg0 arg0, Arg1 arg1))
860 mImpl.OnConnect(MakeCallback(func));
864 * @brief Disconnects a function.
867 * @param[in] func The function to disconnect
869 void Disconnect(void (*func)(Arg0 arg0, Arg1 arg1))
871 mImpl.OnDisconnect(MakeCallback(func));
875 * @brief Connects a member function.
878 * @param[in] obj An object which must implement the ConnectionTrackerInterface
879 * @param[in] func The member function to connect
882 void Connect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1))
884 mImpl.OnConnect(obj, MakeCallback(obj, func));
888 * @brief Disconnects a member function.
891 * @param[in] obj An object which must implement the ConnectionTrackerInterface
892 * @param[in] func The member function to disconnect
895 void Disconnect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1))
897 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
901 * @brief Connects a member function.
904 * @param[in] delegate A slot delegate
905 * @param[in] func The member function to connect
908 void Connect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1))
910 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
914 * @brief Disconnects a member function.
917 * @param[in] delegate A slot delegate
918 * @param[in] func The member function to disconnect
921 void Disconnect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1))
923 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
927 * @brief Connects a function object.
930 * @param[in] connectionTracker A connection tracker which can be used to disconnect
931 * @param[in] func The function object to copy
934 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
936 mImpl.OnConnect(connectionTracker, new CallbackFunctor2<X, Arg0, Arg1>(func));
940 * @brief Connects a function object using FunctorDelegate.
943 * @param[in] connectionTracker A connection tracker which can be used to disconnect
944 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
946 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
948 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate2<Arg0, Arg1>(delegate));
952 * @brief Emits the signal.
955 * @param[in] arg0 The first value to pass to callbacks
956 * @param[in] arg1 The second value to pass to callbacks
958 void Emit(Arg0 arg0, Arg1 arg1)
960 mImpl.Emit<Arg0, Arg1>(arg0, arg1);
964 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
965 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
966 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
967 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
970 // Use composition instead of inheritance (virtual methods don't mix well with templates)
971 BaseSignal mImpl; ///< Implementation
975 * @brief A template for Signals with 2 parameters and a return value.
978 template<typename Ret, typename Arg0, typename Arg1>
979 class Signal<Ret(Arg0, Arg1)>
983 * @brief Default constructor.
991 * @brief Non-virtual destructor.
999 * @brief Queries whether there are any connected slots.
1002 * @return True if there are any slots connected to the signal
1006 return mImpl.Empty();
1010 * @brief Queries the number of slots.
1013 * @return The number of slots connected to this signal
1015 std::size_t GetConnectionCount() const
1017 return mImpl.GetConnectionCount();
1020 * @brief Connects a function.
1022 * @param[in] func The function to connect
1024 void Connect(Ret (*func)(Arg0 arg0, Arg1 arg1))
1026 mImpl.OnConnect(MakeCallback(func));
1030 * @brief Disconnects a function.
1033 * @param[in] func The function to disconnect
1035 void Disconnect(Ret (*func)(Arg0 arg0, Arg1 arg1))
1037 mImpl.OnDisconnect(MakeCallback(func));
1041 * @brief Connects a member function.
1044 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1045 * @param[in] func The member function to connect
1048 void Connect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1))
1050 mImpl.OnConnect(obj, MakeCallback(obj, func));
1054 * @brief Disconnects a member function.
1057 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1058 * @param[in] func The member function to disconnect
1061 void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1))
1063 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
1067 * @brief Connects a member function.
1070 * @param[in] delegate A slot delegate
1071 * @param[in] func The member function to connect
1074 void Connect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1))
1076 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1080 * @brief Disconnects a member function.
1083 * @param[in] delegate A slot delegate
1084 * @param[in] func The member function to disconnect
1087 void Disconnect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1))
1089 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1093 * @brief Connects a function object.
1096 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1097 * @param[in] func The function object to copy
1100 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
1102 mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn2<X, Arg0, Arg1, Ret>(func));
1106 * @brief Connects a function object using FunctorDelegate.
1109 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1110 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1112 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
1114 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn2<Arg0, Arg1, Ret>(delegate));
1118 * @brief Emits the signal.
1121 * @param[in] arg0 The first value to pass to callbacks
1122 * @param[in] arg1 The second value to pass to callbacks
1123 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
1125 Ret Emit(Arg0 arg0, Arg1 arg1)
1127 return mImpl.EmitReturn<Ret, Arg0, Arg1>(arg0, arg1);
1131 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1132 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1133 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1134 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1137 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1138 BaseSignal mImpl; ///< Implementation
1142 * @brief A template for Signals with 3 parameters.
1145 template<typename Arg0, typename Arg1, typename Arg2>
1146 class Signal<void(Arg0, Arg1, Arg2)>
1150 * @brief Default constructor.
1158 * @brief Non-virtual destructor.
1166 * @brief Queries whether there are any connected slots.
1169 * @return True if there are any slots connected to the signal
1173 return mImpl.Empty();
1177 * @brief Queries the number of slots.
1180 * @return The number of slots connected to this signal
1182 std::size_t GetConnectionCount() const
1184 return mImpl.GetConnectionCount();
1187 * @brief Connects a function.
1190 * @param[in] func The function to connect
1192 void Connect(void (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1194 mImpl.OnConnect(MakeCallback(func));
1198 * @brief Disconnects a function.
1201 * @param[in] func The function to disconnect
1203 void Disconnect(void (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1205 mImpl.OnDisconnect(MakeCallback(func));
1209 * @brief Connects a member function.
1212 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1213 * @param[in] func The member function to connect
1216 void Connect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1218 mImpl.OnConnect(obj, MakeCallback(obj, func));
1222 * @brief Disconnects a member function.
1225 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1226 * @param[in] func The member function to disconnect
1229 void Disconnect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1231 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
1235 * @brief Connects a member function.
1238 * @param[in] delegate A slot delegate
1239 * @param[in] func The member function to connect
1242 void Connect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1244 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1248 * @brief Disconnects a member function.
1251 * @param[in] delegate A slot delegate
1252 * @param[in] func The member function to disconnect
1255 void Disconnect(SlotDelegate<X>& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1257 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1261 * @brief Connects a function object.
1264 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1265 * @param[in] func The function object to copy
1268 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
1270 mImpl.OnConnect(connectionTracker, new CallbackFunctor3<X, Arg0, Arg1, Arg2>(func));
1274 * @brief Connects a function object using FunctorDelegate.
1277 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1278 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1280 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
1282 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate3<Arg0, Arg1, Arg2>(delegate));
1286 * @brief Emits the signal.
1289 * @param[in] arg0 The first value to pass to callbacks
1290 * @param[in] arg1 The second value to pass to callbacks
1291 * @param[in] arg2 The third value to pass to callbacks
1293 void Emit(Arg0 arg0, Arg1 arg1, Arg2 arg2)
1295 mImpl.Emit<Arg0, Arg1, Arg2>(arg0, arg1, arg2);
1299 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1300 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1301 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1302 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1305 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1306 BaseSignal mImpl; ///< Implementation
1310 * @brief A template for Signals with 2 parameters and a return value.
1313 template<typename Ret, typename Arg0, typename Arg1, typename Arg2>
1314 class Signal<Ret(Arg0, Arg1, Arg2)>
1318 * @brief Default constructor.
1326 * @brief Non-virtual destructor.
1334 * @brief Queries whether there are any connected slots.
1337 * @return True if there are any slots connected to the signal
1341 return mImpl.Empty();
1345 * @brief Queries the number of slots.
1348 * @return The number of slots connected to this signal
1350 std::size_t GetConnectionCount() const
1352 return mImpl.GetConnectionCount();
1356 * @brief Connects a function.
1359 * @param[in] func The function to connect
1361 void Connect(Ret (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1363 mImpl.OnConnect(MakeCallback(func));
1367 * @brief Disconnects a function.
1370 * @param[in] func The function to disconnect
1372 void Disconnect(Ret (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1374 mImpl.OnDisconnect(MakeCallback(func));
1378 * @brief Connects a member function.
1381 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1382 * @param[in] func The member function to connect
1385 void Connect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1387 mImpl.OnConnect(obj, MakeCallback(obj, func));
1391 * @brief Disconnects a member function.
1394 * @param[in] obj An object which must implement the ConnectionTrackerInterface
1395 * @param[in] func The member function to disconnect
1398 void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1400 mImpl.OnDisconnect(obj, MakeCallback(obj, func));
1404 * @brief Connects a member function.
1407 * @param[in] delegate A slot delegate
1408 * @param[in] func The member function to connect
1411 void Connect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1413 mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1417 * @brief Disconnects a member function.
1420 * @param[in] delegate A slot delegate
1421 * @param[in] func The member function to disconnect
1424 void Disconnect(SlotDelegate<X>& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2))
1426 mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func));
1430 * @brief Connects a function object.
1433 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1434 * @param[in] func The function object to copy
1437 void Connect(ConnectionTrackerInterface* connectionTracker, const X& func)
1439 mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn3<X, Arg0, Arg1, Arg2, Ret>(func));
1443 * @brief Connects a function object using FunctorDelegate.
1446 * @param[in] connectionTracker A connection tracker which can be used to disconnect
1447 * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken)
1449 void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate)
1451 mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn3<Arg0, Arg1, Arg2, Ret>(delegate));
1455 * @brief Emits the signal.
1458 * @param[in] arg0 The first value to pass to callbacks
1459 * @param[in] arg1 The second value to pass to callbacks
1460 * @param[in] arg2 The third value to pass to callbacks
1461 * @return The value returned by the last callback, or a default constructed value if no callbacks are connected
1463 Ret Emit(Arg0 arg0, Arg1 arg1, Arg2 arg2)
1465 return mImpl.EmitReturn<Ret, Arg0, Arg1, Arg2>(arg0, arg1, arg2);
1469 Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
1470 Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
1471 Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
1472 Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
1475 // Use composition instead of inheritance (virtual methods don't mix well with templates)
1476 BaseSignal mImpl; ///< Implementation
1484 #endif // DALI_SIGNAL_H