lsa-segment-storage.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_LSA_SEGMENT_STORAGE_HPP
23 #define NLSR_LSA_SEGMENT_STORAGE_HPP
24 
25 #include "test-access-control.hpp"
26 
27 #include <ndn-cxx/util/segment-fetcher.hpp>
28 #include <ndn-cxx/util/signal.hpp>
29 #include <ndn-cxx/util/time.hpp>
30 
31 #include <vector>
32 #include <tuple>
33 
34 namespace nlsr {
35 
37 {
38 public:
39  LsaSegmentStorage(ndn::Scheduler& scheduler,
40  const ndn::time::seconds lsaDeletionTimepoint);
41 
45  void
46  connectToFetcher(ndn::util::SegmentFetcher& fetcher);
47 
51  const ndn::Data*
52  getLsaSegment(const ndn::Interest& interest);
53 
57  void
58  afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
59 
60 private:
66  void
67  deleteOldLsas(const ndn::Name& newLsaName);
68 
71  void
72  scheduleLsaSegmentDeletion(const ndn::Name& segmentKey);
73 
74 
75 private:
76  ndn::Scheduler& m_scheduler;
77 
78  // Key: /<router-prefix>/<LS type>/<sequence no.>/<segment no.>
79  // Value: corresponding LSA data packet
80  // Data name: /<router-prefix>/<LS type>/<sequence no.>/<version no.>/<segment no.>
81  std::unordered_map<ndn::Name, ndn::Data> m_lsaSegments;
82 
83  const ndn::time::seconds m_lsaDeletionTimepoint;
84 };
85 
86 } // namespace nlsr
87 
88 #endif // NLSR_LSA_SEGMENT_STORAGE_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
void connectToFetcher(ndn::util::SegmentFetcher &fetcher)
Get connected to the signal emitted by SegmentFetcher.
LsaSegmentStorage(ndn::Scheduler &scheduler, const ndn::time::seconds lsaDeletionTimepoint)
const ndn::Data * getLsaSegment(const ndn::Interest &interest)
Returns an LSA segment for an interest from LsaSegmentStorage.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.