9#ifndef slimsig_connection_h
10#define slimsig_connection_h
18template <
class Signal>
21template <
class ThreadPolicy,
class Allocator,
class F>
25 template <
class Signal>
27 using slot =
typename Signal::slot;
28 using slot_type = slot;
29 using slot_list_iterator =
typename Signal::slot_list::iterator;
30 using slot_storage =
typename Signal::slot_list;
31 using slot_id =
typename slot::slot_id;
32 using signal_holder =
typename Signal::signal_holder;
33 connection(std::weak_ptr<signal_holder> slots,
const slot_type& slot) :
connection(std::move(slots), slot.m_slot_id) {};
34 connection(std::weak_ptr<signal_holder> slots,
const slot_id slot_id) : m_slots(std::move(slots)), m_slot_id(slot_id) {};
45 m_slot_id = rhs.m_slot_id;
46 m_slots = rhs.m_slots;
52 swap(m_slots, other.m_slots);
53 swap(m_slot_id, other.m_slot_id);
56 explicit operator bool()
const {
return connected(); };
58 const auto slots = m_slots.lock();
59 if (slots && slots->signal !=
nullptr) {
60 return slots->signal->connected(m_slot_id);
68 std::shared_ptr<signal_holder> slots = m_slots.lock();
69 if (slots !=
nullptr && slots->signal !=
nullptr) {
70 slots->signal->disconnect(m_slot_id);
75 template <
class ThreadPolicy,
class Allocator,
class F>
77 template <
class T,
class IDGenerator,
class FlagType,
class Allocator>
82 std::weak_ptr<signal_holder> m_slots;
86 template <
class connection>
102 m_connection.
swap(other.m_connection);
106 m_connection.
swap(ret);
116 template <
class connection>
connection(const connection &other)
connection & operator=(const connection &rhs)
connection(connection &&other)
void swap(connection &other)
connection & operator=(connection &&rhs)
scoped_connection(const scoped_connection &)=delete
void swap(scoped_connection &other)
scoped_connection(const connection &target)
scoped_connection(scoped_connection &&other)
scoped_connection & operator=(const connection &rhs)
scoped_connection & operator=(scoped_connection &&rhs)
scoped_connection< connection > make_scoped_connection(connection &&target)