24 void disconnect(Object *
object);
27 using SlotList = std::list<BoundMethodBase *>;
29 void connect(BoundMethodBase *slot);
30 void disconnect(std::function<
bool(SlotList::iterator &)> match);
38template<
typename... Args>
48 template<typename T, typename R, std::enable_if_t<std::is_base_of<Object, T>::value> * =
nullptr>
49 void connect(T *obj, R (T::*func)(Args...),
53 SignalBase::connect(
new BoundMethodMember<T, R, Args...>(obj,
object, func, type));
56 template<typename T, typename R, std::enable_if_t<!std::is_base_of<Object, T>::value> * =
nullptr>
58 template<
typename T,
typename R>
60 void connect(T *obj, R (T::*func)(Args...))
62 SignalBase::connect(
new BoundMethodMember<T, R, Args...>(obj,
nullptr, func));
66 template<
typename T,
typename Func,
67 std::enable_if_t<std::is_base_of<Object, T>::value
68#if __cplusplus >= 201703L
69 && std::is_invocable_v<Func, Args...>
75 SignalBase::connect(
new BoundMethodFunctor<T, void, Func, Args...>(obj,
object, func, type));
78 template<
typename T,
typename Func,
79 std::enable_if_t<!std::is_base_of<Object, T>::value
80#if __cplusplus >= 201703L
81 && std::is_invocable_v<Func, Args...>
85 template<
typename T,
typename Func>
89 SignalBase::connect(
new BoundMethodFunctor<T, void, Func, Args...>(obj,
nullptr, func));
95 SignalBase::connect(
new BoundMethodStatic<R, Args...>(func));
100 SignalBase::disconnect([]([[maybe_unused]] SlotList::iterator &iter) {
108 SignalBase::disconnect([obj](SlotList::iterator &iter) {
109 return (*iter)->match(obj);
113 template<
typename T,
typename R>
116 SignalBase::disconnect([obj, func](SlotList::iterator &iter) {
117 BoundMethodArgs<R, Args...> *slot =
118 static_cast<BoundMethodArgs<R, Args...
> *>(*iter);
120 if (!slot->match(obj))
129 return static_cast<BoundMethodMember<T, R, Args...
> *>(slot)->match(func);
136 SignalBase::disconnect([func](SlotList::iterator &iter) {
137 BoundMethodArgs<R, Args...> *slot =
138 static_cast<BoundMethodArgs<R, Args...
> *>(*iter);
140 if (!slot->match(
nullptr))
143 return static_cast<BoundMethodStatic<R, Args...
> *>(slot)->match(func);
153 for (BoundMethodBase *slot : slots())
154 static_cast<BoundMethodArgs<
void, Args...
> *>(slot)->activate(args...);
Method bind and invocation.
Base object to support automatic signal disconnection.
Definition object.h:25
Generic signal and slot communication mechanism.
Definition signal.h:40
void disconnect()
Disconnect the signal from all slots.
Definition signal.h:98
void emit(Args... args)
Emit the signal and call all connected slots.
Definition signal.h:147
void connect(T *obj, R(T::*func)(Args...))
Connect the signal to a member function slot.
Definition signal.h:60
void connect(R(*func)(Args...))
Connect the signal to a static function slot.
Definition signal.h:93
void connect(T *obj, Func func)
Connect the signal to a function object slot.
Definition signal.h:87
void disconnect(T *obj)
Disconnect the signal from all slots of the object.
Definition signal.h:106
void disconnect(R(*func)(Args...))
Disconnect the signal from the slot static function func.
Definition signal.h:134
void disconnect(T *obj, R(T::*func)(Args...))
Disconnect the signal from the object slot member function func.
Definition signal.h:114
Top-level libcamera namespace.
Definition backtrace.h:17
ConnectionType
Connection type for asynchronous communication.
Definition bound_method.h:19
@ ConnectionTypeAuto
If the sender and the receiver live in the same thread, ConnectionTypeDirect is used....
Definition bound_method.h:20