Rename DownloadEngine to DownloadManager

This commit is contained in:
Alexander Bock
2015-05-27 17:14:20 +02:00
parent b18ccfad23
commit 38c2477492
5 changed files with 38 additions and 15 deletions

View File

@@ -22,26 +22,34 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __DOWNLOADENGINE_H__
#define __DOWNLOADENGINE_H__
#ifndef __DOWNLOADMANAGER_H__
#define __DOWNLOADMANAGER_H__
#include <ghoul/designpattern/singleton.h>
#include <ghoul/filesystem/file.h>
#include <functional>
#include <string>
namespace openspace {
class DownloadEngine {
class DownloadManager : public ghoul::Singleton<DownloadManager> {
public:
typedef std::function<void (const File&)> DownloadFinishedCallback;
typedef std::function<void (const ghoul::filesystem::File&)> DownloadFinishedCallback;
static bool downloadFile(
DownloadManager(std::string requestURL);
bool downloadFile(
const std::string& url,
const ghoul::filesystem::File& file,
DownloadFinishedCallback callback = DownloadFinishedCallback()
);
private:
std::string _requestURL;
};
#define DlManager (openspace::DownloadManager::ref())
} // namespace openspace
#endif // __DOWNLOADENGINE_H__
#endif // __DOWNLOADMANAGER_H__

View File

@@ -53,6 +53,7 @@ return {
Type = "text",
File = "${BASE_PATH}/Properties.txt"
},
DownloadRequestURL = "http://openspace.itn.liu.se/request.cgi",
RenderingMethod = "ABufferSingleLinked" -- On Windows and Unix
-- RenderingMethod = "ABufferFrameBuffer" -- On Mac due to OpenGL 4.1 restrictions
}

View File

@@ -30,7 +30,7 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/abuffer/abuffersinglelinked.cpp
${OPENSPACE_BASE_DIR}/src/abuffer/abuffervisualizer.cpp
${OPENSPACE_BASE_DIR}/src/engine/configurationmanager.cpp
${OPENSPACE_BASE_DIR}/src/engine/downloadengine.cpp
${OPENSPACE_BASE_DIR}/src/engine/downloadmanager.cpp
${OPENSPACE_BASE_DIR}/src/engine/logfactory.cpp
${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp
${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp
@@ -96,7 +96,7 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffersinglelinked.h
${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffervisualizer.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/configurationmanager.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/downloadengine.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/downloadmanager.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/logfactory.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/downloadengine.h>
#include <openspace/engine/downloadmanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
@@ -32,7 +32,7 @@
#endif
namespace {
const std::string _loggerCat = "DownloadEngine";
const std::string _loggerCat = "DownloadManager";
size_t writeData(void* ptr, size_t size, size_t nmemb, FILE* stream) {
size_t written;
@@ -43,7 +43,14 @@ namespace {
namespace openspace {
bool DownloadEngine::downloadFile(
DownloadManager::DownloadManager(std::string requestURL)
: _requestURL(std::move(requestURL))
{
curl_global_init(CURL_GLOBAL_ALL);
// Check if URL is accessible
}
bool DownloadManager::downloadFile(
const std::string& url,
const ghoul::filesystem::File& file,
DownloadFinishedCallback callback)
@@ -70,4 +77,5 @@ bool DownloadEngine::downloadFile(
}
}
} // namespace openspace

View File

@@ -47,7 +47,7 @@
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/downloadengine.h>
#include <openspace/engine/downloadmanager.h>
#include <ghoul/ghoul.h>
#include <ghoul/cmdparser/commandlineparser.h>
@@ -88,6 +88,7 @@ namespace {
const std::string KeyRenderingMethod = "RenderingMethod";
const std::string DefaultRenderingMethod = "ABufferSingleLinked";
const std::string KeyDownloadRequestURL = "DownloadRequestURL";
const std::string DefaultOpenGlVersion = "4.3";
@@ -301,8 +302,13 @@ bool OpenSpaceEngine::initialize() {
SysCap.detectCapabilities();
SysCap.logCapabilities();
std::string requestURL = "";
bool success = configurationManager()->getValue(KeyDownloadRequestURL, requestURL);
if (success)
DownloadManager::initialize(requestURL);
// Load SPICE time kernel
bool success = loadSpiceKernels();
success = loadSpiceKernels();
if (!success)
return false;
@@ -366,8 +372,8 @@ bool OpenSpaceEngine::initialize() {
// Load a light and a monospaced font
loadFonts();
ghoul::filesystem::File f("d:/foo.txt");
DownloadEngine::downloadFile("http://curl.haxx.se/libcurl/c/example.html", f);
//ghoul::filesystem::File f("d:/foo.txt");
//DownloadEngine::downloadFile("http://curl.haxx.se/libcurl/c/example.html", f);
_gui->initialize();