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-2020, 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 
38 {
39 public:
40  SegmentPublisher(ndn::Face& face, ndn::KeyChain& keyChain,
41  size_t imsLimit = 100);
42 
52  void
53  publish(const ndn::Name& interestName, const ndn::Name& dataName,
54  const ndn::Block& block, ndn::time::milliseconds freshness,
55  const ndn::security::SigningInfo& signingInfo = ndn::security::SigningInfo());
56 
66  void
67  publish(const ndn::Name& interestName, const ndn::Name& dataName,
68  const ndn::ConstBufferPtr& buffer, ndn::time::milliseconds freshness,
69  const ndn::security::SigningInfo& signingInfo = ndn::security::SigningInfo());
70 
76  bool
77  replyFromStore(const ndn::Name& interestName);
78 
79 private:
80  ndn::Face& m_face;
81  ndn::Scheduler m_scheduler;
82  ndn::KeyChain& m_keyChain;
83 
85  ndn::InMemoryStorageFifo m_ims;
86 };
87 
88 } // namespace psync
89 
90 #endif // PSYNC_SEGMENT_PUBLISHER_HPP
SegmentPublisher(ndn::Face &face, ndn::KeyChain &keyChain, size_t imsLimit=100)
Definition: common.hpp:33
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::SigningInfo())
Put all the segments in memory.
Segment Publisher to publish segmented data.
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
bool replyFromStore(const ndn::Name &interestName)
Try to reply from memory, return false if we cannot find the segment.