blob: 53de93996e81a5ef094f63502b83cbd7401ef07d [file] [log] [blame]
spirosmastorakise0a74c72016-03-04 16:03:08 -08001/* -*- 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
25#include <ndn-cxx/interest.hpp>
26#include <ndn-cxx/data.hpp>
27
28namespace ndn {
29namespace ntorrent {
30
31class FetchingStrategyManager {
32 public:
33 /**
34 * @brief Default Constructor
35 */
36 FetchingStrategyManager() = default;
37
38 /**
39 * @brief Class Destructor
40 */
41 virtual
spirosmastorakis2f769c22016-03-12 11:46:04 -080042 ~FetchingStrategyManager();
spirosmastorakise0a74c72016-03-04 16:03:08 -080043
44 /**
45 * @brief Method called to start the torrent downloading
46 */
47 virtual void
48 start() = 0;
49
50 /**
51 * @brief Method called to pause the torrent downloading
52 */
53 virtual void
54 pause() = 0;
55
56 /**
57 * @brief Method called to continue the torrent downloading
58 */
59 virtual void
60 resume() = 0;
61
62 /**
63 * @brief Struct representing the status of the downloading
64 * process that will be passed to the application layer
65 */
66 struct status {
67 double downloadedPercent;
68 };
69
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 /**
84 * @brief Callback to be called when a file manifest is received
85 */
86 virtual void
87 onManifestReceived(const std::vector<Name>& packetNames) = 0;
88};
89
spirosmastorakis2f769c22016-03-12 11:46:04 -080090inline
91FetchingStrategyManager::~FetchingStrategyManager()
92{
93}
94
spirosmastorakise0a74c72016-03-04 16:03:08 -080095} // namespace ntorrent
96} // namespace ndn
97
98#endif // FETCHING_STRATEGY_MANAGER_HPP