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;
};
diff --git a/src/detail/registered-prefix.hpp b/src/detail/registered-prefix.hpp
index 02a0ed7..36a55fa 100644
--- a/src/detail/registered-prefix.hpp
+++ b/src/detail/registered-prefix.hpp
@@ -13,10 +13,10 @@
namespace ndn {
-class RegisteredPrefix {
+class RegisteredPrefix
+{
public:
- typedef function<void
- (const Name&, const Interest&)> OnInterest;
+ typedef function<void (const Name&, const Interest&)> OnInterest;
/**
* Create a new PrefixEntry.
@@ -24,26 +24,26 @@
* @param onInterest A function object to call when a matching data packet is received.
*/
RegisteredPrefix(const Name& prefix, const OnInterest& onInterest)
- : prefix_(new Name(prefix))
- , onInterest_(onInterest)
+ : m_prefix(new Name(prefix))
+ , m_onInterest(onInterest)
{
}
-
- const Name&
+
+ const Name&
getPrefix() const
{
- return *prefix_;
+ return* m_prefix;
}
-
- const OnInterest&
+
+ const OnInterest&
getOnInterest() const
{
- return onInterest_;
+ return m_onInterest;
}
-
+
private:
- shared_ptr<Name> prefix_;
- const OnInterest onInterest_;
+ shared_ptr<Name> m_prefix;
+ const OnInterest m_onInterest;
};
@@ -54,18 +54,18 @@
*/
struct MatchRegisteredPrefixId
{
- MatchRegisteredPrefixId(const RegisteredPrefixId *registeredPrefixId)
- : id_(registeredPrefixId)
+ MatchRegisteredPrefixId(const RegisteredPrefixId* registeredPrefixId)
+ : m_id(registeredPrefixId)
{
}
bool
- operator()(const shared_ptr<RegisteredPrefix> ®isteredPrefix) const
+ operator()(const shared_ptr<RegisteredPrefix>& registeredPrefix) const
{
- return (reinterpret_cast<const RegisteredPrefixId *>(registeredPrefix.get()) == id_);
+ return (reinterpret_cast<const RegisteredPrefixId*>(registeredPrefix.get()) == m_id);
}
private:
- const RegisteredPrefixId *id_;
+ const RegisteredPrefixId* m_id;
};
} // namespace ndn