rib: simplify Route class

Route::expires is changed to an optional, with nullopt representing
"never expires". This avoids an integer overflow.

RouteFlags accessors are now provided by ndn::nfd::RouteFlagsTraits.

Stream insertion operator is improved.

refs #3502

Change-Id: Ia912eab771fb00020385bf84d486955feae6aafa
diff --git a/rib/route.hpp b/rib/route.hpp
index f739741..2dfeabb 100644
--- a/rib/route.hpp
+++ b/rib/route.hpp
@@ -27,30 +27,20 @@
 #define NFD_RIB_ROUTE_HPP
 
 #include "core/scheduler.hpp"
-
 #include <ndn-cxx/encoding/nfd-constants.hpp>
+#include <ndn-cxx/mgmt/nfd/route-flags-traits.hpp>
+#include <type_traits>
 
 namespace nfd {
 namespace rib {
 
 /** \brief represents a route for a name prefix
  */
-class Route
+class Route : public ndn::nfd::RouteFlagsTraits<Route>
 {
 public:
-  Route()
-    : faceId(0)
-    , origin(ndn::nfd::ROUTE_ORIGIN_APP)
-    , flags(0)
-    , cost(0)
-    , expires(time::steady_clock::TimePoint::min())
-  {
-  }
+  Route();
 
-  bool
-  operator==(const Route& other) const;
-
-public:
   void
   setExpirationEvent(const scheduler::EventId eid)
   {
@@ -63,29 +53,32 @@
     return m_expirationEvent;
   }
 
-  bool
-  isChildInherit() const
+  std::underlying_type<ndn::nfd::RouteFlags>::type
+  getFlags() const
   {
-    return flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
-  }
-
-  bool
-  isCapture() const
-  {
-    return flags & ndn::nfd::ROUTE_FLAG_CAPTURE;
+    return flags;
   }
 
 public:
   uint64_t faceId;
   ndn::nfd::RouteOrigin origin;
-  uint64_t flags;
   uint64_t cost;
-  time::steady_clock::TimePoint expires;
+  std::underlying_type<ndn::nfd::RouteFlags>::type flags;
+  ndn::optional<time::steady_clock::TimePoint> expires;
 
 private:
   scheduler::EventId m_expirationEvent;
 };
 
+bool
+operator==(const Route& lhs, const Route& rhs);
+
+inline bool
+operator!=(const Route& lhs, const Route& rhs)
+{
+  return !(lhs == rhs);
+}
+
 inline bool
 compareFaceIdAndOrigin(const Route& lhs, const Route& rhs)
 {