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 face->onReceiveData.connect(bind(&
Forwarder::onData, &m_forwarder, ref(*face), _1));
90 face->onFail.connectSingleShot(bind(&FaceTable::remove,
this, face, _1));
96 FaceTable::remove(shared_ptr<Face> face,
const std::string& reason)
100 FaceId faceId = face->getId();
101 m_faces.erase(faceId);
105 " remote=" << face->getRemoteUri() <<
106 " local=" << face->getLocalUri() <<
107 " (" << reason <<
")");
113 FaceTable::getForwardRange()
const 115 return m_faces | boost::adaptors::map_values;
121 return this->getForwardRange().begin();
127 return this->getForwardRange().end();
boost::range_iterator< ForwardRange >::type const_iterator
ForwardIterator for shared_ptr<Face>
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)
Copyright (c) 2011-2015 Regents of the University of California.
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