5 # ifndef VCCC_SIGNAL_SLOT_GROUP_H_
6 # define VCCC_SIGNAL_SLOT_GROUP_H_
25 template<
typename Group,
typename Slot>
33 using list = std::list<slot_ptr_type>;
35 using map = std::map<group_key_type, list_iterator, group_key_compare_type>;
45 using weak_slot = std::pair<weak_slot_ptr_type, insert_token>;
72 auto group_it = map_.upper_bound(group);
75 if (group_it == map_.end()) {
76 list_it = list_.emplace(list_.end(), std::move(
slot));
77 group_it = map_.emplace_hint(group_it, group, list_it);
79 list_it = list_.emplace(group_it->second, std::move(
slot));
80 if (group_it->first != group) {
81 group_it = map_.emplace_hint(group_it, group, list_it);
92 if (group_it == map_.end()) {
93 list_it = list_.emplace(list_.end(), std::move(
slot));
94 group_it = map_.emplace_hint(group_it, group, list_it);
96 if (group_it->first == group) {
97 list_it = list_.emplace(group_it->second, std::move(
slot));
98 group_it->second = list_it;
100 list_it = list_.emplace(group_it->second, std::move(
slot));
101 group_it = map_.emplace_hint(group_it, group, list_it);
113 auto size()
const {
return list_.size(); }
118 auto m_pos = conn.first;
119 auto l_pos = conn.second;
121 auto g_pos = map_.find(m_pos->first);
122 if (g_pos == map_.end())
125 auto next_group_l_pos = getNextGroupListPosition(m_pos);
129 }
else if (m_pos->second == l_pos) {
130 m_pos->second = list_.erase(l_pos);
138 if (g_pos == map_.end())
141 auto next_group_l_pos = getNextGroupListPosition(g_pos);
142 eraseList(g_pos->second, next_group_l_pos);
157 weak_list.reserve(
size());
159 for (
auto group_it = map_.begin(); group_it != map_.end(); ++group_it) {
160 auto list_end = getNextGroupListPosition(group_it);
161 for (
auto list_it = group_it->second; list_it != list_end; ++list_it) {
162 weak_list.emplace_back(
getWeakSlot(group_it, list_it));
175 if (it == list_.end())
182 auto next_group_m_pos =
std::next(m_pos);
183 if (next_group_m_pos == map_.end())
185 return next_group_m_pos->second;
189 if (m_pos == map_.end())
191 return m_pos->second;
195 auto pos = map_.find(group);
196 if (pos == map_.end())
207 if (next_group_map_it == map_.end())
209 return next_group_map_it->second;
constexpr VCCC_INLINE_OR_STATIC detail::next_niebloid next
Definition: next.hpp:65
std::enable_if_t< input_iterator< I >::value, std::conditional_t< detail::constant_iterator< I >::value, I, basic_const_iterator< I > > > const_iterator
Definition: basic_const_iterator.hpp:377
constexpr VCCC_INLINE_OR_STATIC detail::distance_niebloid distance
Definition: distance.hpp:72
Definition: directory.h:12
@ ungrouped_back
Definition: group_key.h:14
@ grouped
Definition: group_key.h:14
@ ungrouped_front
Definition: group_key.h:14
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 0 > key
Definition: key_value.hpp:33
slot_position
Definition: slot_group.h:21
@ at_front
Definition: slot_group.h:22
@ at_back
Definition: slot_group.h:22
Definition: group_key.h:49
Definition: group_key.h:17
Definition: slot_group.h:26
auto size() const
Definition: slot_group.h:113
void remove_group(const group_key_type &group_key)
Definition: slot_group.h:136
typename map::iterator map_iterator
Definition: slot_group.h:36
const_iterator begin() const
Definition: slot_group.h:109
typename list::const_iterator const_iterator
Definition: slot_group.h:42
weak_slot insert_front(group_key_type group, slot_ptr_type slot)
Definition: slot_group.h:88
std::list< slot_ptr_type > list
Definition: slot_group.h:33
Slot slot_type
Definition: slot_group.h:31
void remove(const insert_token &conn)
Definition: slot_group.h:117
typename list::iterator list_iterator
Definition: slot_group.h:34
weak_slot getWeakSlot(map_iterator group, list_iterator index) const
Definition: slot_group.h:151
std::weak_ptr< slot_type > weak_slot_ptr_type
Definition: slot_group.h:39
void remove_all()
Definition: slot_group.h:146
std::shared_ptr< slot_type > slot_ptr_type
Definition: slot_group.h:32
std::vector< weak_slot > weak_slot_list
Definition: slot_group.h:46
std::pair< map_iterator, list_iterator > insert_token
Definition: slot_group.h:44
Group group_type
Definition: slot_group.h:27
list_iterator iterator
Definition: slot_group.h:41
std::pair< weak_slot_ptr_type, insert_token > weak_slot
Definition: slot_group.h:45
std::map< group_key_type, list_iterator, group_key_compare_type > map
Definition: slot_group.h:35
weak_slot insert(group_type group, slot_ptr_type slot, slot_position pos=at_back)
Definition: slot_group.h:52
iterator end()
Definition: slot_group.h:110
const_iterator end() const
Definition: slot_group.h:111
iterator begin()
Definition: slot_group.h:108
weak_slot insert_back(group_key_type group, slot_ptr_type slot)
Definition: slot_group.h:71
weak_slot insert(slot_ptr_type slot, slot_position pos=at_back)
Definition: slot_group.h:61
weak_slot_list getWeakList() const
Definition: slot_group.h:155
grouped_slot_list()
Definition: slot_group.h:48
typename map::const_iterator map_const_iterator
Definition: slot_group.h:37