sync-protocol-adapter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_SYNC_PROTOCOL_ADAPTER_HPP
23 #define NLSR_SYNC_PROTOCOL_ADAPTER_HPP
24 
25 #include "conf-parameter.hpp"
26 
27 #include <ndn-cxx/face.hpp>
28 #include <ChronoSync/logic.hpp>
29 #include <PSync/full-producer.hpp>
30 
31 namespace nlsr {
32 
33 typedef std::function<void(const ndn::Name& updateName,
34  uint64_t seqNo)> SyncUpdateCallback;
35 
37 {
38 public:
39  SyncProtocolAdapter(ndn::Face& facePtr,
40  int32_t syncProtocol,
41  const ndn::Name& syncPrefix,
42  const ndn::Name& userPrefix,
43  ndn::time::milliseconds syncInterestLifetime,
44  const SyncUpdateCallback& syncUpdateCallback);
45 
50  void
51  addUserNode(const ndn::Name& userPrefix);
52 
61  void
62  publishUpdate(const ndn::Name& userPrefix, uint64_t seq);
63 
73  void
74  onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates);
75 
84  void
85  onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates);
86 
87 private:
88  int32_t m_syncProtocol;
89  SyncUpdateCallback m_syncUpdateCallback;
90  std::shared_ptr<chronosync::Logic> m_chronoSyncLogic;
91  std::shared_ptr<psync::FullProducer> m_psyncLogic;
92 };
93 
94 } // namespace nlsr
95 
96 #endif // NLSR_SYNC_PROTOCOL_ADAPTER_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::function< void(const ndn::Name &updateName, uint64_t seqNo)> SyncUpdateCallback
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void addUserNode(const ndn::Name &userPrefix)
Add user node to ChronoSync or PSync.
SyncProtocolAdapter(ndn::Face &facePtr, int32_t syncProtocol, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncInterestLifetime, const SyncUpdateCallback &syncUpdateCallback)
void publishUpdate(const ndn::Name &userPrefix, uint64_t seq)
Publish update to ChronoSync or PSync.