22 #ifndef NDN_CXX_IMPL_PENDING_INTEREST_HPP 23 #define NDN_CXX_IMPL_PENDING_INTEREST_HPP 50 return os <<
"forwarder";
70 : m_interest(
std::
move(interest))
72 , m_dataCallback(dataCallback)
73 , m_nackCallback(nackCallback)
74 , m_timeoutCallback(timeoutCallback)
76 scheduleTimeoutEvent(scheduler);
83 : m_interest(
std::
move(interest))
86 scheduleTimeoutEvent(scheduler);
89 shared_ptr<const Interest>
121 BOOST_ASSERT(m_nNotNacked >= 0);
124 m_leastSevereNack = nack;
127 return m_nNotNacked > 0 ?
nullopt : m_leastSevereNack;
137 if (m_dataCallback) {
138 m_dataCallback(*m_interest, data);
149 if (m_nackCallback) {
150 m_nackCallback(*m_interest, nack);
158 m_timeoutEvent = scheduler.
schedule(m_interest->getInterestLifetime(),
159 [=] { this->invokeTimeoutCallback(); });
166 invokeTimeoutCallback()
168 if (m_timeoutCallback) {
169 m_timeoutCallback(*m_interest);
176 shared_ptr<const Interest> m_interest;
182 int m_nNotNacked = 0;
183 optional<lp::Nack> m_leastSevereNack;
188 #endif // NDN_CXX_IMPL_PENDING_INTEREST_HPP Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< const Interest > getInterest() const
std::ostream & operator<<(std::ostream &os, const Data &data)
optional< lp::Nack > recordNack(const lp::Nack &nack)
Record an incoming Nack against a forwarded Interest.
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
represents a Network Nack
NackReason getReason() 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.
Generic time-based scheduler.
PendingInterestOrigin
Indicates where a pending Interest came from.
Interest was received from the forwarder via Transport.
#define NDN_CXX_UNREACHABLE
Interest was received from this app via Face::expressInterest API.
function< void(const Interest &)> TimeoutCallback
Callback invoked when an expressed Interest times out.
function< void(const Interest &, const lp::Nack &)> NackCallback
Callback invoked when a Nack is received in response to an 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.
Template of PendingInterest, RegisteredPrefix, and InterestFilterRecord.
const nullopt_t nullopt((nullopt_t::init()))
PendingInterest(shared_ptr< const Interest > interest, Scheduler &scheduler)
Construct a pending Interest record for an Interest from the forwarder.
function< void(const Interest &, const Data &)> DataCallback
Callback invoked when an expressed Interest is satisfied by a Data packet.
void invokeDataCallback(const Data &data)
Invoke the Data callback.