22 #ifndef NDN_IMPL_PENDING_INTEREST_HPP 23 #define NDN_IMPL_PENDING_INTEREST_HPP 49 return os <<
"forwarder";
78 : m_interest(std::move(interest))
80 , m_dataCallback(dataCallback)
81 , m_nackCallback(nackCallback)
82 , m_timeoutCallback(timeoutCallback)
85 scheduleTimeoutEvent(scheduler);
95 : m_interest(std::move(interest))
99 scheduleTimeoutEvent(scheduler);
105 shared_ptr<const Interest>
137 BOOST_ASSERT(m_nNotNacked >= 0);
140 m_leastSevereNack = nack;
143 return m_nNotNacked > 0 ?
nullopt : m_leastSevereNack;
153 if (m_dataCallback !=
nullptr) {
154 m_dataCallback(*m_interest, data);
165 if (m_nackCallback !=
nullptr) {
166 m_nackCallback(*m_interest, nack);
181 scheduleTimeoutEvent(
Scheduler& scheduler)
183 m_timeoutEvent = scheduler.
scheduleEvent(m_interest->getInterestLifetime(),
184 [=] { this->invokeTimeoutCallback(); });
191 invokeTimeoutCallback()
193 if (m_timeoutCallback) {
194 m_timeoutCallback(*m_interest);
197 BOOST_ASSERT(m_deleter);
202 shared_ptr<const Interest> m_interest;
207 util::scheduler::ScopedEventId m_timeoutEvent;
209 optional<lp::Nack> m_leastSevereNack;
210 std::function<void()> m_deleter;
216 class PendingInterestId;
226 : m_id(pendingInterestId)
231 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const 233 return reinterpret_cast<const PendingInterestId*>(pendingInterest->getInterest().get()) == m_id;
237 const PendingInterestId* m_id;
242 #endif // NDN_IMPL_PENDING_INTEREST_HPP Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< const Interest > getInterest() const
Get the Interest.
std::ostream & operator<<(std::ostream &os, const Data &data)
void setDeleter(const std::function< void()> &deleter)
Set cleanup function to be invoked when Interest times out.
optional< lp::Nack > recordNack(const lp::Nack &nack)
Record an incoming Nack against a forwarded Interest.
Functor to match PendingInterestId.
EventId scheduleEvent(time::nanoseconds after, const EventCallback &callback)
Schedule a one-time event after the specified delay.
represents a Network Nack
NackReason getReason() const
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
void invokeNackCallback(const lp::Nack &nack)
Invoke the Nack callback.
void recordForwarding()
Record that the Interest has been forwarded to one destination.
PendingInterest(shared_ptr< const Interest > interest, const DataCallback &dataCallback, const NackCallback &nackCallback, const TimeoutCallback &timeoutCallback, Scheduler &scheduler)
Construct a pending Interest record for an Interest from Face::expressInterest.
MatchPendingInterestId(const PendingInterestId *pendingInterestId)
PendingInterestOrigin
Indicates where a pending Interest came from.
Interest was received from the forwarder via Transport.
Interest was received from this app via Face::expressInterest API.
function< void(const Interest &)> TimeoutCallback
Callback invoked when expressed Interest times out.
function< void(const Interest &, const lp::Nack &)> NackCallback
Callback invoked when Nack is sent in response to expressed Interest.
PendingInterestOrigin getOrigin() const
Represents a Data packet.
bool isLessSevere(lp::NackReason x, lp::NackReason y)
compare NackReason for severity
Stores a pending Interest and associated callbacks.
const nullopt_t nullopt((nullopt_t::init()))
PendingInterest(shared_ptr< const Interest > interest, Scheduler &scheduler)
Construct a pending Interest record for an Interest from NFD.
function< void(const Interest &, const Data &)> DataCallback
Callback invoked when expressed Interest gets satisfied with a Data packet.
void invokeDataCallback(const Data &data)
Invoke the Data callback.