3DCoat  3D-COAT 4.9.xx
3DCoat is the one application that has all the tools you need to take your 3D idea from a block of digital clay all the way to a production ready, fully textured organic or hard surface model.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
downloader::queue Class Reference

The class for the asyncronous downloading. Create the object, add items to download and do other job or wait till all downloads will be finished. More...

#include <download.h>

Public Member Functions

 queue (int max_threads=2, int retry_attempts=20, std::function< bool(size_t, size_t)> progress=nullptr)
 Construct the download queue. More...
 
void waitTheFinish ()
 Whait till all downloads finish. You can't add new downloads after this command. More...
 
bool success ()
 returns true if all downloads succeed. More...
 
void add (const std::string &url, const std::string &to, bool unzip, std::function< void()> ready=nullptr, std::function< void(const std::string &)> error=nullptr)
 Add the item to be downloaded. More...
 
size_t getProgress ()
 returns the overall progress More...
 
std::pair< size_t, size_t > getDownloadedSize ()
 returns the downloaded size and the total size to be downloaded as the pair More...
 

Detailed Description

The class for the asyncronous downloading. Create the object, add items to download and do other job or wait till all downloads will be finished.

Constructor & Destructor Documentation

downloader::queue::queue ( int  max_threads = 2,
int  retry_attempts = 20,
std::function< bool(size_t, size_t)>  progress = nullptr 
)

Construct the download queue.

Parameters
max_threadsmaximum dowloading threads
retry_attemptsretry attempts count
progressthe callback to follow the progress, called with (downloaded, size_to+download)

Member Function Documentation

void downloader::queue::add ( const std::string &  url,
const std::string &  to,
bool  unzip,
std::function< void()>  ready = nullptr,
std::function< void(const std::string &)>  error = nullptr 
)

Add the item to be downloaded.

Parameters
urlthe URL to download
tothe filename for the downloaded file
unzipneed unzip after the downloading?
readythe ready callback
errorthe errors callback, called with the error message.

References zpp::reader::extractFirstToFile(), and success().

std::pair< size_t, size_t > downloader::queue::getDownloadedSize ( )

returns the downloaded size and the total size to be downloaded as the pair

size_t downloader::queue::getProgress ( )

returns the overall progress

bool downloader::queue::success ( )

returns true if all downloads succeed.

Referenced by add().

void downloader::queue::waitTheFinish ( )

Whait till all downloads finish. You can't add new downloads after this command.


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