Loading...
Searching...
No Matches
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-2023, 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/ims/in-memory-storage-fifo.hpp>
27#include <ndn-cxx/util/scheduler.hpp>
28#include <ndn-cxx/util/segmenter.hpp>
29
30namespace psync {
31
36{
37public:
38 SegmentPublisher(ndn::Face& face, ndn::KeyChain& keyChain,
39 const ndn::security::SigningInfo& signingInfo = ndn::security::SigningInfo(),
40 size_t imsLimit = 100);
41
50 void
51 publish(const ndn::Name& interestName, const ndn::Name& dataName,
52 ndn::span<const uint8_t> buffer, ndn::time::milliseconds freshness);
53
59 bool
60 replyFromStore(const ndn::Name& interestName);
61
62private:
63 ndn::Face& m_face;
64 ndn::Scheduler m_scheduler;
65 ndn::Segmenter m_segmenter;
66
68 ndn::InMemoryStorageFifo m_ims;
69};
70
71} // namespace psync
72
73#endif // PSYNC_SEGMENT_PUBLISHER_HPP
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Helper class to publish segmented data.
bool replyFromStore(const ndn::Name &interestName)
Try to reply from memory, return false if we cannot find the segment.
void publish(const ndn::Name &interestName, const ndn::Name &dataName, ndn::span< const uint8_t > buffer, ndn::time::milliseconds freshness)
Put all the segments in memory.