src: Improving consistency and correcting code style
As of this commit, all data structures can be directly constructed from
wire format.
This commit excludes full correction of code style in security/ and
tools/ndnsec*, which will be part of a different commit.
Change-Id: I121ac1f81948bc7468990df52cdefeb2988d91a1
Refs: #1403
diff --git a/src/detail/pending-interest.hpp b/src/detail/pending-interest.hpp
index 4cfc48a..c481acc 100644
--- a/src/detail/pending-interest.hpp
+++ b/src/detail/pending-interest.hpp
@@ -20,62 +20,64 @@
typedef function<void(const Interest&)> OnTimeout;
/**
- * Create a new PitEntry and set the timeoutTime_ based on the current time and the interest lifetime.
- * @param interest A shared_ptr for the interest.
+ * @brief Create a new PitEntry and set the timeout based on the current time and
+ * the interest lifetime.
+ *
+ * @param interest A shared_ptr for the interest
* @param onData A function object to call when a matching data packet is received.
- * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it.
+ * @param onTimeout A function object to call if the interest times out.
+ * If onTimeout is an empty OnTimeout(), this does not use it.
*/
- PendingInterest(const shared_ptr<const Interest>& interest, const OnData& onData,
+ PendingInterest(const shared_ptr<const Interest>& interest, const OnData& onData,
const OnTimeout& onTimeout)
- : interest_(interest),
- onData_(onData), onTimeout_(onTimeout)
+ : interest_(interest)
+ , onData_(onData)
+ , m_onTimeout(onTimeout)
{
if (interest_->getInterestLifetime() >= time::milliseconds::zero())
- timeout_ = time::steady_clock::now() + interest_->getInterestLifetime();
+ m_timeout = time::steady_clock::now() + interest_->getInterestLifetime();
else
- timeout_ = time::steady_clock::now() + DEFAULT_INTEREST_LIFETIME;
+ m_timeout = time::steady_clock::now() + DEFAULT_INTEREST_LIFETIME;
}
-
- const shared_ptr<const Interest>&
+
+ const shared_ptr<const Interest>&
getInterest()
{
return interest_;
}
-
- const OnData&
+
+ const OnData&
getOnData()
{
return onData_;
}
-
+
/**
* Check if this interest is timed out.
* @return true if this interest timed out, otherwise false.
*/
- bool
+ bool
isTimedOut(const time::steady_clock::TimePoint& now)
{
- return now >= timeout_;
+ return now >= m_timeout;
}
/**
- * Call onTimeout_ (if defined). This ignores exceptions from the onTimeout_.
+ * Call m_onTimeout (if defined). This ignores exceptions from the m_onTimeout.
*/
- void
+ void
callTimeout()
{
- if (onTimeout_) {
- onTimeout_(*interest_);
+ if (m_onTimeout) {
+ m_onTimeout(*interest_);
}
}
-
+
private:
shared_ptr<const Interest> interest_;
const OnData onData_;
- const OnTimeout onTimeout_;
-
- /** The time when the interest times out in time::milliseconds according to getNowMilliseconds, or -1 for no timeout. */
- time::steady_clock::TimePoint timeout_;
+ const OnTimeout m_onTimeout;
+ time::steady_clock::TimePoint m_timeout;
};
@@ -86,18 +88,18 @@
*/
struct MatchPendingInterestId
{
- MatchPendingInterestId(const PendingInterestId *pendingInterestId)
- : id_(pendingInterestId)
+ MatchPendingInterestId(const PendingInterestId* pendingInterestId)
+ : m_id(pendingInterestId)
{
}
bool
- operator()(const shared_ptr<const PendingInterest> &pendingInterest) const
+ operator()(const shared_ptr<const PendingInterest>& pendingInterest) const
{
- return (reinterpret_cast<const PendingInterestId *>(pendingInterest.get()) == id_);
+ return (reinterpret_cast<const PendingInterestId*>(pendingInterest.get()) == m_id);
}
private:
- const PendingInterestId *id_;
+ const PendingInterestId* m_id;
};