mgmt: move Route and RibEntry set methods out of line

Also add missing m_wire.reset() in RibEntry::clearRoutes().

Change-Id: I715d8d5a4f8fe2a4caf6dfce389a04d0d1d542b5
Refs: #3903
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index d8293d5..ed7fd67 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -53,7 +53,48 @@
 
 Route::Route(const Block& block)
 {
-  wireDecode(block);
+  this->wireDecode(block);
+}
+
+Route&
+Route::setFaceId(uint64_t faceId)
+{
+  m_faceId = faceId;
+  m_wire.reset();
+  return *this;
+}
+
+Route&
+Route::setOrigin(uint64_t origin)
+{
+  m_origin = origin;
+  m_wire.reset();
+  return *this;
+}
+
+Route&
+Route::setCost(uint64_t cost)
+{
+  m_cost = cost;
+  m_wire.reset();
+  return *this;
+}
+
+Route&
+Route::setFlags(uint64_t flags)
+{
+  m_flags = flags;
+  m_wire.reset();
+  return *this;
+}
+
+Route&
+Route::setExpirationPeriod(time::milliseconds expirationPeriod)
+{
+  m_expirationPeriod = expirationPeriod;
+  m_hasInfiniteExpirationPeriod = m_expirationPeriod == INFINITE_EXPIRATION_PERIOD;
+  m_wire.reset();
+  return *this;
 }
 
 template<encoding::Tag TAG>
@@ -64,30 +105,16 @@
 
   // Absence of an ExpirationPeriod signifies non-expiration
   if (!m_hasInfiniteExpirationPeriod) {
-    totalLength += prependNonNegativeIntegerBlock(block,
-                                                  ndn::tlv::nfd::ExpirationPeriod,
-                                                  m_expirationPeriod.count());
+    totalLength += prependNonNegativeIntegerBlock(block, ndn::tlv::nfd::ExpirationPeriod,
+                                                  static_cast<uint64_t>(m_expirationPeriod.count()));
   }
-
-  totalLength += prependNonNegativeIntegerBlock(block,
-                                                ndn::tlv::nfd::Flags,
-                                                m_flags);
-
-  totalLength += prependNonNegativeIntegerBlock(block,
-                                                ndn::tlv::nfd::Cost,
-                                                m_cost);
-
-  totalLength += prependNonNegativeIntegerBlock(block,
-                                                ndn::tlv::nfd::Origin,
-                                                m_origin);
-
-  totalLength += prependNonNegativeIntegerBlock(block,
-                                                ndn::tlv::nfd::FaceId,
-                                                m_faceId);
+  totalLength += prependNonNegativeIntegerBlock(block, ndn::tlv::nfd::Flags, m_flags);
+  totalLength += prependNonNegativeIntegerBlock(block, ndn::tlv::nfd::Cost, m_cost);
+  totalLength += prependNonNegativeIntegerBlock(block, ndn::tlv::nfd::Origin, m_origin);
+  totalLength += prependNonNegativeIntegerBlock(block, ndn::tlv::nfd::FaceId, m_faceId);
 
   totalLength += block.prependVarNumber(totalLength);
   totalLength += block.prependVarNumber(ndn::tlv::nfd::Route);
-
   return totalLength;
 }
 
@@ -100,9 +127,8 @@
 const Block&
 Route::wireEncode() const
 {
-  if (m_wire.hasWire()) {
+  if (m_wire.hasWire())
     return m_wire;
-  }
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
@@ -111,7 +137,6 @@
   wireEncode(buffer);
 
   m_wire = buffer.block();
-
   return m_wire;
 }
 
@@ -200,21 +225,38 @@
   return os;
 }
 
+////////////////////
 
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-
-
-RibEntry::RibEntry()
-{
-}
+RibEntry::RibEntry() = default;
 
 RibEntry::RibEntry(const Block& block)
 {
-  wireDecode(block);
+  this->wireDecode(block);
 }
 
+RibEntry&
+RibEntry::setName(const Name& prefix)
+{
+  m_prefix = prefix;
+  m_wire.reset();
+  return *this;
+}
+
+RibEntry&
+RibEntry::addRoute(const Route& route)
+{
+  m_routes.push_back(route);
+  m_wire.reset();
+  return *this;
+}
+
+RibEntry&
+RibEntry::clearRoutes()
+{
+  m_routes.clear();
+  m_wire.reset();
+  return *this;
+}
 
 template<encoding::Tag TAG>
 size_t
