mcloud  1.0.0
MCloud API library for cmcc cloud service
syncmanager.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_SYNCMANAGER_H_
20 #define MCLOUD_API_SYNCMANAGER_H_
21 
22 #include <mcloud/api/taskqueue.h>
24 #include <mcloud/api/uploadtask.h>
25 #include <mcloud/api/visibility.h>
26 
27 #include <memory>
28 #include <vector>
29 
30 namespace mcloud {
31 namespace api {
32 
33 class ClientPriv;
34 class SyncManagerPriv;
35 
46  public:
47  typedef std::shared_ptr<SyncManager> Ptr;
48 
50 
52 
53  typedef std::vector<std::string> Stringlist;
54 
55  virtual ~SyncManager() = default;
56 
57  SyncManager(const SyncManager&) = delete;
58 
59  SyncManager& operator=(const SyncManager &) = delete;
60 
66  void start();
67 
73  void cancel();
74 
80  void pause();
81 
88  DownloadTask::Ptr add_download_task(const std::string &content_id);
89 
102  DownloadTask::Ptr add_download_task(const DownloadBufferCb &buffer_cb);
103 
123  UploadTask::Ptr add_upload_task(const UploadRequest &request_item);
124 
144  UploadTask::Ptr add_upload_task(const UploadBufferCb &buffer_cb);
145 
151  DownloadList download_queue();
152 
158  UploadList upload_queue();
159 
160 private:
161  SyncManager(ClientPriv* client_priv);
162 
163  friend class ClientPriv;
164 
165  std::shared_ptr<SyncManagerPriv> p_;
166 };
167 
168 }
169 }
170 
171 #endif // MCLOUD_API_SYNCMANAGER_H_
A thread-safe deque template.
Definition: taskqueue.h:34
UploadBufferCb is a upload request item which consists of a upload folder id, upload buffer size...
Definition: uploadtask.h:49
DownloadBufferCb is a download request object which consists of a content id and writing callback fun...
Definition: downloadtask.h:36
std::shared_ptr< UploadTask > Ptr
Definition: uploadtask.h:68
std::shared_ptr< DownloadTask > Ptr
Definition: downloadtask.h:52
SyncManager handles all the requests to upload and download. It&#39;s constructed around two threads for ...
Definition: syncmanager.h:45
std::shared_ptr< SyncManager > Ptr
Definition: syncmanager.h:47
UploadRequest is a upload request item which consists of a upload folder id, up-front buffer size...
Definition: uploadtask.h:37
Definition: client.h:37
TaskQueue< UploadTask::Ptr > UploadList
Definition: syncmanager.h:51
TaskQueue< DownloadTask::Ptr > DownloadList
Definition: syncmanager.h:49
#define MCLOUD_API_DLL_PUBLIC
Definition: visibility.h:26
std::vector< std::string > Stringlist
Definition: syncmanager.h:53