mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 13:08:49 -05:00
Cleanup code
This commit is contained in:
@@ -102,8 +102,6 @@ public:
|
||||
|
||||
|
||||
void scheduleLoadSingleAsset(std::string assetPath);
|
||||
|
||||
void writeDocumentation();
|
||||
void toggleShutdownMode();
|
||||
|
||||
// Guaranteed to return a valid pointer
|
||||
@@ -166,6 +164,10 @@ public:
|
||||
std::function<bool (double, double)> function
|
||||
);
|
||||
|
||||
void writeSceneDocumentation();
|
||||
void writeStaticDocumentation();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* application.
|
||||
@@ -182,8 +184,7 @@ private:
|
||||
void loadFonts();
|
||||
|
||||
void configureLogging(bool consoleLog);
|
||||
void writeDocumentations();
|
||||
|
||||
|
||||
void runGlobalCustomizationScripts(const std::string& sceneDescription);
|
||||
void configureLogging();
|
||||
|
||||
|
||||
@@ -181,8 +181,6 @@ public:
|
||||
*/
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
std::string generateJson() const override;
|
||||
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___ASYNCHTTPREQUEST___H__
|
||||
#define __OPENSPACE_CORE___ASYNCHTTPREQUEST___H__
|
||||
|
||||
#include <future>
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class AsncHttpRequestData {
|
||||
public:
|
||||
std::chrono::system_clock::time_point startTime();
|
||||
std::chrono::system_clock::time_point finishTime();
|
||||
private:
|
||||
std::chrono::system_clock::time_point _startTime;
|
||||
std::chrono::system_clock::time_point _finishTime;
|
||||
};
|
||||
|
||||
class AsyncHttpRequest {
|
||||
public:
|
||||
enum class ReadyState : unsigned int {
|
||||
Unsent,
|
||||
Loading,
|
||||
Done
|
||||
};
|
||||
|
||||
using StateChangeCallback = std::function<void(ReadyState)>;
|
||||
using ProgressCallback = std::function<void(float)>;
|
||||
using DataCallback = std::function<void(char*, size_t)>;
|
||||
|
||||
AsyncHttpRequest(
|
||||
std::string url,
|
||||
DataCallback dataCallback);
|
||||
~AsyncHttpRequest();
|
||||
|
||||
virtual std::future<AsncHttpRequestData> start(
|
||||
StateChangeCallback stateChangeCallback,
|
||||
ProgressCallback progressCallback);
|
||||
void wait();
|
||||
|
||||
std::chrono::system_clock::duration timeElapsed();
|
||||
std::chrono::system_clock::duration estimatedTimeRemaining();
|
||||
float progress();
|
||||
ReadyState readyState();
|
||||
private:
|
||||
std::chrono::system_clock::time_point startTime;
|
||||
float _progress;
|
||||
};
|
||||
|
||||
//////
|
||||
|
||||
class AsncHttpDownloadData : public AsncHttpRequestData {
|
||||
public:
|
||||
std::string url();
|
||||
private:
|
||||
std::string _url;
|
||||
};
|
||||
|
||||
class AsyncHttpDownload : public AsyncHttpRequest {
|
||||
public:
|
||||
AsyncHttpDownload(
|
||||
std::string url,
|
||||
std::string path);
|
||||
virtual ~AsyncHttpDownload();
|
||||
|
||||
/*std::future<AsncHttpDownloadData> start(
|
||||
StateChangeCallback stateChangeCallback,
|
||||
ProgressCallback progressCallback) override;*/
|
||||
};
|
||||
|
||||
////
|
||||
|
||||
class AsyncHttpReadData : public AsncHttpRequestData {
|
||||
public:
|
||||
std::vector<char>& buffer();
|
||||
private:
|
||||
std::vector<char> _buffer;
|
||||
};
|
||||
|
||||
class AsyncHttpRead : public AsyncHttpRequest {
|
||||
public:
|
||||
AsyncHttpRead(std::string url);
|
||||
~AsyncHttpRead();
|
||||
/*std::future<AsncHttpReadData> start(
|
||||
StateChangeCallback stateChangeCallback,
|
||||
ProgressCallback progressCallback) override;*/
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___ASYNCHTTPREQUEST___H__
|
||||
|
||||
/*
|
||||
// start
|
||||
std::ostream file();
|
||||
AsyncHttpDownload d(url, file);
|
||||
std::future<AsyncHttpDownloadData> data = d->start(progressCallback, progressCallback);
|
||||
|
||||
// in event loop
|
||||
AsyncHttpRequest::ReadyState status = d.readyState();
|
||||
if (status == AsyncHttpRequest::ReadyState::Loading) {
|
||||
float progress = d.progress();
|
||||
// update some progress bar..
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// usage:
|
||||
|
||||
HTTPDownload ();
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user