giga::core::Downloader Class Referencefinal

#include <Downloader.h>

Public Types

typedef std::function< void(FileTransferer
&, TransferProgress)> 
ProgressFct
 
typedef std::function< void(const
Node &, const
boost::filesystem::path &)> 
OnDownloadedFct
 
typedef std::function< void(const
Node &, const
boost::filesystem::path
&, FileDownloader::Action)> 
OnFileDownloadedFct
 
typedef std::function< void(const
std::string &, const
utility::string_t
&, std::string &&)> 
OnErrorFct
 

Public Member Functions

 Downloader (const Application &app)
 construct a Downloader More...
 
 Downloader (Downloader &&)=delete
 
 Downloader (const Downloader &)=delete
 
Downloaderoperator= (const Downloader &)=delete
 
Downloaderoperator= (Downloader &&)=delete
 
void setDownloadProgressFct (ProgressFct fct)
 Set a callback to follow the download progress. More...
 
void setOnDownloadedFct (OnDownloadedFct fct)
 
void setOnFileDownloadedFct (OnFileDownloadedFct fct)
 
void setOnErrorFct (OnErrorFct fct)
 
void addDownload (std::unique_ptr< Node > &&node, const boost::filesystem::path &path)
 add a file or folder to the list of download More...
 
void start ()
 Start the uploading process.
 
void join ()
 Wit for the uploading process to finish.
 
void kill ()
 Cancel the current download; Clear the queue; stop the process.
 
void limitRate (uint64_t rate)
 Limit the current download rate. More...
 
void pause ()
 Pause the current download. Uses resume() to restart.
 
void resume ()
 Resume a previously pause()d download.
 
void clear ()
 Remove all the files waiting to be process. Only the current downloading file remains. The Error queue is cleared (. More...
 
FileTransferer::State state ()
 Gets the current download state.
 
bool isStarted () const
 
std::shared_ptr< FileDownloaderdownloadingFile ()
 Gets the current FileDownloader. More...
 
void callProgressFct () const
 

Detailed Description

Download folders and files.

Constructor & Destructor Documentation

giga::core::Downloader::Downloader ( const Application app)
explicit

construct a Downloader

See Also
setDownloadProgressFct()

Member Function Documentation

void giga::core::Downloader::addDownload ( std::unique_ptr< Node > &&  node,
const boost::filesystem::path &  path 
)

add a file or folder to the list of download

Parameters
nodemove here the node you want to download. It can either be a FileNode or a FolderNode.
paththe path to a folder where you want node to be downloaded.
void giga::core::Downloader::clear ( )

Remove all the files waiting to be process. Only the current downloading file remains. The Error queue is cleared (.

See Also
consumeError())
std::shared_ptr<FileDownloader> giga::core::Downloader::downloadingFile ( )

Gets the current FileDownloader.

For each file downloaded by the Downloader a FileDownloader is created. This methods return the FileDownloader for the file being currently download. It may return nullptr if there is no file downloading yet.

Returns
The current FileDownloader or nullptr.
void giga::core::Downloader::limitRate ( uint64_t  rate)

Limit the current download rate.

Parameters
ratethe download rate in Octet/s. Uses 0 for no limit.
void giga::core::Downloader::setDownloadProgressFct ( ProgressFct  fct)

Set a callback to follow the download progress.

Parameters
fcta callback function that will be called periodically to let you know of the download progress

fct will be called :

  • At the beginning of the download for each file
  • For long download it is called periodically.

You should not do any long lasting computation in this function.


The documentation for this class was generated from the following files:
  • /home/thomas/code/GiGaSdk/src/giga/core/Downloader.h
  • /home/thomas/code/GiGaSdk/src/giga/core/Downloader.cpp