blob: 251409864f60649a8f14e5c8efb9422abf61c23e [file] [log] [blame]
Andrea Tosatto672b9a72016-01-05 16:18:20 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento06807dc2017-09-19 15:52:43 -04002/*
3 * Copyright (c) 2016-2017, Regents of the University of California,
4 * Colorado State University,
5 * University Pierre & Marie Curie, Sorbonne University.
Andrea Tosatto672b9a72016-01-05 16:18:20 +01006 *
7 * This file is part of ndn-tools (Named Data Networking Essential Tools).
8 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
9 *
10 * ndn-tools 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 * ndn-tools 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 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
22 *
23 * @author Andrea Tosatto
24 */
25
26#ifndef NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_FIXED_HPP
27#define NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_FIXED_HPP
28
29#include "discover-version.hpp"
30
31namespace ndn {
32namespace chunks {
33
34/**
35 * @brief Service to retrieve a specific version segment. The version is specified in the prefix
36 *
37 * Send a request of a specific version and expect to be answered with one segment.
38 *
39 * The received name component after version can be an invalid segment number, this component will
40 * be excluded in the next interests. In the unlikely case that there are too many excluded
41 * components such that the Interest cannot fit in ndn::MAX_NDN_PACKET_SIZE, the discovery
42 * procedure will throw Face::Error.
43 *
44 * DiscoverVersionFixed's user is notified once after one segment with the user specified version
45 * is found or on failure to find any Data version.
46 */
47class DiscoverVersionFixed : public DiscoverVersion
48{
Andrea Tosatto672b9a72016-01-05 16:18:20 +010049public:
50 /**
Davide Pesavento06807dc2017-09-19 15:52:43 -040051 * @brief create a DiscoverVersionFixed service
Andrea Tosatto672b9a72016-01-05 16:18:20 +010052 */
53 DiscoverVersionFixed(const Name& prefix, Face& face, const Options& options);
54
55 /**
56 * @brief identify the latest Data version published.
57 */
58 void
Davide Pesavento25625ca2016-05-03 18:21:22 +020059 run() final;
Andrea Tosatto672b9a72016-01-05 16:18:20 +010060
61private:
62 void
Davide Pesavento25625ca2016-05-03 18:21:22 +020063 handleData(const Interest& interest, const Data& data) final;
Andrea Tosatto672b9a72016-01-05 16:18:20 +010064
65private:
66 Exclude m_strayExcludes;
67};
68
69} // namespace chunks
70} // namespace ndn
71
72#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_FIXED_HPP