blob: b81faf2f43db3d18b76ead61165dd98403ea992e [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
spirosmastorakise0a74c72016-03-04 16:03:08 -080025#include <ndn-cxx/data.hpp>
Mickey Sweattb7ee19c2016-04-21 12:18:15 -070026#include <ndn-cxx/interest.hpp>
27#include <ndn-cxx/util/time.hpp>
spirosmastorakise0a74c72016-03-04 16:03:08 -080028
29namespace ndn {
30namespace ntorrent {
31
32class FetchingStrategyManager {
33 public:
34 /**
35 * @brief Default Constructor
36 */
37 FetchingStrategyManager() = default;
38
39 /**
40 * @brief Class Destructor
41 */
42 virtual
spirosmastorakis2f769c22016-03-12 11:46:04 -080043 ~FetchingStrategyManager();
spirosmastorakise0a74c72016-03-04 16:03:08 -080044
45 /**
46 * @brief Method called to start the torrent downloading
47 */
48 virtual void
Mickey Sweatt15dde2d2016-04-28 23:42:45 -070049 start(const time::milliseconds& timeout = time::milliseconds::zero()) = 0;
spirosmastorakise0a74c72016-03-04 16:03:08 -080050
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 };
spirosmastorakise0a74c72016-03-04 16:03:08 -080070 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 Sweatt15dde2d2016-04-28 23:42:45 -070084 * @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 /**
spirosmastorakise0a74c72016-03-04 16:03:08 -080090 * @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
spirosmastorakis2f769c22016-03-12 11:46:04 -080096inline
97FetchingStrategyManager::~FetchingStrategyManager()
98{
99}
100
spirosmastorakise0a74c72016-03-04 16:03:08 -0800101} // namespace ntorrent
102} // namespace ndn
103
104#endif // FETCHING_STRATEGY_MANAGER_HPP