sync-protocol-adapter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2022, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
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 <ndn-cxx/security/key-chain.hpp>
29 
30 #ifdef HAVE_CHRONOSYNC
31 #include <ChronoSync/logic.hpp>
32 #endif
33 #ifdef HAVE_PSYNC
34 #include <PSync/full-producer.hpp>
35 #endif
36 #ifdef HAVE_SVS
37 #include <ndn-svs/core.hpp>
38 #endif
39 
40 namespace nlsr {
41 
42 using SyncUpdateCallback = std::function<void(const ndn::Name& updateName,
43  uint64_t seqNo, uint64_t incomingFaceId)>;
44 
46 {
47 public:
48  SyncProtocolAdapter(ndn::Face& face,
49  ndn::KeyChain& keyChain,
50  SyncProtocol syncProtocol,
51  const ndn::Name& syncPrefix,
52  const ndn::Name& userPrefix,
53  ndn::time::milliseconds syncInterestLifetime,
54  SyncUpdateCallback syncUpdateCallback);
55 
60  void
61  addUserNode(const ndn::Name& userPrefix);
62 
71  void
72  publishUpdate(const ndn::Name& userPrefix, uint64_t seq);
73 
75 #ifdef HAVE_CHRONOSYNC
83  void
84  onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates);
85 #endif // HAVE_CHRONOSYNC
86 
87 #ifdef HAVE_PSYNC
95  void
96  onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates);
97 #endif // HAVE_PSYNC
98 
99 #ifdef HAVE_SVS
107  void
108  onSvsUpdate(const std::vector<ndn::svs::MissingDataInfo>& updates);
109 #endif // HAVE_SVS
110 
111 private:
112  SyncProtocol m_syncProtocol;
113  SyncUpdateCallback m_syncUpdateCallback;
114 
115 #ifdef HAVE_CHRONOSYNC
116  std::shared_ptr<chronosync::Logic> m_chronoSyncLogic;
117 #endif
118 #ifdef HAVE_PSYNC
119  std::shared_ptr<psync::FullProducer> m_psyncLogic;
120 #endif
121 #ifdef HAVE_SVS
122  std::shared_ptr<ndn::svs::SVSyncCore> m_svsCore;
123 #endif
124 };
125 
126 } // namespace nlsr
127 
128 #endif // NLSR_SYNC_PROTOCOL_ADAPTER_HPP
void publishUpdate(const ndn::Name &userPrefix, uint64_t seq)
Publish update to Sync.
SyncProtocolAdapter(ndn::Face &face, ndn::KeyChain &keyChain, SyncProtocol syncProtocol, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncInterestLifetime, SyncUpdateCallback syncUpdateCallback)
void addUserNode(const ndn::Name &userPrefix)
Add user node to Sync.
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::function< void(const ndn::Name &updateName, uint64_t seqNo, uint64_t incomingFaceId)> SyncUpdateCallback
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE