31 #include "bind_member.h"
48 operator bool()
const {
return static_cast<bool>(impl); }
51 explicit Slot(T impl) : impl(impl) { }
54 std::shared_ptr<SlotImpl> impl;
66 template<
typename SlotImplType>
70 std::vector<std::weak_ptr<SlotImplType>>
slots;
73 template<
typename FuncType>
83 std::shared_ptr<SignalImpl<SlotImplT>> sig =
signal.lock();
86 for (
auto it = sig->slots.begin(); it != sig->slots.end(); ++it)
89 if (it->expired() || it->lock().get() ==
this)
91 it = sig->slots.erase(it);
92 if (it == sig->slots.end())
99 std::weak_ptr<SignalImpl<SlotImplT>>
signal;
103 template<
typename FuncType>
109 template<
typename... Args>
112 std::vector<std::weak_ptr<SlotImplT<FuncType>>> slots = impl->slots;
115 std::shared_ptr<SlotImplT<FuncType>> slot = weak_slot.lock();
118 slot->callback(args...);
125 auto slot_impl = std::make_shared<SlotImplT<FuncType>>(impl, func);
126 impl->slots.push_back(slot_impl);
127 return Slot(slot_impl);
130 template<
typename InstanceType,
typename MemberFuncType>
137 std::shared_ptr<SignalImpl<SlotImplT<FuncType>>> impl;
143 template<
typename FuncType,
typename InstanceType,
typename MemberFuncType>
146 slots.push_back(signal.
connect(instance, func));
149 template<
typename FuncType,
typename CallbackType>
152 slots.push_back(signal.
connect(func));
156 std::vector<Slot> slots;