22 #ifndef NDN_DETAIL_PENDING_INTEREST_HPP 23 #define NDN_DETAIL_PENDING_INTEREST_HPP 25 #include "../data.hpp" 26 #include "../interest.hpp" 27 #include "../lp/nack.hpp" 28 #include "../util/scheduler-scoped-event-id.hpp" 48 return os <<
"forwarder";
77 : m_interest(
std::move(interest))
79 , m_dataCallback(dataCallback)
80 , m_nackCallback(nackCallback)
81 , m_timeoutCallback(timeoutCallback)
82 , m_timeoutEvent(scheduler)
85 scheduleTimeoutEvent(scheduler);
95 : m_interest(
std::move(interest))
97 , m_timeoutEvent(scheduler)
100 scheduleTimeoutEvent(scheduler);
106 shared_ptr<const Interest>
138 BOOST_ASSERT(m_nNotNacked >= 0);
141 m_leastSevereNack = nack;
144 return m_nNotNacked > 0 ?
nullopt : m_leastSevereNack;
154 if (m_dataCallback !=
nullptr) {
155 m_dataCallback(*m_interest, data);
166 if (m_nackCallback !=
nullptr) {
167 m_nackCallback(*m_interest, nack);
182 scheduleTimeoutEvent(Scheduler& scheduler)
184 m_timeoutEvent = scheduler.scheduleEvent(m_interest->getInterestLifetime(),
185 [=] { this->invokeTimeoutCallback(); });
192 invokeTimeoutCallback()
194 if (m_timeoutCallback) {
195 m_timeoutCallback(*m_interest);
198 BOOST_ASSERT(m_deleter);
203 shared_ptr<const Interest> m_interest;
211 std::function<void()> m_deleter;
217 class PendingInterestId;
227 : m_id(pendingInterestId)
232 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const 234 return reinterpret_cast<const PendingInterestId*
>(pendingInterest->getInterest().get()) == m_id;
238 const PendingInterestId* m_id;
243 #endif // NDN_DETAIL_PENDING_INTEREST_HPP constexpr nullopt_t nullopt
Copyright (c) 2011-2015 Regents of the University of California.
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.
shared_ptr< const Interest > getInterest() const
Get the Interest.
represents a Network Nack
NackReason getReason() const
PendingInterestOrigin getOrigin() 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)
Event that is automatically cancelled upon destruction.
PendingInterestOrigin
Indicates where a pending Interest came from.
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
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.
Represents a Data packet.
bool isLessSevere(lp::NackReason x, lp::NackReason y)
compare NackReason for severity
Stores a pending Interest and associated callbacks.
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.