mcloud  1.0.0
MCloud API library for cmcc cloud service
downloadtask.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Gary Wang <gary.wang@canonical.com>
17  */
18 
19 #ifndef MCLOUD_API_DOWNLOADTASK_H_
20 #define MCLOUD_API_DOWNLOADTASK_H_
21 
22 #include <mcloud/api/visibility.h>
23 #include <mcloud/api/task.h>
24 
25 #include <memory>
26 
27 namespace mcloud {
28 namespace api {
29 
30 class TaskHandler;
31 
37 {
38  std::string content_id;
40 };
41 
42 class DownloadTaskPriv;
43 class SyncManagerPriv;
44 
51 public:
52  typedef std::shared_ptr<DownloadTask> Ptr;
53 
54  virtual ~DownloadTask() = default;
55 
56  DownloadTask(const DownloadTask& ) = delete;
57 
58  DownloadTask& operator=(const DownloadTask& ) = delete;
59 
63  const std::string & task_id() const override;
64 
68  const std::string & content_id() const override;
69 
73  const std::string & content_name() const override;
74 
78  const std::string & file_path() const override;
79 
84  const std::string & task_url() const override;
85 
89  const std::string & error_string() const override;
90 
95  Task::Status status() const override;
96 
101  Task::ProgressHandler & progress_changed() override;
102 
107  Task::StatusHandler & status_changed() override;
108 
113  void cancel() override;
114 
115 private:
116  DownloadTask(std::shared_ptr<DownloadTaskPriv> p);
117 
118  friend class SyncManagerPriv;
119 
120  std::shared_ptr<DownloadTaskPriv> p_;
121 };
122 
123 }
124 }
125 
126 #endif // MCLOUD_API_DOWNLOADTASK_H_
DownloadBufferCb is a download request object which consists of a content id and writing callback fun...
Definition: downloadtask.h:36
Task is an abstract class that defines common interfaces for upload and download task.
Definition: task.h:34
std::shared_ptr< DownloadTask > Ptr
Definition: downloadtask.h:52
Task::Buffer_Callback write_cb
Definition: downloadtask.h:39
std::function< void(Status)> StatusHandler
Definition: task.h:50
DownloadTask is a task item that can be accessed from application layer to fetch basic download item ...
Definition: downloadtask.h:50
std::function< void(float)> ProgressHandler
Definition: task.h:48
Definition: client.h:37
std::function< size_t(void *dest, size_t buf_size)> Buffer_Callback
Definition: task.h:52
#define MCLOUD_API_DLL_PUBLIC
Definition: visibility.h:26
Status
The Status enum indicates current status of this task.
Definition: task.h:39