mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
new download function using std::future and std::async
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <future>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -60,8 +61,17 @@ public:
|
||||
bool abortDownload;
|
||||
};
|
||||
|
||||
struct MemoryFile {
|
||||
std::string buffer;
|
||||
std::string format;
|
||||
};
|
||||
|
||||
using DownloadProgressCallback = std::function<void(const FileFuture&)>;
|
||||
using DownloadFinishedCallback = std::function<void(const FileFuture&)>;
|
||||
|
||||
using SuccessCallback = std::function<void(const MemoryFile&)>;
|
||||
using ErrorCallback = std::function<void(const std::string&)>;
|
||||
|
||||
using RequestFinishedCallback = std::function<void(std::string)>;
|
||||
using AsyncDownloadFinishedCallback =
|
||||
std::function<void(const std::vector<std::shared_ptr<FileFuture>>&)>;
|
||||
@@ -81,6 +91,10 @@ public:
|
||||
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback()
|
||||
);
|
||||
|
||||
std::future<MemoryFile> fetchFile(
|
||||
const std::string& url,
|
||||
SuccessCallback successCallback = SuccessCallback(), ErrorCallback errorCallback = ErrorCallback());
|
||||
|
||||
std::vector<std::shared_ptr<FileFuture>> downloadRequestFiles(const std::string& identifier,
|
||||
const ghoul::filesystem::Directory& destination, int version,
|
||||
bool overrideFiles = true,
|
||||
|
||||
Reference in New Issue
Block a user