31 #include <ndn-cxx/util/concepts.hpp>
42 auto i = m_faces.find(
id);
43 return i == m_faces.end() ? nullptr : i->second.get();
49 return m_faces.size();
56 NFD_LOG_WARN(
"Trying to add existing face id=" << face->getId() <<
" to the face table");
60 FaceId faceId = ++m_lastFaceId;
62 this->addImpl(std::move(face), faceId);
70 this->addImpl(std::move(face), faceId);
74 FaceTable::addImpl(shared_ptr<Face> facePtr,
FaceId faceId)
76 facePtr->setId(faceId);
77 auto [it, isNew] = m_faces.try_emplace(faceId, std::move(facePtr));
79 auto& face = *it->second;
82 " remote=" << face.getRemoteUri() <<
83 " local=" << face.getLocalUri());
91 FaceTable::remove(
FaceId faceId)
93 auto i = m_faces.find(faceId);
94 BOOST_ASSERT(i != m_faces.end());
95 shared_ptr<Face> face = i->second;
103 " remote=" << face->getRemoteUri() <<
104 " local=" << face->getLocalUri());
111 FaceTable::getForwardRange()
const
113 return m_faces | boost::adaptors::map_values | boost::adaptors::indirected;
119 return this->getForwardRange().begin();
125 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
Generalization of a network interface.
#define NFD_LOG_INIT(name)
constexpr FaceId INVALID_FACEID
Indicates an invalid FaceId.
constexpr FaceId FACEID_RESERVED_MAX
Upper bound of reserved FaceIds.
void connectFaceClosedSignal(Face &face, std::function< void()> f)
Invokes a callback when a face is closed.
uint64_t FaceId
Identifies a face.
NDN_CXX_ASSERT_FORWARD_ITERATOR(FaceTable::const_iterator)
boost::asio::io_service & getGlobalIoService()
Returns the global io_service instance for the calling thread.