22 #ifndef NDN_DETAIL_PENDING_INTEREST_HPP 23 #define NDN_DETAIL_PENDING_INTEREST_HPP 25 #include "../common.hpp" 26 #include "../interest.hpp" 27 #include "../data.hpp" 28 #include "../util/time.hpp" 29 #include "../util/scheduler.hpp" 30 #include "../util/scheduler-scoped-event-id.hpp" 31 #include "../lp/nack.hpp" 53 : m_interest(interest)
54 , m_dataCallback(dataCallback)
55 , m_nackCallback(nackCallback)
56 , m_timeoutCallback(timeoutCallback)
57 , m_timeoutEvent(scheduler)
60 scheduler.
scheduleEvent(m_interest->getInterestLifetime() > time::milliseconds::zero() ?
61 m_interest->getInterestLifetime() :
63 bind(&PendingInterest::invokeTimeoutCallback,
this));
69 shared_ptr<const Interest>
82 m_dataCallback(*m_interest, data);
92 m_nackCallback(*m_interest, nack);
110 invokeTimeoutCallback()
112 if (m_timeoutCallback) {
113 m_timeoutCallback(*m_interest);
116 BOOST_ASSERT(m_deleter);
121 shared_ptr<const Interest> m_interest;
126 std::function<void()> m_deleter;
130 class PendingInterestId;
140 : m_id(pendingInterestId)
145 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const 147 return (reinterpret_cast<const PendingInterestId*>(
148 pendingInterest->getInterest().get()) == m_id);
151 const PendingInterestId* m_id;
157 #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 called after interest times out.
EventId scheduleEvent(const time::nanoseconds &after, const Event &event)
Schedule one time event after the specified delay.
Functor to match pending interests against PendingInterestId.
represents a Network Nack
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
void invokeNackCallback(const lp::Nack &nack)
invokes the NackCallback
PendingInterest(shared_ptr< const Interest > interest, const DataCallback &dataCallback, const NackCallback &nackCallback, const TimeoutCallback &timeoutCallback, Scheduler &scheduler)
Create a new PitEntry and set the timeout based on the current time and the Interest lifetime...
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 called when expressed Interest times out.
function< void(const Interest &, const lp::Nack &)> NackCallback
Callback called when Nack is sent in response to expressed Interest.
function< void(const Interest &, const Data &)> DataCallback
Callback called when expressed Interest gets satisfied with a Data packet.
void invokeDataCallback(const Data &data)
invokes the DataCallback