mcloud  1.0.0
MCloud API library for cmcc cloud service
mcloud::api::Task Class Referenceabstract

Task is an abstract class that defines common interfaces for upload and download task. More...

#include <task.h>

+ Inheritance diagram for mcloud::api::Task:
+ Collaboration diagram for mcloud::api::Task:

Public Types

enum  Status {
  Status::Unstart,
  Status::Running,
  Status::Canceled,
  Status::Paused,
  Status::Broken,
  Status::Complete
}
 The Status enum indicates current status of this task. More...
 
typedef std::function< void(float)> ProgressHandler
 
typedef std::function< void(Status)> StatusHandler
 
typedef std::function< size_t(void *dest, size_t buf_size)> Buffer_Callback
 

Public Member Functions

virtual ~Task ()=default
 
virtual const std::string & task_id () const =0
 Returns an unique id of task. More...
 
virtual const std::string & content_id () const =0
 Returns an unique id of cloud content on mcloud. More...
 
virtual const std::string & content_name () const =0
 Returns a display name of cloud content on mcloud. More...
 
virtual const std::string & file_path () const =0
 Returns cloud content local storage file path. More...
 
virtual const std::string & error_string () const =0
 Contains the error string if an error occurs during task running. More...
 
virtual const std::string & task_url () const =0
 Returns a item url assigned by mcloud. More...
 
virtual Task::Status status () const =0
 Returns current download or upload item sync-up status. More...
 
virtual Task::ProgressHandlerprogress_changed ()=0
 Handler for download or upload progress of a task. More...
 
virtual Task::StatusHandlerstatus_changed ()=0
 Handler for download or upload progress of a task. More...
 
virtual void cancel ()=0
 Cancels the task. More...
 

Detailed Description

Task is an abstract class that defines common interfaces for upload and download task.

Definition at line 34 of file task.h.

Member Typedef Documentation

◆ Buffer_Callback

typedef std::function<size_t(void *dest, size_t buf_size)> mcloud::api::Task::Buffer_Callback

Definition at line 52 of file task.h.

◆ ProgressHandler

typedef std::function<void(float)> mcloud::api::Task::ProgressHandler

Definition at line 48 of file task.h.

◆ StatusHandler

typedef std::function<void(Status)> mcloud::api::Task::StatusHandler

Definition at line 50 of file task.h.

Member Enumeration Documentation

◆ Status

The Status enum indicates current status of this task.

Enumerator
Unstart 

Task is in queue and sync manager does not run this task yet.

Running 

Task is being processed by sync manager.

Canceled 

Task is in canceled status, it is caused by the call from Client::cancel_sync().

Paused 

Task is in paused status, it is caused by the call from Client::pause_sync().

Broken 

Task is broken when sync manager failed to download/upload a task after several times trying.

Complete 

Task is completed.

Definition at line 39 of file task.h.

Constructor & Destructor Documentation

◆ ~Task()

virtual mcloud::api::Task::~Task ( )
virtualdefault

Member Function Documentation

◆ cancel()

virtual void mcloud::api::Task::cancel ( )
pure virtual

Cancels the task.

See also
Task::StatusHandler

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ content_id()

virtual const std::string& mcloud::api::Task::content_id ( ) const
pure virtual

Returns an unique id of cloud content on mcloud.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ content_name()

virtual const std::string& mcloud::api::Task::content_name ( ) const
pure virtual

Returns a display name of cloud content on mcloud.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ error_string()

virtual const std::string& mcloud::api::Task::error_string ( ) const
pure virtual

Contains the error string if an error occurs during task running.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ file_path()

virtual const std::string& mcloud::api::Task::file_path ( ) const
pure virtual

Returns cloud content local storage file path.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ progress_changed()

virtual Task::ProgressHandler& mcloud::api::Task::progress_changed ( )
pure virtual

Handler for download or upload progress of a task.

See also
Task::ProgressHandler

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ status()

virtual Task::Status mcloud::api::Task::status ( ) const
pure virtual

Returns current download or upload item sync-up status.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ status_changed()

virtual Task::StatusHandler& mcloud::api::Task::status_changed ( )
pure virtual

Handler for download or upload progress of a task.

See also
Task::StatusHandler

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ task_id()

virtual const std::string& mcloud::api::Task::task_id ( ) const
pure virtual

Returns an unique id of task.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.

◆ task_url()

virtual const std::string& mcloud::api::Task::task_url ( ) const
pure virtual

Returns a item url assigned by mcloud.

Note
the url will be expried after a period of time.

Implemented in mcloud::api::UploadTask, and mcloud::api::DownloadTask.


The documentation for this class was generated from the following file: