Chavoosh Ghasemi | d8f9af2 | 2019-02-28 09:47:26 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2016-2019, Regents of the University of California, |
| 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
| 6 | * |
| 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 Chavoosh Ghasemi <chghasemi@cs.arizona.edu> |
| 24 | */ |
| 25 | |
| 26 | #ifndef NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_REALTIME_HPP |
| 27 | #define NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_REALTIME_HPP |
| 28 | |
| 29 | #include "discover-version.hpp" |
| 30 | |
| 31 | namespace ndn { |
| 32 | namespace chunks { |
| 33 | |
| 34 | /** |
| 35 | * @brief Options for discover version realtime |
| 36 | * |
| 37 | * The canonical name to use is DiscoverVersionRealtime::Options |
| 38 | */ |
| 39 | class DiscoverVersionRealtimeOptions : public virtual Options |
| 40 | { |
| 41 | public: |
| 42 | explicit |
| 43 | DiscoverVersionRealtimeOptions(const Options& opts = Options()) |
| 44 | : Options(opts) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | public: |
| 49 | time::milliseconds discoveryTimeout{DEFAULT_INTEREST_LIFETIME}; ///< timeout for version discovery |
| 50 | }; |
| 51 | |
| 52 | /** |
| 53 | * @brief Service for discovering Data version by sending discovery interests |
| 54 | * |
| 55 | * This service employs RDR-style metadata class for version discovery. |
| 56 | * @see https://redmine.named-data.net/projects/ndn-tlv/wiki/RDR |
| 57 | */ |
| 58 | class DiscoverVersionRealtime : public DiscoverVersion, protected DiscoverVersionRealtimeOptions |
| 59 | { |
| 60 | public: |
| 61 | typedef DiscoverVersionRealtimeOptions Options; |
| 62 | |
| 63 | public: |
| 64 | /** |
| 65 | * @param prefix Name of solicited data |
| 66 | * @param face The face through which discovery Interests are expressed |
| 67 | * @param options Additional information about the service |
| 68 | */ |
| 69 | DiscoverVersionRealtime(const Name& prefix, Face& face, const Options& options); |
| 70 | |
| 71 | /** |
| 72 | * @brief Send a discovery Interest out |
| 73 | */ |
| 74 | void |
| 75 | run() final; |
| 76 | |
| 77 | private: |
| 78 | void |
| 79 | handleData(const Interest& interest, const Data& data) final; |
| 80 | }; |
| 81 | |
| 82 | } // namespace chunks |
| 83 | } // namespace ndn |
| 84 | |
| 85 | #endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_REALTIME_HPP |