@@ -232,7 +274,6 @@
 
   totalLength += block.prependVarNumber(totalLength);
   totalLength += block.prependVarNumber(tlv::nfd::RibEntry);
-
   return totalLength;
 }
 
@@ -245,9 +286,8 @@
 const Block&
 RibEntry::wireEncode() const
 {
-  if (m_wire.hasWire()) {
+  if (m_wire.hasWire())
     return m_wire;
-  }
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
@@ -256,7 +296,6 @@
   wireEncode(buffer);
 
   m_wire = buffer.block();
-
   return m_wire;
 }
 
diff --git a/src/mgmt/nfd/rib-entry.hpp b/src/mgmt/nfd/rib-entry.hpp
index 6c1c5a2..b0d7289 100644
--- a/src/mgmt/nfd/rib-entry.hpp
+++ b/src/mgmt/nfd/rib-entry.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,7 +22,7 @@
 #ifndef NDN_MGMT_NFD_RIB_ENTRY_HPP
 #define NDN_MGMT_NFD_RIB_ENTRY_HPP
 
-#include "rib-flags.hpp" // include this first, to ensure it compiles on its own.
+#include "rib-flags.hpp"
 #include "../../name.hpp"
 #include "../../util/time.hpp"
 
@@ -55,7 +55,8 @@
   {
   public:
     explicit
-    Error(const std::string& what) : tlv::Error(what)
+    Error(const std::string& what)
+      : tlv::Error(what)
     {
     }
   };
@@ -72,12 +73,7 @@
   }
 
   Route&
-  setFaceId(uint64_t faceId)
-  {
-    m_faceId = faceId;
-    m_wire.reset();
-    return *this;
-  }
+  setFaceId(uint64_t faceId);
 
   uint64_t
   getOrigin() const
@@ -89,12 +85,7 @@
    *  @param origin a code defined in ndn::nfd::RouteOrigin
    */
   Route&
-  setOrigin(uint64_t origin)
-  {
-    m_origin = origin;
-    m_wire.reset();
-    return *this;
-  }
+  setOrigin(uint64_t origin);
 
   uint64_t
   getCost() const
@@ -103,12 +94,7 @@
   }
 
   Route&
-  setCost(uint64_t cost)
-  {
-    m_cost = cost;
-    m_wire.reset();
-    return *this;
-  }
+  setCost(uint64_t cost);
 
   uint64_t
   getFlags() const
@@ -120,31 +106,18 @@
    *  @param flags a bitwise OR'ed code from ndn::nfd::RouteFlags
    */
   Route&
-  setFlags(uint64_t flags)
-  {
-    m_flags = flags;
-    m_wire.reset();
-    return *this;
-  }
+  setFlags(uint64_t flags);
 
   static const time::milliseconds INFINITE_EXPIRATION_PERIOD;
 
-  const time::milliseconds&
+  time::milliseconds
   getExpirationPeriod() const
   {
     return m_expirationPeriod;
   }
 
   Route&
-  setExpirationPeriod(const time::milliseconds& expirationPeriod)
-  {
-    m_expirationPeriod = expirationPeriod;
-
-    m_hasInfiniteExpirationPeriod = m_expirationPeriod == INFINITE_EXPIRATION_PERIOD;
-
-    m_wire.reset();
-    return *this;
-  }
+  setExpirationPeriod(time::milliseconds expirationPeriod);
 
   bool
   hasInfiniteExpirationPeriod() const
@@ -195,7 +168,9 @@
   class Error : public tlv::Error
   {
   public:
-    Error(const std::string& what) : tlv::Error(what)
+    explicit
+    Error(const std::string& what)
+      : tlv::Error(what)
     {
     }
   };
@@ -215,12 +190,7 @@
   }
 
   RibEntry&
-  setName(const Name& prefix)
-  {
-    m_prefix = prefix;
-    m_wire.reset();
-    return *this;
-  }
+  setName(const Name& prefix);
 
   const std::list<Route>&
   getRoutes() const
@@ -229,19 +199,10 @@
   }
 
   RibEntry&
-  addRoute(const Route& route)
-  {
-    m_routes.push_back(route);
-    m_wire.reset();
-    return *this;
-  }
+  addRoute(const Route& route);
 
   RibEntry&
-  clearRoutes()
-  {
-    m_routes.clear();
-    return *this;
-  }
+  clearRoutes();
 
   template<encoding::Tag TAG>
   size_t