2 #include <score/model/IdentifiedObjectMap.hpp>
4 #include <nano_signal_slot.hpp>
12 template <
typename T,
bool Ordered>
14 template <
typename T,
bool Ordered>
34 template <
typename T,
bool Ordered = false>
40 OSSIA_INLINE
auto begin()
const INLINE_EXPORT {
return m_map.begin(); }
42 OSSIA_INLINE
auto cbegin()
const INLINE_EXPORT {
return m_map.cbegin(); }
43 OSSIA_INLINE
auto end()
const INLINE_EXPORT {
return m_map.end(); }
45 OSSIA_INLINE
auto cend()
const INLINE_EXPORT {
return m_map.cend(); }
46 OSSIA_INLINE
auto size()
const INLINE_EXPORT {
return m_map.size(); }
47 OSSIA_INLINE
bool empty()
const INLINE_EXPORT {
return m_map.empty(); }
48 OSSIA_INLINE
auto& unsafe_map() INLINE_EXPORT {
return m_map; }
49 OSSIA_INLINE
const auto& map()
const INLINE_EXPORT {
return m_map; }
50 OSSIA_INLINE
const auto& get()
const INLINE_EXPORT {
return m_map.m_map; }
51 T& at(
const Id<T>&
id) INLINE_EXPORT {
return m_map.at(
id); }
52 T& at(
const Id<T>&
id)
const INLINE_EXPORT {
return m_map.at(
id); }
53 auto find(
const Id<T>&
id)
const INLINE_EXPORT {
return m_map.find(
id); }
56 mutable Nano::Signal<void(T&)> mutable_added;
57 mutable Nano::Signal<void(
const T&)> added;
58 mutable Nano::Signal<void(
const T&)> removing;
59 mutable Nano::Signal<void(
const T&)> removed;
60 mutable Nano::Signal<void()> orderChanged;
61 mutable Nano::Signal<void()> replaced;
65 void erase(T& elt) INLINE_EXPORT
68 m_map.remove(elt.id());
72 void remove(T& elt) INLINE_EXPORT
75 m_map.remove(elt.id());
80 void remove(T* elt) INLINE_EXPORT
83 m_map.remove(elt->id());
88 void remove(
const Id<T>&
id) INLINE_EXPORT
90 auto it = m_map.m_map.find(
id);
93 auto& elt = *it->second.first;
102 auto& elt = *it->second;
111 void clear() INLINE_EXPORT
113 while(!m_map.empty())
115 remove(*m_map.begin());
125 m_map.m_map = std::move(new_map.m_map);
126 if constexpr(Ordered)
128 m_map.m_order = std::move(new_map.m_order);
138 template <
typename T,
bool O>
142 map.unsafe_map().insert(t);
144 map.mutable_added(*t);
A map to access child objects through their id.
Definition: IdentifiedObjectMap.hpp:16
The id_base_t class.
Definition: Identifier.hpp:57
The EntityMap class.
Definition: EntityMap.hpp:36
Definition: EntityMap.hpp:16
Base toolkit upon which the software is built.
Definition: Application.cpp:90