Add missing constructors

This commit is contained in:
Emil Axelsson
2017-11-14 11:26:23 +01:00
parent 81f45aed71
commit c032e4a66e
4 changed files with 26 additions and 11 deletions
+11 -4
View File
@@ -126,6 +126,7 @@ private:
class HttpDownload {
public:
HttpDownload();
HttpDownload(HttpDownload&& d);
virtual ~HttpDownload() = default;
using ProgressCallback = std::function<bool(HttpRequest::Progress)>;
void onProgress(ProgressCallback progressCallback);
@@ -153,6 +154,7 @@ private:
class SyncHttpDownload : public virtual HttpDownload {
public:
SyncHttpDownload(std::string url);
SyncHttpDownload(SyncHttpDownload&& d) = default;
virtual ~SyncHttpDownload() = default;
void download(HttpRequest::RequestOptions opt);
protected:
@@ -162,6 +164,7 @@ protected:
class AsyncHttpDownload : public virtual HttpDownload {
public:
AsyncHttpDownload(std::string url);
AsyncHttpDownload(AsyncHttpDownload&& d);
virtual ~AsyncHttpDownload() = default;
void start(HttpRequest::RequestOptions opt);
void cancel();
@@ -178,7 +181,9 @@ private:
class HttpFileDownload : public virtual HttpDownload {
public:
HttpFileDownload() = default;
HttpFileDownload(std::string destination);
HttpFileDownload(HttpFileDownload&& d) = default;
virtual ~HttpFileDownload() = default;
protected:
bool initDownload() override;
@@ -191,6 +196,8 @@ private:
class HttpMemoryDownload : public virtual HttpDownload {
public:
HttpMemoryDownload() = default;
HttpMemoryDownload(HttpMemoryDownload&& d) = default;
virtual ~HttpMemoryDownload() = default;
const std::vector<char>& downloadedData();
protected:
@@ -205,7 +212,7 @@ private:
class SyncHttpMemoryDownload : public SyncHttpDownload, public HttpMemoryDownload {
public:
SyncHttpMemoryDownload(std::string url);
SyncHttpMemoryDownload(SyncHttpMemoryDownload&&);
SyncHttpMemoryDownload(SyncHttpMemoryDownload&&) = default;
virtual ~SyncHttpMemoryDownload() = default;
};
@@ -213,7 +220,7 @@ public:
class SyncHttpFileDownload : public SyncHttpDownload, public HttpFileDownload {
public:
SyncHttpFileDownload(std::string url, std::string destinationPath);
SyncHttpFileDownload(SyncHttpFileDownload&&);
SyncHttpFileDownload(SyncHttpFileDownload&&) = default;
virtual ~SyncHttpFileDownload() = default;
};
@@ -221,7 +228,7 @@ public:
class AsyncHttpMemoryDownload : public AsyncHttpDownload, public HttpMemoryDownload {
public:
AsyncHttpMemoryDownload(std::string url);
AsyncHttpMemoryDownload(AsyncHttpMemoryDownload&&);
AsyncHttpMemoryDownload(AsyncHttpMemoryDownload&&) = default;
virtual ~AsyncHttpMemoryDownload() = default;
};
@@ -229,7 +236,7 @@ public:
class AsyncHttpFileDownload : public AsyncHttpDownload, public HttpFileDownload {
public:
AsyncHttpFileDownload(std::string url, std::string destinationPath);
AsyncHttpFileDownload(AsyncHttpFileDownload&&);
AsyncHttpFileDownload(AsyncHttpFileDownload&&) = default;
virtual ~AsyncHttpFileDownload() = default;
};
@@ -70,11 +70,6 @@ private:
std::atomic<bool> _rejected;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___RESOURCESYNCHRONIZATION___H__
-2
View File
@@ -32,8 +32,6 @@
namespace openspace {
class HttpSynchronizationJob;
class HttpSynchronization : public ResourceSynchronization {
public:
HttpSynchronization(const ghoul::Dictionary& dict);
+15
View File
@@ -135,6 +135,14 @@ HttpDownload::HttpDownload()
: _onProgress([] (HttpRequest::Progress) { return true; })
{}
HttpDownload::HttpDownload(HttpDownload&& d)
: _onProgress(std::move(d._onProgress))
, _started(std::move(d._started))
, _failed(std::move(d._failed))
, _successful(std::move(d._successful))
{}
void HttpDownload::onProgress(ProgressCallback progressCallback) {
std::lock_guard<std::mutex> guard(_onProgressMutex);
_onProgress = progressCallback;
@@ -189,6 +197,12 @@ AsyncHttpDownload::AsyncHttpDownload(std::string url)
: _httpRequest(std::move(url))
{}
AsyncHttpDownload::AsyncHttpDownload(AsyncHttpDownload&& d)
: _httpRequest(std::move(d._httpRequest))
, _downloadThread(std::move(d._downloadThread))
, _shouldCancel(std::move(d._shouldCancel))
{}
void AsyncHttpDownload::start(HttpRequest::RequestOptions opt) {
std::lock_guard<std::mutex> guard(_mutex);
if (hasStarted()) {
@@ -300,6 +314,7 @@ size_t HttpFileDownload::handleData(HttpRequest::Data d) {
SyncHttpMemoryDownload::SyncHttpMemoryDownload(std::string url)
: SyncHttpDownload(std::move(url))
, HttpMemoryDownload()
{}
SyncHttpFileDownload::SyncHttpFileDownload(std::string url, std::string destinationPath)