31#include <boost/asio/defer.hpp>
40 auto i = m_faces.find(
id);
41 return i == m_faces.end() ? nullptr : i->second.get();
47 return m_faces.size();
54 NFD_LOG_WARN(
"Trying to add existing face id=" << face->getId() <<
" to the face table");
58 FaceId faceId = ++m_lastFaceId;
60 this->addImpl(std::move(face), faceId);
68 this->addImpl(std::move(face), faceId);
72FaceTable::addImpl(shared_ptr<Face> facePtr, FaceId faceId)
74 facePtr->setId(faceId);
75 auto [it, isNew] = m_faces.try_emplace(faceId, std::move(facePtr));
77 auto& face = *it->second;
80 " remote=" << face.getRemoteUri() <<
81 " local=" << face.getLocalUri());
83 connectFaceClosedSignal(face, [
this, faceId] { remove(faceId); });
89FaceTable::remove(FaceId faceId)
91 auto i = m_faces.find(faceId);
92 BOOST_ASSERT(i != m_faces.end());
93 shared_ptr<Face> face = i->second;
101 " remote=" << face->getRemoteUri() <<
102 " local=" << face->getLocalUri());
109FaceTable::getForwardRange()
const
111 return m_faces | boost::adaptors::map_values | boost::adaptors::indirected;
117 return this->getForwardRange().begin();
123 return this->getForwardRange().end();
const_iterator end() const
size_t size() const noexcept
Return the total number of faces.
signal::Signal< FaceTable, Face > beforeRemove
Fires immediately before a face is removed.
signal::Signal< FaceTable, Face > afterAdd
Fires immediately after a face is added.
boost::indirected_range< const boost::select_second_const_range< FaceMap > > ForwardRange
Face * get(FaceId id) const noexcept
Get face by FaceId.
const_iterator begin() const
void add(shared_ptr< Face > face)
Add a face.
void addReserved(shared_ptr< Face > face, FaceId faceId)
Add a special face with a reserved FaceId.
boost::range_iterator< ForwardRange >::type const_iterator
#define NFD_LOG_INIT(name)
constexpr FaceId INVALID_FACEID
Indicates an invalid FaceId.
constexpr FaceId FACEID_RESERVED_MAX
Upper bound of reserved FaceIds.
boost::asio::io_context & getGlobalIoService()
Returns the global io_context instance for the calling thread.