35 : m_forwarder(forwarder)
49 return (i == m_faces.end()) ? (shared_ptr<Face>()) : (i->second);
55 return m_faces.size();
61 if (face->getId() !=
INVALID_FACEID && m_faces.count(face->getId()) > 0) {
62 NFD_LOG_WARN(
"Trying to add existing face id=" << face->getId() <<
" to the face table");
66 FaceId faceId = ++m_lastFaceId;
68 this->addImpl(face, faceId);
75 BOOST_ASSERT(m_faces.count(face->getId()) == 0);
77 this->addImpl(face, faceId);
81 FaceTable::addImpl(shared_ptr<Face> face,
FaceId faceId)
84 m_faces[faceId] = face;
85 NFD_LOG_INFO(
"Added face id=" << faceId <<
" remote=" << face->getRemoteUri()
86 <<
" local=" << face->getLocalUri());
89 &m_forwarder, ref(*face), _1);
91 &m_forwarder, ref(*face), _1);
92 face->onFail += bind(&FaceTable::remove,
99 FaceTable::remove(shared_ptr<Face> face)
103 FaceId faceId = face->getId();
104 m_faces.erase(faceId);
106 NFD_LOG_INFO(
"Removed face id=" << faceId <<
" remote=" << face->getRemoteUri() <<
107 " local=" << face->getLocalUri());
111 face->onReceiveInterest.clear();
112 face->onReceiveData .clear();
113 face->onSendInterest .clear();
114 face->onSendData .clear();
121 FaceTable::getForwardRange()
const
123 return m_faces | boost::adaptors::map_values;
129 return this->getForwardRange().begin();
135 return this->getForwardRange().end();
boost::range_iterator< ForwardRange >::type const_iterator
ForwardIterator for shared_ptr
const FaceId FACEID_RESERVED_MAX
upper bound of reserved FaceIds
const_iterator end() const
void add(shared_ptr< Face > face)
signal::Signal< FaceTable, shared_ptr< Face > > onRemove
fires before a Face is removed
#define NFD_LOG_WARN(expression)
void removeNextHopFromAllEntries(shared_ptr< Face > face)
removes the NextHop record for face in all entrites
#define NFD_LOG_INFO(expression)
void onData(Face &face, const Data &data)
boost::select_second_const_range< FaceMap > ForwardRange
void onInterest(Face &face, const Interest &interest)
#define NFD_LOG_INIT(name)
const FaceId INVALID_FACEID
indicates an invalid FaceId
FaceTable(Forwarder &forwarder)
void addReserved(shared_ptr< Face > face, FaceId faceId)
add a special Face with a reserved FaceId
const_iterator begin() const
signal::Signal< FaceTable, shared_ptr< Face > > onAdd
fires after a Face is added
shared_ptr< Face > get(FaceId id) const