22 #ifndef NDN_CXX_IMPL_RECORD_CONTAINER_HPP 23 #define NDN_CXX_IMPL_RECORD_CONTAINER_HPP 48 BOOST_ASSERT(m_id != 0);
60 BOOST_ASSERT(m_container !=
nullptr);
61 m_container->erase(m_id);
85 auto i = m_container.find(
id);
86 if (i == m_container.end()) {
94 template<
typename ...TArgs>
98 BOOST_ASSERT(
id != 0);
99 auto it = m_container.emplace(std::piecewise_construct, std::forward_as_tuple(
id),
100 std::forward_as_tuple(std::forward<decltype(args)>(args)...));
101 BOOST_ASSERT(it.second);
103 Record& record = it.first->second;
104 record.m_container =
this;
117 template<
typename ...TArgs>
121 return put(allocateId(), std::forward<decltype(args)>(args)...);
127 m_container.erase(
id);
144 template<
typename Visitor>
148 for (
auto i = m_container.begin(); i != m_container.end(); ) {
149 bool wantErase = f(i->second);
151 i = m_container.erase(i);
166 template<
typename Visitor>
170 removeIf([&f] (
Record& record) {
179 return m_container.empty();
185 return m_container.size();
195 std::atomic<RecordId> m_lastId{0};
201 #endif // NDN_CXX_IMPL_RECORD_CONTAINER_HPP Copyright (c) 2011-2015 Regents of the University of California.
void forEach(const Visitor &f)
Visit all records.
Record & insert(TArgs &&... args)
Insert a record with newly assigned ID.
NDN_CXX_NODISCARD bool empty() const noexcept
util::Signal< RecordContainer< T > > onEmpty
Signals when container becomes empty.
void removeIf(const Visitor &f)
Visit all records with the option to erase.
Container of PendingInterest, RegisteredPrefix, or InterestFilterRecord.
size_t size() const noexcept
provides a lightweight signal / event system
void deleteSelf()
Delete this record from the container.
Common includes and macros used throughout the library.
Record & put(RecordId id, TArgs &&... args)
Insert a record with given ID.
#define NDN_CXX_NODISCARD
std::map< RecordId, Record > Container
Stores a pending Interest and associated callbacks.
Template of PendingInterest, RegisteredPrefix, and InterestFilterRecord.