spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2016 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of the nTorrent codebase. |
| 6 | * |
| 7 | * nTorrent is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * nTorrent is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with nTorrent, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS for complete list of nTorrent authors and contributors. |
| 20 | */ |
| 21 | |
| 22 | #ifndef FETCHING_STRATEGY_MANAGER_HPP |
| 23 | #define FETCHING_STRATEGY_MANAGER_HPP |
| 24 | |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 25 | #include <ndn-cxx/data.hpp> |
Mickey Sweatt | b7ee19c | 2016-04-21 12:18:15 -0700 | [diff] [blame] | 26 | #include <ndn-cxx/interest.hpp> |
| 27 | #include <ndn-cxx/util/time.hpp> |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
| 30 | namespace ntorrent { |
| 31 | |
| 32 | class FetchingStrategyManager { |
| 33 | public: |
| 34 | /** |
| 35 | * @brief Default Constructor |
| 36 | */ |
| 37 | FetchingStrategyManager() = default; |
| 38 | |
| 39 | /** |
| 40 | * @brief Class Destructor |
| 41 | */ |
| 42 | virtual |
spirosmastorakis | 2f769c2 | 2016-03-12 11:46:04 -0800 | [diff] [blame] | 43 | ~FetchingStrategyManager(); |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * @brief Method called to start the torrent downloading |
| 47 | */ |
| 48 | virtual void |
Mickey Sweatt | 15dde2d | 2016-04-28 23:42:45 -0700 | [diff] [blame] | 49 | start(const time::milliseconds& timeout = time::milliseconds::zero()) = 0; |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * @brief Method called to pause the torrent downloading |
| 53 | */ |
| 54 | virtual void |
| 55 | pause() = 0; |
| 56 | |
| 57 | /** |
| 58 | * @brief Method called to continue the torrent downloading |
| 59 | */ |
| 60 | virtual void |
| 61 | resume() = 0; |
| 62 | |
| 63 | /** |
| 64 | * @brief Struct representing the status of the downloading |
| 65 | * process that will be passed to the application layer |
| 66 | */ |
| 67 | struct status { |
| 68 | double downloadedPercent; |
| 69 | }; |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 70 | private: |
| 71 | /** |
| 72 | * @brief Callback to be called when data is received |
| 73 | */ |
| 74 | virtual void |
| 75 | onDataPacketReceived(const ndn::Data& data) = 0; |
| 76 | |
| 77 | /** |
| 78 | * @brief Callback to be called when data retrieval failed |
| 79 | */ |
| 80 | virtual void |
| 81 | onDataRetrievalFailure(const ndn::Interest& interest, const std::string& errorCode) = 0; |
| 82 | |
| 83 | /** |
Mickey Sweatt | 15dde2d | 2016-04-28 23:42:45 -0700 | [diff] [blame] | 84 | * @brief Callback to be called when a torrent file segment is received |
| 85 | */ |
| 86 | virtual void |
| 87 | onTorrentFileSegmentReceived(const std::vector<Name>& manifestNames) = 0; |
| 88 | |
| 89 | /** |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 90 | * @brief Callback to be called when a file manifest is received |
| 91 | */ |
| 92 | virtual void |
| 93 | onManifestReceived(const std::vector<Name>& packetNames) = 0; |
| 94 | }; |
| 95 | |
spirosmastorakis | 2f769c2 | 2016-03-12 11:46:04 -0800 | [diff] [blame] | 96 | inline |
| 97 | FetchingStrategyManager::~FetchingStrategyManager() |
| 98 | { |
| 99 | } |
| 100 | |
spirosmastorakis | e0a74c7 | 2016-03-04 16:03:08 -0800 | [diff] [blame] | 101 | } // namespace ntorrent |
| 102 | } // namespace ndn |
| 103 | |
| 104 | #endif // FETCHING_STRATEGY_MANAGER_HPP |