mcloud  1.0.0
MCloud API library for cmcc cloud service
task.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_TASK_H_
20 #define MCLOUD_API_TASK_H_
21 
22 #include <mcloud/api/visibility.h>
23 #include <functional>
24 #include <string>
25 
26 namespace mcloud {
27 namespace api {
28 
35 public:
39  enum class Status {
40  Unstart,
41  Running,
42  Canceled,
43  Paused,
44  Broken,
45  Complete,
46  };
47 
48  typedef std::function<void(float)> ProgressHandler;
49 
50  typedef std::function<void(Status)> StatusHandler;
51 
52  typedef std::function<size_t(void *dest, size_t buf_size)> Buffer_Callback;
53 
54  virtual ~Task() = default;
55 
59  virtual const std::string & task_id() const = 0;
60 
64  virtual const std::string & content_id() const = 0;
65 
69  virtual const std::string & content_name() const = 0;
70 
74  virtual const std::string & file_path() const = 0;
75 
79  virtual const std::string & error_string() const = 0;
80 
85  virtual const std::string & task_url() const = 0;
86 
90  virtual Task::Status status() const = 0;
91 
96  virtual Task::ProgressHandler & progress_changed() = 0;
97 
102  virtual Task::StatusHandler & status_changed() = 0;
103 
108  virtual void cancel() = 0;
109 };
110 
111 }
112 }
113 
114 #endif // MCLOUD_API_TASK_H_
Task is an abstract class that defines common interfaces for upload and download task.
Definition: task.h:34
std::function< void(Status)> StatusHandler
Definition: task.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