23 void disconnect(Object *
object);
26 using SlotList = std::list<BoundMethodBase *>;
28 void connect(BoundMethodBase *slot);
29 void disconnect(std::function<
bool(SlotList::iterator &)> match);
37template<
typename... Args>
40 static_assert((!std::is_rvalue_reference_v<Args> && ...));
49 template<typename T, typename R, std::enable_if_t<std::is_base_of<Object, T>::value> * =
nullptr>
50 void connect(T *obj, R (T::*func)(Args...),
54 SignalBase::connect(
new BoundMethodMember<T, R, Args...>(obj,
object, func, type));
57 template<typename T, typename R, std::enable_if_t<!std::is_base_of<Object, T>::value> * =
nullptr>
59 template<
typename T,
typename R>
61 void connect(T *obj, R (T::*func)(Args...))
63 SignalBase::connect(
new BoundMethodMember<T, R, Args...>(obj,
nullptr, func));
67 template<
typename T,
typename Func,
68 std::enable_if_t<std::is_base_of<Object, T>::value &&
69 std::is_invocable_v<Func, Args...>> * =
nullptr>
73 SignalBase::connect(
new BoundMethodFunctor<T, void, Func, Args...>(obj,
object, func, type));
76 template<
typename T,
typename Func,
77 std::enable_if_t<!std::is_base_of<Object, T>::value &&
78 std::is_invocable_v<Func, Args...>> * =
nullptr>
80 template<
typename T,
typename Func>
84 SignalBase::connect(
new BoundMethodFunctor<T, void, Func, Args...>(obj,
nullptr, func));
90 SignalBase::connect(
new BoundMethodStatic<R, Args...>(func));
95 SignalBase::disconnect([]([[maybe_unused]] SlotList::iterator &iter) {
103 SignalBase::disconnect([obj](SlotList::iterator &iter) {
104 return (*iter)->match(obj);
108 template<
typename T,
typename R>
111 SignalBase::disconnect([obj, func](SlotList::iterator &iter) {
112 BoundMethodArgs<R, Args...> *slot =
113 static_cast<BoundMethodArgs<R, Args...
> *>(*iter);
115 if (!slot->match(obj))
124 return static_cast<BoundMethodMember<T, R, Args...
> *>(slot)->match(func);
131 SignalBase::disconnect([func](SlotList::iterator &iter) {
132 BoundMethodArgs<R, Args...> *slot =
133 static_cast<BoundMethodArgs<R, Args...
> *>(*iter);
135 if (!slot->match(
nullptr))
138 return static_cast<BoundMethodStatic<R, Args...
> *>(slot)->match(func);
148 for (BoundMethodBase *slot : slots())
149 static_cast<BoundMethodArgs<
void, Args...
> *>(slot)->activate(args...);
Method bind and invocation.
Base object to support automatic signal disconnection.
Definition object.h:27
Generic signal and slot communication mechanism.
Definition signal.h:39
void disconnect(R(*func)(Args...))
Disconnect the signal from the slot static function func.
Definition signal.h:129
void connect(T *obj, Func func)
Connect the signal to a function object slot.
Definition signal.h:82
void disconnect(T *obj)
Disconnect the signal from all slots of the object.
Definition signal.h:101
void disconnect()
Disconnect the signal from all slots.
Definition signal.h:93
void connect(T *obj, R(T::*func)(Args...))
Connect the signal to a member function slot.
Definition signal.h:61
void connect(R(*func)(Args...))
Connect the signal to a static function slot.
Definition signal.h:88
void disconnect(T *obj, R(T::*func)(Args...))
Disconnect the signal from the object slot member function func.
Definition signal.h:109
void emit(Args... args)
Emit the signal and call all connected slots.
Definition signal.h:142
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