mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Cleaning ConfigurationManager and OpenSpaceEngine
Updated Ghoul version
This commit is contained in:
Submodule ext/ghoul updated: ff01cac350...aef83ca794
@@ -41,32 +41,92 @@ class ConfigurationManager : public ghoul::Dictionary {
|
||||
public:
|
||||
/// The key that stores the subdirectory containing all predefined path tokens
|
||||
static const std::string KeyPaths;
|
||||
///
|
||||
/// The key that stores the location to the cache directory used to store all the
|
||||
/// permanent and non-permanent cached files
|
||||
static const std::string KeyCache;
|
||||
/// The key that stores the main directory for fonts
|
||||
static const std::string KeyFonts;
|
||||
/// The key that stores the location of the SGCT configuration file that is used on
|
||||
/// application launch
|
||||
static const std::string KeyConfigSgct;
|
||||
/// The key that stores the type of Lua documentation that should be stored
|
||||
static const std::string KeyLuaDocumentationType;
|
||||
/// The key that stores the save location of the Lua documentation
|
||||
static const std::string KeyLuaDocumentationFile;
|
||||
/// The key that stores the type of Property documentation that should be stored
|
||||
static const std::string KeyPropertyDocumentationType;
|
||||
/// The key that stores the save location of the Property documentation
|
||||
static const std::string KeyPropertyDocumentationFile;
|
||||
/// The key that stores the location of the scene file that is initially loaded
|
||||
static const std::string KeyConfigScene;
|
||||
static const std::string KeyEnableGui;
|
||||
/// The key that stores the subdirectory containing a list of all startup scripts to
|
||||
/// be executed on application start before the scene file is loaded
|
||||
static const std::string KeyStartupScript;
|
||||
/// The key that stores the subdirectory containing a list of all settings scripts to
|
||||
/// be executed on application start and after the scene file is loaded
|
||||
static const std::string KeySettingsScript;
|
||||
/// The key that stores the location of the SPICE time kernel to be loaded on
|
||||
/// application start
|
||||
static const std::string KeySpiceTimeKernel;
|
||||
/// The key that stores the location of the SPICE leapsecond kernel to be loaded on
|
||||
/// application start
|
||||
static const std::string KeySpiceLeapsecondKernel;
|
||||
/// The key that stores the desired LogLevel for the whole application
|
||||
/// \sa ghoul::logging::LogManager
|
||||
static const std::string KeyLogLevel;
|
||||
/// The key that stores whether the log should be immediately flushed after a n
|
||||
/// \sa ghoul::logging::LogManager
|
||||
static const std::string KeyLogImmediateFlush;
|
||||
/// The key that stores a subdirectory with a description for additional
|
||||
/// ghoul::logging::Log%s to be created
|
||||
/// \sa LogFactory
|
||||
static const std::string KeyLogs;
|
||||
/// The key that stores the verbosity (None, Minimal, Default, Full) of the system
|
||||
/// capabilities components
|
||||
static const std::string KeyCapabilitiesVerbosity;
|
||||
/// The key that stores whether the master node should perform rendering just function
|
||||
/// as a pure manager
|
||||
static const std::string KeyDisableMasterRendering;
|
||||
/// The key that sets the request URL that is used to request additional data to be
|
||||
/// downloaded
|
||||
static const std::string KeyDownloadRequestURL;
|
||||
|
||||
/**
|
||||
* Iteratively walks the directory structure starting with \p filename to find the
|
||||
* base name compoenent of \p filename. The directory structure is searched by first
|
||||
* searching the current directory and then moving iteratively to the the parent
|
||||
* directory.
|
||||
* \param filename The fully qualified filename to be searched for
|
||||
* \return The path to the file that was found with the same base name as \p filename
|
||||
* but higher up in the file structure.
|
||||
* \throw ghoul::RuntimeError If the configuration could not be found
|
||||
* \pre \p filename must not be empty
|
||||
*/
|
||||
static std::string findConfiguration(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Load the provided configuration file (\p filename) into this Dictionary. All paths
|
||||
* that are specified in the configuration file will automatically be registered in
|
||||
* the ghoul::filesystem::FileSystem.
|
||||
* \param filename The filename to be loaded
|
||||
* \throw ghoul::FileNotFoundException If the \p filename did not exist
|
||||
* \throw ghoul::RuntimeError If the configuration file was not complete (i.e., did
|
||||
* not specify the necessary keys KeyPaths, KeyPaths.KeyCache, KeyFonts, and
|
||||
* KeyConfigSgct)
|
||||
* \throw ghoul::lua::LuaRuntimeException If there was Lua-based error loading the
|
||||
* configuration file
|
||||
* \pre \p filename must not be empty
|
||||
*/
|
||||
void loadFromFile(const std::string& filename);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Checks whether the loaded configuration file is complete, that is specifying the
|
||||
* necessary keys KeyPaths, KeyPaths.KeyCache, KeyFonts, and KeyConfigSgct. The method
|
||||
* will log fatal errors if a key is missing.
|
||||
* \return <code>true</code> if the configuration file was complete;
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
bool checkCompleteness() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ const string ConfigurationManager::KeyPropertyDocumentationType =
|
||||
const string ConfigurationManager::KeyPropertyDocumentationFile =
|
||||
"PropertyDocumentationFile.File";
|
||||
const string ConfigurationManager::KeyConfigScene = "Scene";
|
||||
const string ConfigurationManager::KeyEnableGui = "EnableGUI";
|
||||
const string ConfigurationManager::KeyStartupScript = "StartupScripts";
|
||||
const string ConfigurationManager::KeySettingsScript = "SettingsScripts";
|
||||
const string ConfigurationManager::KeySpiceTimeKernel = "SpiceKernel.Time";
|
||||
@@ -66,6 +65,8 @@ const string ConfigurationManager::KeyDisableMasterRendering = "DisableRendering
|
||||
const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL";
|
||||
|
||||
string ConfigurationManager::findConfiguration(const string& filename) {
|
||||
ghoul_assert(!filename.empty(), "Filename must not be empty");
|
||||
|
||||
using ghoul::filesystem::Directory;
|
||||
|
||||
Directory directory = FileSys.currentDirectory();
|
||||
@@ -110,13 +111,6 @@ void ConfigurationManager::loadFromFile(const string& filename) {
|
||||
ghoul::lua::loadDictionaryFromFile(filename, *this);
|
||||
|
||||
// Register all the paths
|
||||
// const bool hasPath = hasKeyAndValue<std::string>(KeyPaths);
|
||||
// if (!hasPath) {
|
||||
// throw ghoul::RuntimeError(
|
||||
// "Configuration does not contain the key '" + KeyPaths + "'",
|
||||
// "ConfifgurationManager"
|
||||
// );
|
||||
// }
|
||||
ghoul::Dictionary dictionary = value<ghoul::Dictionary>(KeyPaths);
|
||||
|
||||
std::vector<std::string> pathKeys = dictionary.keys();
|
||||
@@ -135,14 +129,16 @@ void ConfigurationManager::loadFromFile(const string& filename) {
|
||||
}
|
||||
|
||||
bool complete = checkCompleteness();
|
||||
if (!complete)
|
||||
return false;
|
||||
if (!complete) {
|
||||
throw ghoul::RuntimeError(
|
||||
"Configuration file '" + filename + "' was not complete",
|
||||
"ConfigurationManager"
|
||||
);
|
||||
}
|
||||
|
||||
// Remove the Paths dictionary from the configuration manager as those paths might
|
||||
// change later and we don't want to be forced to keep our local copy up to date
|
||||
removeKey(KeyPaths);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConfigurationManager::checkCompleteness() const {
|
||||
|
||||
@@ -306,6 +306,7 @@ bool OpenSpaceEngine::initialize() {
|
||||
Verbosity verbosity = Verbosity::Default;
|
||||
if (configurationManager().hasKeyAndValue<std::string>(ConfigurationManager::KeyCapabilitiesVerbosity)) {
|
||||
std::map<std::string, Verbosity> verbosityMap = {
|
||||
{ "None", Verbosity::None },
|
||||
{ "Minimal", Verbosity::Minimal },
|
||||
{ "Default", Verbosity::Default },
|
||||
{ "Full", Verbosity::Full }
|
||||
|
||||
Reference in New Issue
Block a user