22 #ifndef NDN_DETAIL_PENDING_INTEREST_HPP 23 #define NDN_DETAIL_PENDING_INTEREST_HPP 25 #include "../interest.hpp" 26 #include "../data.hpp" 27 #include "../lp/nack.hpp" 28 #include "../util/scheduler-scoped-event-id.hpp" 55 : m_interest(interest)
56 , m_dataCallback(dataCallback)
57 , m_nackCallback(nackCallback)
58 , m_timeoutCallback(timeoutCallback)
59 , m_timeoutEvent(scheduler)
62 scheduler.
scheduleEvent(m_interest->getInterestLifetime() > time::milliseconds::zero() ?
63 m_interest->getInterestLifetime() :
65 [=] { this->invokeTimeoutCallback(); });
71 shared_ptr<const Interest>
84 if (m_dataCallback !=
nullptr) {
85 m_dataCallback(*m_interest, data);
96 if (m_nackCallback !=
nullptr) {
97 m_nackCallback(*m_interest, nack);
115 invokeTimeoutCallback()
117 if (m_timeoutCallback) {
118 m_timeoutCallback(*m_interest);
121 BOOST_ASSERT(m_deleter);
126 shared_ptr<const Interest> m_interest;
131 std::function<void()> m_deleter;
137 class PendingInterestId;
147 : m_id(pendingInterestId)
152 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const 154 return reinterpret_cast<const PendingInterestId*
>(pendingInterest->getInterest().get()) == m_id;
158 const PendingInterestId* m_id;
163 #endif // NDN_DETAIL_PENDING_INTEREST_HPP Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< const Interest > getInterest() const
void setDeleter(const std::function< void()> &deleter)
Set cleanup function to be invoked when Interest times out.
EventId scheduleEvent(const time::nanoseconds &after, const Event &event)
Schedule a one-time event after the specified delay.
Functor to match PendingInterestId.
represents a Network Nack
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
void invokeNackCallback(const lp::Nack &nack)
invokes the Nack callback
PendingInterest(shared_ptr< const Interest > interest, const DataCallback &dataCallback, const NackCallback &nackCallback, const TimeoutCallback &timeoutCallback, Scheduler &scheduler)
Construct a pending Interest record.
MatchPendingInterestId(const PendingInterestId *pendingInterestId)
Event that is automatically cancelled upon destruction.
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
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.
stores a pending Interest and associated callbacks
function< void(const Interest &, const Data &)> DataCallback
Callback invoked when expressed Interest gets satisfied with a Data packet.
void invokeDataCallback(const Data &data)
invokes the Data callback