Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame] | 2 | /* |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 3 | * Copyright (c) 2016-2019, Regents of the University of California, |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame] | 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 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 Wentao Shang |
| 24 | * @author Steve DiBenedetto |
| 25 | * @author Andrea Tosatto |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 26 | * @author Chavoosh Ghasemi |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #ifndef NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP |
| 30 | #define NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP |
| 31 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 32 | #include "options.hpp" |
| 33 | |
| 34 | namespace ndn { |
| 35 | namespace chunks { |
| 36 | |
| 37 | class DataFetcher; |
| 38 | |
| 39 | /** |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 40 | * @brief Service for discovering the latest Data version. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 41 | * |
| 42 | * DiscoverVersion's user is notified once after identifying the latest retrievable version or |
| 43 | * on failure to find any Data version. |
| 44 | */ |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 45 | class DiscoverVersion |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 46 | { |
| 47 | public: // signals |
| 48 | /** |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 49 | * @brief Signal emitted when the versioned name of Data is found. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 50 | */ |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 51 | signal::Signal<DiscoverVersion, Name> onDiscoverySuccess; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * @brief Signal emitted when a failure occurs. |
| 55 | */ |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 56 | signal::Signal<DiscoverVersion, std::string> onDiscoveryFailure; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 57 | |
| 58 | public: |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 59 | DiscoverVersion(Face& face, const Name& prefix, const Options& options); |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame] | 60 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 61 | /** |
| 62 | * @brief identify the latest Data version published. |
| 63 | */ |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 64 | void |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 65 | run(); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 66 | |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 67 | private: |
| 68 | void |
| 69 | handleData(const Interest& interest, const Data& data); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 70 | |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 71 | private: |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 72 | Face& m_face; |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 73 | const Name m_prefix; |
| 74 | const Options& m_options; |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 75 | shared_ptr<DataFetcher> m_fetcher; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace chunks |
| 79 | } // namespace ndn |
| 80 | |
| 81 | #endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP |