face: minor refactoring and Doxygen improvements
refs #3248
Change-Id: I8c44b4342b9d7b9e896dbc96fbf671d3e29bcb3c
diff --git a/src/detail/pending-interest.hpp b/src/detail/pending-interest.hpp
index bac5836..f21fc2e 100644
--- a/src/detail/pending-interest.hpp
+++ b/src/detail/pending-interest.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,28 +22,30 @@
#ifndef NDN_DETAIL_PENDING_INTEREST_HPP
#define NDN_DETAIL_PENDING_INTEREST_HPP
-#include "../common.hpp"
#include "../interest.hpp"
#include "../data.hpp"
-#include "../util/time.hpp"
-#include "../util/scheduler.hpp"
-#include "../util/scheduler-scoped-event-id.hpp"
#include "../lp/nack.hpp"
+#include "../util/scheduler-scoped-event-id.hpp"
namespace ndn {
+/**
+ * @brief stores a pending Interest and associated callbacks
+ */
class PendingInterest : noncopyable
{
public:
/**
- * @brief Create a new PitEntry and set the timeout based on the current time and
- * the Interest lifetime.
- * @param interest shared_ptr for the Interest
- * @param dataCallback function to call when matching Data packet is received
- * @param nackCallback function to call when Nack matching Interest is received
- * @param timeoutCallback function to call if Interest times out
- * @param scheduler Scheduler instance to use to schedule a timeout event. The scheduled
- * event will be automatically cancelled when pending Interest is destroyed.
+ * @brief Construct a pending Interest record
+ *
+ * The timeout is set based on the current time and the Interest lifetime.
+ * This class will invoke the timeout callback unless the record is deleted before timeout.
+ *
+ * @param interest the Interest
+ * @param dataCallback invoked when matching Data packet is received
+ * @param nackCallback invoked when Nack matching Interest is received
+ * @param timeoutCallback invoked when Interest times out
+ * @param scheduler Scheduler for scheduling the timeout event
*/
PendingInterest(shared_ptr<const Interest> interest,
const DataCallback& dataCallback,
@@ -60,7 +62,7 @@
scheduler.scheduleEvent(m_interest->getInterestLifetime() > time::milliseconds::zero() ?
m_interest->getInterestLifetime() :
DEFAULT_INTEREST_LIFETIME,
- bind(&PendingInterest::invokeTimeoutCallback, this));
+ [=] { this->invokeTimeoutCallback(); });
}
/**
@@ -73,8 +75,7 @@
}
/**
- * @brief invokes the DataCallback
- * @note If the DataCallback is an empty function, this method does nothing.
+ * @brief invokes the Data callback
*/
void
invokeDataCallback(const Data& data)
@@ -83,8 +84,7 @@
}
/**
- * @brief invokes the NackCallback
- * @note If the NackCallback is an empty function, this method does nothing.
+ * @brief invokes the Nack callback
*/
void
invokeNackCallback(const lp::Nack& nack)
@@ -93,7 +93,7 @@
}
/**
- * @brief Set cleanup function to be called after interest times out
+ * @brief Set cleanup function to be invoked when Interest times out
*/
void
setDeleter(const std::function<void()>& deleter)
@@ -103,8 +103,7 @@
private:
/**
- * @brief invokes the TimeoutCallback
- * @note If the TimeoutCallback is an empty function, this method does nothing.
+ * @brief invokes the timeout callback (if non-empty) and the deleter
*/
void
invokeTimeoutCallback()
@@ -126,11 +125,13 @@
std::function<void()> m_deleter;
};
-
+/**
+ * @brief Opaque type to identify a PendingInterest
+ */
class PendingInterestId;
/**
- * @brief Functor to match pending interests against PendingInterestId
+ * @brief Functor to match PendingInterestId
*/
class MatchPendingInterestId
{
@@ -144,14 +145,13 @@
bool
operator()(const shared_ptr<const PendingInterest>& pendingInterest) const
{
- return (reinterpret_cast<const PendingInterestId*>(
- pendingInterest->getInterest().get()) == m_id);
+ return reinterpret_cast<const PendingInterestId*>(pendingInterest->getInterest().get()) == m_id;
}
+
private:
const PendingInterestId* m_id;
};
-
} // namespace ndn
#endif // NDN_DETAIL_PENDING_INTEREST_HPP