sync: removed ref to lsdb.

Sync now emits to a signal whenever a new LSA is detected, and the LSDB
listens to this signal.  Sync consults a function object gotten at ctor time
to determine LSA newness.  This means Sync no longer needs a reference to
the LSDB, and LSA newness criteria can be freely manipulated.

Change-Id: Ifce3ebfc921ad846fcfa12d99c78f3b337180827
refs: #4264
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 5a4d709..95b656c 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -20,13 +20,11 @@
  **/
 
 #include "sync-logic-handler.hpp"
-
 #include "common.hpp"
 #include "conf-parameter.hpp"
-#include "logger.hpp"
 #include "lsa.hpp"
-#include "lsdb.hpp"
 #include "utility/name-helper.hpp"
+#include "logger.hpp"
 
 namespace nlsr {
 
@@ -45,10 +43,10 @@
   }
 };
 
-SyncLogicHandler::SyncLogicHandler(ndn::Face& face,
-                                   Lsdb& lsdb, ConfParameter& conf)
-  : m_syncFace(face)
-  , m_lsdb(lsdb)
+SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, ConfParameter& conf)
+  : onNewLsa(ndn::make_unique<OnNewLsa>())
+  , m_syncFace(face)
+  , m_isLsaNew(isLsaNew)
   , m_confParam(conf)
 {
 }
@@ -125,7 +123,7 @@
     _LOG_DEBUG("Received sync update with higher " << lsaType
                << " sequence number than entry in LSDB");
 
-    if (isLsaNew(originRouter, lsaType, seqNo)) {
+    if (m_isLsaNew(originRouter, lsaType, seqNo)) {
       if (lsaType == AdjLsa::TYPE_STRING && seqNo != 0 &&
           m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
         _LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing"
@@ -139,44 +137,11 @@
                    << " is enabled. Not going to fetch.");
         return;
       }
-      expressInterestForLsa(updateName, seqNo);
+      (*onNewLsa)(updateName, seqNo);
     }
   }
 }
 
-bool
-SyncLogicHandler::isLsaNew(const ndn::Name& originRouter, const std::string& lsaType,
-                           const uint64_t& seqNo)
-{
-  ndn::Name lsaKey = originRouter;
-  lsaKey.append(lsaType);
-
-  if (lsaType == NameLsa::TYPE_STRING)
-  {
-    return m_lsdb.isNameLsaNew(lsaKey, seqNo);
-  }
-  else if (lsaType == AdjLsa::TYPE_STRING)
-  {
-    return m_lsdb.isAdjLsaNew(lsaKey, seqNo);
-  }
-  else if (lsaType == CoordinateLsa::TYPE_STRING)
-  {
-    return m_lsdb.isCoordinateLsaNew(lsaKey, seqNo);
-  }
-
-  return false;
-}
-
-void
-SyncLogicHandler::expressInterestForLsa(const ndn::Name& updateName,
-                                        const uint64_t& seqNo)
-{
-  ndn::Name interest(updateName);
-  interest.appendNumber(seqNo);
-
-  m_lsdb.expressInterest(interest, 0);
-}
-
 void
 SyncLogicHandler::publishRoutingUpdate(const ndn::Name& type, const uint64_t& seqNo)
 {