From c032e4a66e62bda10820653f7921491991827742 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Tue, 14 Nov 2017 11:26:23 +0100 Subject: [PATCH] Add missing constructors --- include/openspace/util/httprequest.h | 15 +++++++++++---- include/openspace/util/resourcesynchronization.h | 5 ----- modules/sync/syncs/httpsynchronization.h | 2 -- src/util/httprequest.cpp | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/include/openspace/util/httprequest.h b/include/openspace/util/httprequest.h index 52e59d1d91..b94a4ef816 100644 --- a/include/openspace/util/httprequest.h +++ b/include/openspace/util/httprequest.h @@ -126,6 +126,7 @@ private: class HttpDownload { public: HttpDownload(); + HttpDownload(HttpDownload&& d); virtual ~HttpDownload() = default; using ProgressCallback = std::function; 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& 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; }; diff --git a/include/openspace/util/resourcesynchronization.h b/include/openspace/util/resourcesynchronization.h index eed9d1c1ef..5883fb0257 100644 --- a/include/openspace/util/resourcesynchronization.h +++ b/include/openspace/util/resourcesynchronization.h @@ -70,11 +70,6 @@ private: std::atomic _rejected; }; - - - - - } // namespace openspace #endif // __OPENSPACE_CORE___RESOURCESYNCHRONIZATION___H__ diff --git a/modules/sync/syncs/httpsynchronization.h b/modules/sync/syncs/httpsynchronization.h index 76541c528d..4c95098fff 100644 --- a/modules/sync/syncs/httpsynchronization.h +++ b/modules/sync/syncs/httpsynchronization.h @@ -32,8 +32,6 @@ namespace openspace { -class HttpSynchronizationJob; - class HttpSynchronization : public ResourceSynchronization { public: HttpSynchronization(const ghoul::Dictionary& dict); diff --git a/src/util/httprequest.cpp b/src/util/httprequest.cpp index daff1f0d62..8d7c81246d 100644 --- a/src/util/httprequest.cpp +++ b/src/util/httprequest.cpp @@ -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 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 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)