Started cleanup of module structure

This commit is contained in:
Alexander Bock
2015-12-14 10:50:38 -08:00
parent e26f1d41a4
commit 2fce471743
25 changed files with 298 additions and 302 deletions
@@ -29,11 +29,20 @@
namespace openspace {
/**
* The ConfigurationManager takes care of loading the major configuration file
* <code>openspace.cfg</code> and making it available to the rest of the application. The
* exposed keys in the ghoul::Dictionary are declared in this class as static constants.
* The findConfiguration method walks the filesystem from a provided starting point until
* it found the requested file or throws a ghoul::RuntimeError if it could not find the
* file. The loadFromFile method then loads the file into a ghoul::Dictionary format.
*/
class ConfigurationManager : public ghoul::Dictionary {
public:
/// The key that stores the subdirectory containing all predefined path tokens
static const std::string KeyPaths;
///
static const std::string KeyCache;
static const std::string KeyCachePath;
static const std::string KeyFonts;
static const std::string KeyConfigSgct;
static const std::string KeyLuaDocumentationType;
@@ -53,7 +62,9 @@ public:
static const std::string KeyDisableMasterRendering;
static const std::string KeyDownloadRequestURL;
bool loadFromFile(const std::string& filename);
static std::string findConfiguration(const std::string& filename);
void loadFromFile(const std::string& filename);
private:
bool checkCompleteness() const;
+17 -19
View File
@@ -26,12 +26,14 @@
#define __DOWNLOADMANAGER_H__
#include <ghoul/designpattern/singleton.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/directory.h>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace openspace {
@@ -58,42 +60,38 @@ public:
bool abortDownload;
};
typedef std::function<void(const FileFuture&)> DownloadProgressCallback;
typedef std::function<void(const FileFuture&)> DownloadFinishedCallback;
typedef std::function<void(const std::vector<FileFuture*>&)> AsyncDownloadFinishedCallback;
using DownloadProgressCallback = std::function<void(const FileFuture&)>;
using DownloadFinishedCallback = std::function<void(const FileFuture&)>;
using AsyncDownloadFinishedCallback =
std::function<void(const std::vector<FileFuture*>&)>;
DownloadManager(std::string requestURL, int applicationVersion);
DownloadManager(std::string requestURL, int applicationVersion,
bool useMultithreadedDownload = true);
// callers responsibility to delete
// callbacks happen on a different thread
FileFuture* downloadFile(
const std::string& url,
const ghoul::filesystem::File& file,
FileFuture* downloadFile(const std::string& url, const ghoul::filesystem::File& file,
bool overrideFile = true,
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(),
DownloadProgressCallback progressCallback = DownloadProgressCallback()
);
std::vector<FileFuture*> downloadRequestFiles(
const std::string& identifier,
const ghoul::filesystem::Directory& destination,
int version,
std::vector<FileFuture*> downloadRequestFiles(const std::string& identifier,
const ghoul::filesystem::Directory& destination, int version,
bool overrideFiles = true,
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(),
DownloadProgressCallback progressCallback = DownloadProgressCallback()
);
void downloadRequestFilesAsync(
const std::string& identifier,
const ghoul::filesystem::Directory& destination,
int version,
bool overrideFiles,
AsyncDownloadFinishedCallback callback
void downloadRequestFilesAsync(const std::string& identifier,
const ghoul::filesystem::Directory& destination, int version,
bool overrideFiles, AsyncDownloadFinishedCallback callback
);
private:
std::string _requestURL;
std::vector<std::string> _requestURL;
int _applicationVersion;
bool _useMultithreadedDownload;
};
#define DlManager (openspace::DownloadManager::ref())
+2 -4
View File
@@ -28,10 +28,8 @@
#include <memory>
namespace ghoul {
class Dictionary;
namespace logging {
class Log;
}
class Dictionary;
namespace logging { class Log; }
}
namespace openspace {
+15 -8
View File
@@ -25,26 +25,33 @@
#ifndef __MODULEENGINE_H__
#define __MODULEENGINE_H__
#include <openspace/util/openspacemodule.h>
#include <memory>
#include <vector>
namespace openspace {
class OpenSpaceModule;
/**
* The ModuleEngine is the central repository for registering and accessing
* OpenSpaceModule for the current application run. By create%ing the ModuleEngine, the
* default set of OpenSpaceModule%s as generated by CMake in the
* <code>moduleregistration.h</code> file is automatically registered and created.
*/
class ModuleEngine {
public:
bool create();
bool destroy();
void create();
void destroy();
bool initialize();
bool deinitialize();
void registerModules(std::vector<OpenSpaceModule*> modules);
void registerModule(OpenSpaceModule* module);
const std::vector<OpenSpaceModule*> modules() const;
void registerModules(std::vector<std::unique_ptr<OpenSpaceModule>> modules);
void registerModule(std::unique_ptr<OpenSpaceModule> module);
std::vector<OpenSpaceModule*> modules() const;
protected:
std::vector<OpenSpaceModule*> _modules;
std::vector<std::unique_ptr<OpenSpaceModule>> _modules;
};
+9 -8
View File
@@ -59,17 +59,17 @@ namespace properties { class PropertyOwner; }
class OpenSpaceEngine {
public:
static bool create(int argc, char** argv, std::unique_ptr<WindowWrapper> windowWrapper, std::vector<std::string>& sgctArguments);
static bool create(int argc, char** argv,
std::unique_ptr<WindowWrapper> windowWrapper,
std::vector<std::string>& sgctArguments);
static void destroy();
static bool isInitialized();
static OpenSpaceEngine& ref();
static bool isInitialized();
bool initialize();
bool isMaster();
void setMaster(bool master);
double runTime();
void setRunTime(double t);
static bool findConfiguration(std::string& filename);
// Guaranteed to return a valid pointer
ConfigurationManager& configurationManager();
@@ -86,6 +86,7 @@ public:
gui::GUI& gui();
// SGCT callbacks
bool initialize();
bool initializeGL();
void preSynchronization();
void postSynchronizationPreDraw();
@@ -116,8 +117,8 @@ private:
void runScripts(const ghoul::Dictionary& scripts);
void runStartupScripts();
void configureLogging();
// Components
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
std::unique_ptr<RenderEngine> _renderEngine;
@@ -131,13 +132,13 @@ private:
std::unique_ptr<WindowWrapper> _windowWrapper;
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
// Others
std::unique_ptr<properties::PropertyOwner> _globalPropertyNamespace;
std::unique_ptr<SyncBuffer> _syncBuffer;
bool _isMaster;
double _runTime;
std::unique_ptr<SyncBuffer> _syncBuffer;
static OpenSpaceEngine* _engine;
};
+10 -4
View File
@@ -34,15 +34,21 @@ public:
OpenSpaceModule(std::string name);
virtual ~OpenSpaceModule() = default;
virtual bool create();
virtual bool destroy();
void create();
void destroy();
virtual bool initialize();
virtual bool deinitialize();
bool initialize();
bool deinitialize();
std::string name() const;
protected:
virtual void internalCreate();
virtual void internalDestroy();
virtual void internalInitialize();
virtual void internalDeinitialize();
std::string modulePath() const;
const std::string _name;