segment-publisher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, The University of Memphis
4  *
5  * This file is part of PSync.
6  * See AUTHORS.md for complete list of PSync authors and contributors.
7  *
8  * PSync is free software: you can redistribute it and/or modify it under the terms
9  * of the GNU Lesser General Public License as published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option) any later version.
11  *
12  * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE. See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18  **/
19 
20 #ifndef PSYNC_SEGMENT_PUBLISHER_HPP
21 #define PSYNC_SEGMENT_PUBLISHER_HPP
22 
24 
25 #include <ndn-cxx/face.hpp>
26 #include <ndn-cxx/name.hpp>
27 #include <ndn-cxx/ims/in-memory-storage-fifo.hpp>
28 #include <ndn-cxx/security/key-chain.hpp>
29 #include <ndn-cxx/util/scheduler.hpp>
30 #include <ndn-cxx/util/time.hpp>
31 
32 namespace psync {
33 
34 const int MAX_SEGMENTS_STORED = 100;
35 
41 {
42 public:
43  SegmentPublisher(ndn::Face& face, ndn::KeyChain& keyChain,
44  size_t imsLimit = MAX_SEGMENTS_STORED);
45 
55  void
56  publish(const ndn::Name& interestName, const ndn::Name& dataName,
57  const ndn::Block& block, ndn::time::milliseconds freshness,
58  const ndn::security::SigningInfo& signingInfo =
59  ndn::security::v2::KeyChain::getDefaultSigningInfo());
60 
66  bool
67  replyFromStore(const ndn::Name& interestName);
68 
69 private:
70  ndn::Face& m_face;
71  ndn::util::Scheduler m_scheduler;
72  ndn::KeyChain& m_keyChain;
73 
75  ndn::InMemoryStorageFifo m_ims;
76 };
77 
78 } // namespace psync
79 
80 #endif // PSYNC_SEGMENT_PUBLISHER_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
void publish(const ndn::Name &interestName, const ndn::Name &dataName, const ndn::Block &block, ndn::time::milliseconds freshness, const ndn::security::SigningInfo &signingInfo=ndn::security::v2::KeyChain::getDefaultSigningInfo())
Put all the segments in memory.
Segment Publisher to publish segmented data.
SegmentPublisher(ndn::Face &face, ndn::KeyChain &keyChain, size_t imsLimit=MAX_SEGMENTS_STORED)
bool replyFromStore(const ndn::Name &interestName)
Try to reply from memory, return false if we cannot find the segment.
const int MAX_SEGMENTS_STORED