Feature/configuration (#605)

* Switch openspace.cfg file from a Dictionary-based loading to a variable based loading
 * Change ConfigurationManager to not use Dictionary anymore, but a struct with explicit configuration values instead
This commit is contained in:
Alexander Bock
2018-04-20 18:40:21 -04:00
committed by GitHub
parent 3810209365
commit b4be63af65
30 changed files with 1026 additions and 1201 deletions

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/sgctwindowwrapper.h>
#include <openspace/util/keys.h>
@@ -313,10 +313,10 @@ void mainInitFunc() {
#endif // OPENSPACE_HAS_SPOUT
}
std::string k = openspace::ConfigurationManager::KeyScreenshotUseDate;
std::string screenshotPath = "${SCREENSHOTS}";
std::string screenshotNames = "OpenSpace";
if (OsEng.configurationManager().hasKey(k)) {
if (OsEng.configuration().shouldUseScreenshotDate) {
std::time_t now = std::time(nullptr);
std::tm* nowTime = std::localtime(&now);
char mbstr[100];

View File

@@ -23,7 +23,6 @@
****************************************************************************************/
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/util/factorymanager.h>

View File

@@ -44,7 +44,6 @@
#include <openspace/rendering/dashboarditem.h>
#include <openspace/util/progressbar.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/util/taskloader.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/resourcesynchronization.h>

View File

@@ -0,0 +1,134 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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___CONFIGURATION___H__
#define __OPENSPACE_CORE___CONFIGURATION___H__
#include <ghoul/lua/luastate.h>
#include <ghoul/misc/dictionary.h>
#include <map>
#include <string>
#include <vector>
namespace openspace {
namespace documentation { struct Documentation; }
struct Configuration {
std::string windowConfiguration = "${CONFIG}/single.xml";
std::string asset = "default";
std::vector<std::string> globalCustomizationScripts;
std::map<std::string, std::string> pathTokens;
std::map<std::string, std::string> fonts;
struct Logging {
std::string level = "Info";
std::string directory = "${BASE}";
std::string performancePrefix = "PM-";
bool forceImmediateFlush = false;
std::string capabilitiesVerbosity = "Default";
std::vector<ghoul::Dictionary> logs;
};
Logging logging;
std::string scriptLog = "";
struct DocumentationInfo {
std::string lua = "";
std::string property = "";
std::string sceneProperty = "";
std::string keyboard = "";
std::string documentation = "";
std::string factory = "";
std::string license = "";
};
DocumentationInfo documentation;
bool useMultithreadedInitialization = false;
struct LoadingScreen {
bool isShowingMessages = true;
bool isShowingNodeNames = true;
bool isShowingProgressbar = true;
};
LoadingScreen loadingScreen;
bool isCheckingOpenGLState = false;
bool isLoggingOpenGLCalls = false;
float shutdownCountdown = 0.f;
bool shouldUseScreenshotDate = false;
std::string onScreenTextScaling = "window";
bool usePerSceneCache = false;
bool isRenderingOnMasterDisabled = false;
bool isSceneTranslationOnMasterDisabled = false;
std::map<std::string, ghoul::Dictionary> moduleConfigurations;
std::string renderingMethod = "Framebuffer";
struct OpenGLDebugContext {
bool isActive = false;
bool isSynchronous = true;
struct IdentifierFilter {
std::string type = "";
std::string source = "";
unsigned int identifier = 0;
};
std::vector<IdentifierFilter> identifierFilters;
std::vector<std::string> severityFilters;
};
OpenGLDebugContext openGLDebugContext;
std::string serverPasskey = "17308";
bool doesRequireSocketAuthentication = true;
std::vector<std::string> clientAddressWhitelist = {};
std::string webHelperLocation = "";
std::string cefWebGuiUrl = "";
struct HTTPProxy {
bool usingHttpProxy = false;
std::string address;
unsigned int port = 0;
std::string authentication = "BASIC";
std::string user;
std::string password;
};
HTTPProxy httpProxy;
static documentation::Documentation Documentation;
ghoul::lua::LuaState state;
};
std::string findConfiguration(const std::string& filename = "openspace.cfg");
Configuration loadConfigurationFromFile(const std::string& filename);
} // namespace openspace
#endif // __OPENSPACE_CORE___CONFIGURATION___H__

View File

@@ -1,282 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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___CONFIGURATIONMANAGER___H__
#define __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__
#include <ghoul/misc/dictionary.h>
namespace openspace {
namespace documentation { struct Documentation; }
/**
* 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 constexpr const char* KeyPaths = "Paths";
/// The key that stores the location to the cache directory used to store all the
/// permanent and non-permanent cached files
static constexpr const char* KeyCachePath = "Paths.CACHE";
/// The key that stores the main directory for fonts
static constexpr const char* KeyFonts = "Fonts";
/// The key that stores the location of the SGCT configuration file that is used on
/// application launch
static constexpr const char* KeyConfigSgct = "SGCTConfig";
/// The key that defines a list of scripts for global customization that get executed
/// regardless of which scene is loaded
static constexpr const char* KeyGlobalCustomizationScripts =
"GlobalCustomizationScripts";
/// The part of the key that defines the type
// static constexpr const char* PartType = "Type";
/// The part of the key that defines the file
// static constexpr const char* PartFile = "File";
/// The key that stores the Lua documentation
static constexpr const char* KeyLuaDocumentation = "LuaDocumentation";
/// The key that stores the scripting log
static constexpr const char* KeyScriptLog = "ScriptLog";
/// The key that stores the Scene Property documentation
static constexpr const char* KeyScenePropertyDocumentation =
"ScenePropertyDocumentation";
/// The key that stores the Root Property documentation
static constexpr const char* KeyPropertyDocumentation = "PropertyDocumentation";
/// The key that stores the keyboard bindings that should be stored
static constexpr const char* KeyKeyboardShortcuts = "KeyboardShortcuts";
/// The key that stores the main documentation
static constexpr const char* KeyDocumentation = "Documentation";
/// The key that stores the factory documentation values
static constexpr const char* KeyFactoryDocumentation = "FactoryDocumentation";
/// The key that decides whether or not we should require incoming web socket
/// connections to authorize or not
static constexpr const char* KeyRequireSocketAuthentication =
"RequireSocketAuthentication";
/// The key that stores the location of the asset file that is initially loaded
static constexpr const char* KeyConfigAsset = "Asset";
/// The key that stores the scene license documentation values
static constexpr const char* KeySceneLicenseDocumentation = "LicenseDocumentation";
/// The key that stores the settings for determining log-related settings
static constexpr const char* KeyLogging = "Logging";
/// The key that stores the directory for Logging
static constexpr const char* LoggingDirectory = "Logging.LogDir";
static constexpr const char* PartLogDir = "LogDir";
/// The key that stores the desired LogLevel for the whole application
/// \sa ghoul::logging::LogManager
static constexpr const char* KeyLoggingLogLevel = "Logging.LogLevel";
static constexpr const char* PartLogLevel = "LogLevel";
/// The key that stores whether the log should be immediately flushed after a n
/// \sa ghoul::logging::LogManager
static constexpr const char* KeyLoggingImmediateFlush = "Logging.ImmediateFlush";
static constexpr const char* PartImmediateFlush = "ImmediateFlush";
/// The key for prefixing PerformanceMeasurement logfiles
static constexpr const char* LoggingPerformancePrefix = "Logging.PerformancePrefix";
static constexpr const char* PartLogPerformancePrefix = "PerformancePrefix";
/// The key that stores a subdirectory with a description for additional
/// ghoul::logging::Log%s to be created
/// \sa LogFactory
static constexpr const char* KeyLoggingLogs = "Logging.Logs";
static constexpr const char* PartLogs = "Logs";
/// The key that stores whether a log should be appended to or should be overwritten
static constexpr const char* PartAppend = "Append";
/// The key that stores the verbosity (None, Minimal, Default, Full) of the system
/// capabilities components
static constexpr const char* PartCapabilitiesVerbosity = "CapabilitiesVerbosity";
/// The key that stores the settings for determining Launcher-related settings
static constexpr const char* KeyLauncher = "Launcher";
/// The full key that stores the verbosity of the system capabilities component
static constexpr const char* KeyCapabilitiesVerbosity =
"Logging.CapabilitiesVerbosity";
/// The key that stores the time (in seconds) that the application will wait before
/// shutting down after the shutdown call is made
static constexpr const char* KeyShutdownCountdown = "ShutdownCountdown";
/// The key that stores whether the onscreen text should be scaled to the window size
/// or the window resolution
static constexpr const char* KeyOnScreenTextScaling = "OnScreenTextScaling";
/// The key that stores whether the master node should perform rendering just function
/// as a pure manager
static constexpr const char* KeyDisableMasterRendering = "DisableRenderingOnMaster";
/// The key that stores whether the master node should apply the scene transformation
static constexpr const char* KeyDisableSceneOnMaster = "DisableSceneOnMaster";
/// The key that stores the switch for enabling/disabling the rendering on a master
/// computer
static constexpr const char* KeyRenderingMethod = "RenderingMethod";
/// The key that determines whether a new cache folder is used for each scene file
static constexpr const char* KeyPerSceneCache = "PerSceneCache";
/// The key that stores the http proxy settings for the downloadmanager
static constexpr const char* KeyHttpProxy = "HttpProxy";
/// The key that stores the address of the http proxy
static constexpr const char* PartHttpProxyAddress = "Address";
/// The key that stores the port of the http proxy
static constexpr const char* PartHttpProxyPort = "Port";
/// The key that stores the authentication method of the http proxy
static constexpr const char* PartHttpProxyAuthentication = "Authentication";
/// Key that stores the username to use for authentication to access the http proxy
static constexpr const char* PartHttpProxyUser = "User";
/// Key that stores the password to use for authentication to access the http proxy
static constexpr const char* PartHttpProxyPassword = "Password";
/// The key that stores the dictionary containing information about debug contexts
static constexpr const char* KeyOpenGLDebugContext = "OpenGLDebugContext";
/// The part of the key storing whether an OpenGL Debug context should be created
static constexpr const char* PartActivate = "Activate";
/// The part of the key storing whether the debug callbacks are performed synchronous
static constexpr const char* PartSynchronous = "Synchronous";
/// The part of the key storing a list of identifiers that should be filtered out
static constexpr const char* PartFilterIdentifier = "FilterIdentifier";
/// The part of the key that stores the source of the ignored identifier
static constexpr const char* PartFilterIdentifierSource = "Source";
/// The part of the key that stores the type of the ignored identifier
static constexpr const char* PartFilterIdentifierType = "Type";
/// The part of the key that stores the identifier of the ignored identifier
static constexpr const char* PartFilterIdentifierIdentifier = "Identifier";
/// The part of the key storing a list of severities that should be filtered out
static constexpr const char* PartFilterSeverity = "PartFilterSeverity";
/// The part of the key storing whether the OpenGL state should be checked each call
static constexpr const char* KeyCheckOpenGLState = "CheckOpenGLState";
/// The part of the key storing whether the OpenGL state should be checked each call
static constexpr const char* KeyServerPasskey = "ServerPasskey";
/// Whitelist of client addresses that won't need autorization
static constexpr const char* KeyServerClientAddressWhitelist =
"ClientAddressWhitelist";
static constexpr const char* KeyLogEachOpenGLCall = "LogEachOpenGLCall";
/// This key determines whether the scene graph nodes should initialized multithreaded
static constexpr const char* KeyUseMultithreadedInitialization =
"UseMultithreadedInitialization";
/// The key under which all of the loading settings are grouped
static constexpr const char* KeyLoadingScreen = "LoadingScreen";
/// The part of the key storing whether the loading screen should display the message
/// about current status
static constexpr const char* KeyLoadingScreenShowMessage =
"LoadingScreen.ShowMessage";
static constexpr const char* PartShowMessage = "ShowMessage";
/// The part of the key storing whether the loading screen should display node names
static constexpr const char* KeyLoadingScreenShowNodeNames =
"LoadingScreen.ShowNodeNames";
static constexpr const char* PartShowNodeNames = "ShowNodeNames";
/// The part of the key storing whether the loading screen should contain a progress
/// bar
static constexpr const char* KeyLoadingScreenShowProgressbar =
"LoadingScreen.ShowProgressbar";
static constexpr const char* PartShowProgressbar = "ShowProgressbar";
/// The key used to specify module specific configurations
static constexpr const char* KeyModuleConfigurations = "ModuleConfigurations";
/// The key used to specify whether screenshots should contain the current date
static constexpr const char* KeyScreenshotUseDate = "ScreenshotUseDate";
static constexpr const char* KeyWebHelperLocation = "WebHelperLocation";
static constexpr const char* KeyCefWebGuiUrl = "CefWebGuiUrl";
/**
* 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
*/
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 SpecificationError 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
* \pre \p filename must exist
*/
void loadFromFile(const std::string& filename);
static documentation::Documentation Documentation();
};
} // namespace openspace
#endif // __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__

View File

@@ -33,6 +33,7 @@
#include <ghoul/misc/assert.h>
#include <algorithm>
#include <map>
namespace ghoul::systemcapabilities { struct Version; }
@@ -59,7 +60,7 @@ public:
* \throw ghoul::RuntimeError If two modules in the default modules have the same
* name
*/
void initialize(const ghoul::Dictionary& moduleConfigurations);
void initialize(const std::map<std::string, ghoul::Dictionary>& moduleConfigurations);
/**
* Calls the initializeGL functions of all registered OpenSpaceModule%s.

View File

@@ -44,7 +44,7 @@ namespace ghoul::fontrendering { class FontManager; }
namespace openspace {
class AssetManager;
class ConfigurationManager;
struct Configuration;
class Dashboard;
class DownloadManager;
class GUI;
@@ -121,8 +121,9 @@ public:
void scheduleLoadSingleAsset(std::string assetPath);
void toggleShutdownMode();
const Configuration& configuration() const;
// Guaranteed to return a valid pointer
ConfigurationManager& configurationManager();
LuaConsole& console();
AssetManager& assetManager();
Dashboard& dashboard();
@@ -205,8 +206,9 @@ private:
void runGlobalCustomizationScripts();
void configureLogging();
std::unique_ptr<Configuration> _configuration;
// Components
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<Scene> _scene;
std::unique_ptr<AssetManager> _assetManager;
std::unique_ptr<Dashboard> _dashboard;

View File

@@ -42,7 +42,6 @@
#include <openspace/rendering/deferredcastermanager.h>
#include <modules/atmosphere/rendering/atmospheredeferredcaster.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/renderer.h>

View File

@@ -28,7 +28,6 @@
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/time.h>

View File

@@ -25,7 +25,6 @@
#include <modules/base/rendering/renderablesphericalgrid.h>
#include <modules/base/basemodule.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>

View File

@@ -27,7 +27,7 @@
#include <modules/globebrowsing/tile/rawtiledatareader/gdalwrapper.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/configuration.h>
#include <ghoul/filesystem/filesystem.h> // abspath
#include <ghoul/ghoul.h>
@@ -142,64 +142,24 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize
}
void GdalWrapper::setGdalProxyConfiguration() {
ghoul::Dictionary proxySettings;
bool proxyEnabled = OsEng.configurationManager().getValue(
ConfigurationManager::KeyHttpProxy, proxySettings
);
if (proxyEnabled) {
std::string proxyAddress, proxyPort, proxyUser, proxyPassword,
proxyAuth;
if (OsEng.configuration().httpProxy.usingHttpProxy) {
std::string address = OsEng.configuration().httpProxy.address;
unsigned int port = OsEng.configuration().httpProxy.port;
std::string user = OsEng.configuration().httpProxy.user;
std::string password = OsEng.configuration().httpProxy.password;
std::string auth = OsEng.configuration().httpProxy.authentication;
std::transform(auth.begin(), auth.end(), auth.begin(), ::toupper);
bool success = proxySettings.getValue(
ConfigurationManager::PartHttpProxyAddress,
proxyAddress
);
success &= proxySettings.getValue(
ConfigurationManager::PartHttpProxyPort,
proxyPort
);
proxySettings.getValue(
ConfigurationManager::PartHttpProxyAuthentication,
proxyAuth
);
std::string proxy = address + ":" + std::to_string(port);
CPLSetConfigOption("GDAL_HTTP_PROXY", proxy.c_str());
LDEBUG(fmt::format("Using proxy server {}", proxy));
std::string proxyAuthString = "BASIC";
if (proxyAuth == "basic" || proxyAuth == "") {
proxyAuthString = "BASIC";
} else if (proxyAuth == "ntlm") {
proxyAuthString = "NTLM";
} else if (proxyAuth == "digest") {
proxyAuthString = "DIGEST";
} else if (proxyAuth == "any") {
proxyAuthString = "ANY";
} else {
success = false;
if (!user.empty() && !password.empty()) {
std::string userPwd = user + ":" + password;
CPLSetConfigOption("GDAL_HTTP_PROXYUSERPWD", userPwd.c_str());
CPLSetConfigOption("GDAL_HTTP_PROXYAUTH", auth.c_str());
LDEBUG(fmt::format("Using authentication method: {}", auth));
}
bool userAndPassword = proxySettings.getValue(
ConfigurationManager::PartHttpProxyUser,
proxyUser
);
userAndPassword &= proxySettings.getValue(
ConfigurationManager::PartHttpProxyPassword,
proxyPassword
);
if (success) {
std::string proxy = proxyAddress + ":" + proxyPort;
CPLSetConfigOption("GDAL_HTTP_PROXY", proxy.c_str());
LDEBUG(fmt::format("Using proxy server {}", proxy));
if (userAndPassword) {
std::string proxyUserPwd = proxyUser + ":" + proxyPassword;
CPLSetConfigOption("GDAL_HTTP_PROXYUSERPWD", proxyUserPwd.c_str());
CPLSetConfigOption("GDAL_HTTP_PROXYAUTH", proxyAuthString.c_str());
LDEBUG(fmt::format("Using authentication method: {}", proxyAuthString));
}
} else {
LERROR("Invalid proxy settings for GDAL");
}
} else {
LDEBUG("Setting up GDAL without proxy server");
}
}

View File

@@ -38,8 +38,6 @@
#include <modules/globebrowsing/geometry/geodeticpatch.h>
#include <modules/globebrowsing/geometry/angle.h>
#include <openspace/engine/configurationmanager.h>
#include <float.h>
#include <sstream>
#include <algorithm>

View File

@@ -24,7 +24,6 @@
#include <modules/multiresvolume/rendering/renderablemultiresvolume.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/rendering/renderengine.h>

View File

@@ -34,7 +34,6 @@
#include <ghoul/logging/logmanager.h>
#include <fmt/format.h>
#include <include/openspace/engine/openspaceengine.h>
#include <include/openspace/engine/configurationmanager.h>
#include "topic.h"

View File

@@ -23,6 +23,7 @@
****************************************************************************************/
#include <modules/server/include/connection.h>
#include <modules/server/include/authorizationtopic.h>
#include <modules/server/include/getpropertytopic.h>
#include <modules/server/include/luascripttopic.h>
@@ -30,6 +31,7 @@
#include <modules/server/include/subscriptiontopic.h>
#include <modules/server/include/timetopic.h>
#include <modules/server/include/triggerpropertytopic.h>
#include <openspace/engine/configuration.h>
namespace {
constexpr const char* _loggerCat = "ServerModule: Connection";
@@ -67,15 +69,7 @@ Connection::Connection(std::shared_ptr<ghoul::io::Socket> s, const std::string &
_topicFactory.registerClass<BounceTopic>(BounceTopicKey);
// see if the default config for requiring auth (on) is overwritten
const bool hasAuthConfiguration = OsEng.configurationManager().hasKeyAndValue<bool>(
ConfigurationManager::KeyRequireSocketAuthentication
);
if (hasAuthConfiguration) {
_requireAuthorization = OsEng.configurationManager().value<bool>(
ConfigurationManager::KeyRequireSocketAuthentication);
} else {
_requireAuthorization = true;
}
_requireAuthorization = OsEng.configuration().doesRequireSocketAuthentication;
}
void Connection::handleMessage(std::string message) {
@@ -186,16 +180,8 @@ void Connection::setAuthorized(const bool status) {
}
bool Connection::isWhitelisted() {
const bool hasWhitelist = OsEng.configurationManager().hasKeyAndValue<std::string>(
ConfigurationManager::KeyServerClientAddressWhitelist);
if (!hasWhitelist) {
return false;
}
const auto whitelist = OsEng.configurationManager().value<std::string>(
ConfigurationManager::KeyServerClientAddressWhitelist);
return whitelist.find(_address) != std::string::npos;
const std::vector<std::string>& wl = OsEng.configuration().clientAddressWhitelist;
return std::find(wl.begin(), wl.end(), _address) != wl.end();
}
} // namespace openspace

View File

@@ -24,15 +24,18 @@
#include "include/authorizationtopic.h"
#include <openspace/engine/configuration.h>
namespace {
std::string _loggerCat = "AuthorizationTopic";
}
constexpr const char* _loggerCat = "AuthorizationTopic";
} // namespace
namespace openspace {
AuthorizationTopic::AuthorizationTopic()
: Topic()
, _isAuthenticated(false) {};
AuthorizationTopic::AuthorizationTopic()
: Topic()
, _isAuthenticated(false)
{};
bool AuthorizationTopic::isDone() {
return _isAuthenticated;
@@ -69,14 +72,7 @@ bool AuthorizationTopic::authorize(const std::string key) {
}
const std::string AuthorizationTopic::getKey() const {
bool hasConfigPassword = OsEng.configurationManager().hasKeyAndValue<std::string>(
ConfigurationManager::KeyServerPasskey);
if (hasConfigPassword) {
return OsEng.configurationManager().value<std::string>(
ConfigurationManager::KeyServerPasskey);
}
return "17308";
return OsEng.configuration().serverPasskey;
}
nlohmann::json AuthorizationTopic::message(const std::string& message,

View File

@@ -27,7 +27,6 @@
#include <modules/spacecraftinstruments/util/imagesequencer.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>

View File

@@ -30,7 +30,6 @@
#include <modules/sync/tasks/syncassettask.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/screenspacerenderable.h>

View File

@@ -2,135 +2,134 @@
-- require('scripts/configuration_helper.lua')
-- which defines helper functions useful to customize the configuration
return {
-- Determines which SGCT configuration file is loaded, that is, if there rendering
-- occurs in a single window, a fisheye projection, or a dome cluster system
-- Determines which SGCT configuration file is loaded, that is, if there rendering
-- occurs in a single window, a fisheye projection, or a dome cluster system
-- A regular 1280x720 window
SGCTConfig = sgct.config.single{},
-- A regular 1280x720 window
SGCTConfig = sgct.config.single{}
-- A regular 1920x1080 window
-- SGCTConfig = sgct.config.single{1920, 1080},
-- A regular 1920x1080 window
-- SGCTConfig = sgct.config.single{1920, 1080}
-- A windowed 1920x1080 fullscreen
-- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"},
-- A windowed 1920x1080 fullscreen
-- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"}
-- A 1k fisheye rendering
-- SGCTConfig = sgct.config.fisheye{1024, 1024},
-- A 1k fisheye rendering
-- SGCTConfig = sgct.config.fisheye{1024, 1024}
-- A 4k fisheye rendering in a 1024x1024 window
-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27},
-- A 4k fisheye rendering in a 1024x1024 window
-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27}
-- Streaming OpenSpace via Spout to OBS
-- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"},
-- Streaming OpenSpace via Spout to OBS
-- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"}
-- SGCTConfig = "${CONFIG}/spout_output.xml",
-- SGCTConfig = "${CONFIG}/spout_output.xml"
--SGCTConfig = "${CONFIG}/openvr_oculusRiftCv1.xml",
--SGCTConfig = "${CONFIG}/openvr_htcVive.xml",
--SGCTConfig = "${CONFIG}/openvr_oculusRiftCv1.xml"
--SGCTConfig = "${CONFIG}/openvr_htcVive.xml"
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
-- of all entities that will be visible during an instance of OpenSpace
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
-- of all entities that will be visible during an instance of OpenSpace
Asset = "default",
-- Asset = "default_full",
-- Asset = "newhorizons",
-- Asset = "rosetta",
-- Asset = "osirisrex",
-- Asset = "voyager",
Asset = "default"
-- Asset = "default_full"
-- Asset = "newhorizons"
-- Asset = "rosetta"
-- Asset = "osirisrex"
-- Asset = "voyager"
-- These scripts are executed after the initialization of each scene, thus making
-- it possible to have global overrides to default values or execute other scripts
-- regardless of the scene that is loaded
GlobalCustomizationScripts = {
"${SCRIPTS}/customization.lua"
-- These scripts are executed after the initialization of each scene, thus making
-- it possible to have global overrides to default values or execute other scripts
-- regardless of the scene that is loaded
GlobalCustomizationScripts = {
"${SCRIPTS}/customization.lua"
}
Paths = {
DATA = "${BASE}/data",
ASSETS = "${DATA}/assets",
FONTS = "${DATA}/fonts",
TASKS = "${DATA}/tasks",
SYNC = "${BASE}/sync",
SCREENSHOTS = "${BASE}/screenshots",
WEB = "${DATA}/web",
CACHE = "${BASE}/cache",
CONFIG = "${BASE}/config",
DOCUMENTATION = "${BASE}/documentation",
LOGS = "${BASE}/logs",
MODULES = "${BASE}/modules",
SCRIPTS = "${BASE}/scripts",
SHADERS = "${BASE}/shaders"
}
Fonts = {
Mono = "${FONTS}/Bitstream-Vera-Sans-Mono/VeraMono.ttf",
Light = "${FONTS}/Roboto/Roboto-Regular.ttf",
Console = "${FONTS}/Inconsolata/Inconsolata-Regular.ttf",
Loading = "${FONTS}/Roboto/Roboto-Regular.ttf"
}
Logging = {
LogDir = "${LOGS}",
-- LogLevel = "Trace",
LogLevel = "Debug",
ImmediateFlush = true,
Logs = {
{ Type = "html", File = "${LOGS}/log.html", Append = false }
},
CapabilitiesVerbosity = "Full"
}
ScriptLog = "${LOGS}/ScriptLog.txt"
Paths = {
DATA = "${BASE}/data",
ASSETS = "${DATA}/assets",
FONTS = "${DATA}/fonts",
TASKS = "${DATA}/tasks",
SYNC = "${BASE}/sync",
SCREENSHOTS = "${BASE}/screenshots",
WEB = "${DATA}/web",
CACHE = "${BASE}/cache",
CONFIG = "${BASE}/config",
DOCUMENTATION = "${BASE}/documentation",
LOGS = "${BASE}/logs",
MODULES = "${BASE}/modules",
SCRIPTS = "${BASE}/scripts",
SHADERS = "${BASE}/shaders"
},
Fonts = {
Mono = "${FONTS}/Bitstream-Vera-Sans-Mono/VeraMono.ttf",
Light = "${FONTS}/Roboto/Roboto-Regular.ttf",
Console = "${FONTS}/Inconsolata/Inconsolata-Regular.ttf",
Loading = "${FONTS}/Roboto/Roboto-Regular.ttf"
},
Logging = {
LogDir = "${LOGS}",
-- LogLevel = "Trace",
LogLevel = "Debug",
ImmediateFlush = true,
Logs = {
{ Type = "html", File = "${LOGS}/log.html", Append = false }
},
CapabilitiesVerbosity = "Full"
},
ScriptLog = "${LOGS}/ScriptLog.txt",
Launcher = {
LogLevel = "None"
},
Documentation = {
LuaDocumentation = "${DOCUMENTATION}/LuaScripting.html",
PropertyDocumentation = "${DOCUMENTATION}/Properties.html",
ScenePropertyDocumentation = "${DOCUMENTATION}/SceneProperties.html",
KeyboardShortcuts = "${DOCUMENTATION}/KeyboardMapping.html",
Documentation = "${DOCUMENTATION}/Documentation.html",
FactoryDocumentation = "${DOCUMENTATION}/FactoryDocumentation.html",
LicenseDocumentation = "${DOCUMENTATION}/License.html",
UseMultithreadedInitialization = true,
LoadingScreen = {
ShowMessage = true,
ShowNodeNames = true,
ShowProgressbar = true
},
CheckOpenGLState = false,
LogEachOpenGLCall = false,
ShutdownCountdown = 3,
ScreenshotUseDate = true,
-- OnScreenTextScaling = "framebuffer",
-- PerSceneCache = true,
-- DisableRenderingOnMaster = true,
-- DisableSceneOnMaster = true,
ModuleConfigurations = {
Sync = {
SynchronizationRoot = "${SYNC}",
HttpSynchronizationRepositories = {
"data.openspaceproject.com/request"
}
}
},
RenderingMethod = "Framebuffer",
OpenGLDebugContext = {
Activate = false,
FilterIdentifier = {
{ Type = "Other", Source = "API", Identifier = 131185 },
{ Type = "Performance", Source = "API", Identifier = 131186 }, --Buffer performance warning: "copied/moved from VIDEO memory to HOST memory"
{ Type = "Deprecated", Source = "API", Identifier = 7} -- API_ID_LINE_WIDTH deprecated behavior warning has been generated
},
-- FilterSeverity = { }
},
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer",
ServerPasskey = "secret!",
ClientAddressWhitelist = "127.0.0.1 localhost",
WebHelperLocation = "${BASE}/bin/Release/openspace_web_helper",
-- CefWebGuiUrl = "file://${BASE_PATH}/gui/index.html#/onscreen/"
CefWebGuiUrl = "http://localhost:8080/#/onscreen/"
}
UseMultithreadedInitialization = true
LoadingScreen = {
ShowMessage = true,
ShowNodeNames = true,
ShowProgressbar = true
}
CheckOpenGLState = false
LogEachOpenGLCall = false
ShutdownCountdown = 3
ScreenshotUseDate = true
-- OnScreenTextScaling = "framebuffer"
-- PerSceneCache = true
-- DisableRenderingOnMaster = true
-- DisableSceneOnMaster = true
ModuleConfigurations = {
Sync = {
SynchronizationRoot = "${SYNC}",
HttpSynchronizationRepositories = {
"data.openspaceproject.com/request"
}
}
}
RenderingMethod = "Framebuffer"
OpenGLDebugContext = {
Activate = false,
FilterIdentifier = {
{ Type = "Other", Source = "API", Identifier = 131185 },
{ Type = "Performance", Source = "API", Identifier = 131186 }, --Buffer performance warning: "copied/moved from VIDEO memory to HOST memory"
{ Type = "Deprecated", Source = "API", Identifier = 7} -- API_ID_LINE_WIDTH deprecated behavior warning has been generated
},
-- FilterSeverity = { }
}
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer"
ServerPasskey = "secret!"
ClientAddressWhitelist = {
"127.0.0.1",
"localhost"
}
WebHelperLocation = "${BASE}/bin/Release/openspace_web_helper"
-- CefWebGuiUrl = "file://${BASE_PATH}/gui/index.html#/onscreen/"
CefWebGuiUrl = "http://localhost:8080/#/onscreen/"

View File

@@ -31,8 +31,10 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/documentation/documentationengine.cpp
${OPENSPACE_BASE_DIR}/src/documentation/documentationgenerator.cpp
${OPENSPACE_BASE_DIR}/src/documentation/verifier.cpp
${OPENSPACE_BASE_DIR}/src/engine/configurationmanager.cpp
${OPENSPACE_BASE_DIR}/src/engine/configurationmanager_doc.inl
${OPENSPACE_BASE_DIR}/src/engine/configuration.cpp
${OPENSPACE_BASE_DIR}/src/engine/configuration_doc.inl
# ${OPENSPACE_BASE_DIR}/src/engine/configurationmanager.cpp
# ${OPENSPACE_BASE_DIR}/src/engine/configurationmanager_doc.inl
${OPENSPACE_BASE_DIR}/src/engine/downloadmanager.cpp
${OPENSPACE_BASE_DIR}/src/engine/logfactory.cpp
${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp
@@ -202,7 +204,7 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/documentation/documentationgenerator.h
${OPENSPACE_BASE_DIR}/include/openspace/documentation/verifier.h
${OPENSPACE_BASE_DIR}/include/openspace/documentation/verifier.inl
${OPENSPACE_BASE_DIR}/include/openspace/engine/configurationmanager.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/configuration.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

View File

@@ -25,7 +25,6 @@
#include <openspace/documentation/core_registration.h>
#include <openspace/documentation/documentationengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/logfactory.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/openspaceengine.h>
@@ -52,7 +51,6 @@
namespace openspace {
void registerCoreClasses(documentation::DocumentationEngine& engine) {
engine.addDocumentation(ConfigurationManager::Documentation());
engine.addDocumentation(LogFactoryDocumentation());
engine.addDocumentation(Mission::Documentation());
engine.addDocumentation(Renderable::Documentation());

View File

@@ -0,0 +1,350 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#include <openspace/engine/configuration.h>
#include <openspace/documentation/documentation.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/assert.h>
namespace {
constexpr const char* BasePathToken = "${BASE}";
// We can't use ${SCRIPTS} here as that hasn't been defined by this point
constexpr const char* InitialConfigHelper =
"${BASE}/scripts/configuration_helper.lua";
// Variable names for the openspace.cfg file
// These are also used in the _doc include file
constexpr const char* KeySGCTConfig = "SGCTConfig";
constexpr const char* KeyAsset = "Asset";
constexpr const char* KeyGlobalCustomizationScripts = "GlobalCustomizationScripts";
constexpr const char* KeyPaths = "Paths";
constexpr const char* KeyPathsCACHE = "Paths.CACHE";
constexpr const char* KeyFonts = "Fonts";
constexpr const char* KeyLogging = "Logging";
constexpr const char* KeyLogDir = "LogDir";
constexpr const char* KeyPerformancePrefix = "PerformancePrefix";
constexpr const char* KeyLogLevel = "LogLevel";
constexpr const char* KeyImmediateFlush = "ImmediateFlush";
constexpr const char* KeyLogs = "Logs";
constexpr const char* KeyCapabilitiesVerbosity = "CapabilitiesVerbosity";
constexpr const char* KeyLuaDocumentation = "LuaDocumentation";
constexpr const char* KeyPropertyDocumentation = "PropertyDocumentation";
constexpr const char* KeyScriptLog = "ScriptLog";
constexpr const char* KeyKeyboardShortcuts = "KeyboardShortcuts";
constexpr const char* KeyDocumentation = "Documentation";
constexpr const char* KeyFactoryDocumentation = "FactoryDocumentation";
constexpr const char* KeyRequireSocketAuthentication = "RequireSocketAuthentication";
constexpr const char* KeyServerPasskey = "ServerPasskey";
constexpr const char* KeyClientAddressWhitelist = "ClientAddressWhitelist";
constexpr const char* KeyLicenseDocumentation = "LicenseDocumentation";
constexpr const char* KeyShutdownCountdown = "ShutdownCountdown";
constexpr const char* KeyPerSceneCache = "PerSceneCache";
constexpr const char* KeyOnScreenTextScaling = "OnScreenTextScaling";
constexpr const char* KeyRenderingMethod = "RenderingMethod";
constexpr const char* KeyDisableRenderingOnMaster = "DisableRenderingOnMaster";
constexpr const char* KeyDisableSceneOnMaster = "DisableSceneOnMaster";
constexpr const char* KeyScreenshotUseDate = "ScreenshotUseDate";
constexpr const char* KeyHttpProxy = "HttpProxy";
constexpr const char* KeyAddress = "Address";
constexpr const char* KeyPort = "Port";
constexpr const char* KeyAuthentication = "Authentication";
constexpr const char* KeyUser = "User";
constexpr const char* KeyPassword = "Password";
constexpr const char* KeyOpenGLDebugContext = "OpenGLDebugContext";
constexpr const char* KeyActivate = "Activate";
constexpr const char* KeySynchronous = "Synchronous";
constexpr const char* KeyFilterIdentifier = "FilterIdentifier";
constexpr const char* KeyIdentifier = "Identifier";
constexpr const char* KeySource = "Source";
constexpr const char* KeyType = "Type";
constexpr const char* KeyFilterSeverity = "FilterSeverity";
constexpr const char* KeyCheckOpenGLState = "CheckOpenGLState";
constexpr const char* KeyLogEachOpenGLCall = "LogEachOpenGLCall";
constexpr const char* KeyUseMultithreadedInitialization =
"UseMultithreadedInitialization";
constexpr const char* KeyLoadingScreen = "LoadingScreen";
constexpr const char* KeyShowMessage = "ShowMessage";
constexpr const char* KeyShowNodeNames = "ShowNodeNames";
constexpr const char* KeyShowProgressbar = "ShowProgressbar";
constexpr const char* KeyModuleConfigurations = "ModuleConfigurations";
} // namespace
#include "configuration_doc.inl"
namespace openspace {
template <typename T>
void getValue(ghoul::lua::LuaState& L, const char* name, T& value) {
auto it = std::find_if(
Configuration::Documentation.entries.begin(),
Configuration::Documentation.entries.end(),
[name](const documentation::DocumentationEntry& e) {
return e.key == name;
}
);
bool isOptional =
it != Configuration::Documentation.entries.end()
? it->optional :
true;
lua_getglobal(L, name);
if (isOptional && lua_isnil(L, -1)) {
return;
}
if (!isOptional && lua_isnil(L, -1)) {
documentation::TestResult testResult = {
false,
{ { name, documentation::TestResult::Offense::Reason::MissingKey} },
{}
};
throw documentation::SpecificationError(std::move(testResult), "Configuration");
}
if constexpr (std::is_same_v<T, std::vector<std::string>>) {
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
std::vector<std::string> res;
for (size_t i = 1; i <= d.size(); ++i) {
res.push_back(d.value<std::string>(std::to_string(i)));
}
value = res;
}
else if constexpr (std::is_same_v<T, std::map<std::string, std::string>>) {
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
std::map<std::string, std::string> res;
for (size_t i = 0; i < d.size(); ++i) {
std::string key = d.keys()[i];
std::string v = d.value<std::string>(key);
res[std::move(key)] = std::move(v);
}
value = res;
}
else if constexpr (std::is_same_v<T, std::map<std::string, ghoul::Dictionary>>) {
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
std::map<std::string, ghoul::Dictionary> res;
for (size_t i = 0; i < d.size(); ++i) {
std::string key = d.keys()[i];
ghoul::Dictionary v = d.value<ghoul::Dictionary>(key);
res[std::move(key)] = std::move(v);
}
value = res;
}
else if constexpr (std::is_same_v<T, Configuration::Logging>) {
Configuration::Logging& v = static_cast<Configuration::Logging&>(value);
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
d.getValue(KeyLogLevel, v.level);
d.getValue(KeyLogDir, v.directory);
d.getValue(KeyPerformancePrefix, v.performancePrefix);
d.getValue(KeyImmediateFlush, v.forceImmediateFlush);
d.getValue(KeyCapabilitiesVerbosity, v.capabilitiesVerbosity);
if (d.hasKeyAndValue<ghoul::Dictionary>(KeyLogs)) {
ghoul::Dictionary l = d.value<ghoul::Dictionary>(KeyLogs);
std::vector<ghoul::Dictionary> res;
for (size_t i = 1; i <= l.size(); ++i) {
res.push_back(l.value<ghoul::Dictionary>(std::to_string(i)));
}
v.logs = res;
}
}
else if constexpr (std::is_same_v<T, Configuration::DocumentationInfo>) {
Configuration::DocumentationInfo& v =
static_cast<Configuration::DocumentationInfo&>(value);
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
d.getValue(KeyLuaDocumentation, v.lua);
d.getValue(KeyPropertyDocumentation, v.property);
d.getValue("ScenePropertyDocumentation", v.sceneProperty);
d.getValue(KeyKeyboardShortcuts, v.keyboard);
d.getValue(KeyDocumentation, v.documentation);
d.getValue(KeyFactoryDocumentation, v.factory);
d.getValue(KeyLicenseDocumentation, v.license);
}
else if constexpr (std::is_same_v<T, Configuration::LoadingScreen>) {
Configuration::LoadingScreen& v =
static_cast<Configuration::LoadingScreen&>(value);
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
d.getValue(KeyShowMessage, v.isShowingMessages);
d.getValue(KeyShowNodeNames, v.isShowingNodeNames);
d.getValue(KeyShowProgressbar, v.isShowingProgressbar);
}
else if constexpr (std::is_same_v<T, Configuration::OpenGLDebugContext>) {
Configuration::OpenGLDebugContext& v =
static_cast<Configuration::OpenGLDebugContext&>(value);
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
d.getValue(KeyActivate, v.isActive);
d.getValue(KeySynchronous, v.isSynchronous);
if (d.hasKeyAndValue<ghoul::Dictionary>(KeyFilterIdentifier)) {
ghoul::Dictionary f = d.value<ghoul::Dictionary>(KeyFilterIdentifier);
std::vector<Configuration::OpenGLDebugContext::IdentifierFilter> res;
for (size_t i = 1; i <= f.size(); ++i) {
Configuration::OpenGLDebugContext::IdentifierFilter filter;
ghoul::Dictionary fi = f.value<ghoul::Dictionary>(std::to_string(i));
double id = static_cast<double>(filter.identifier);
fi.getValue(KeyIdentifier, id);
filter.identifier = static_cast<unsigned int>(id);
fi.getValue(KeySource, filter.source);
fi.getValue(KeyType, filter.type);
res.push_back(filter);
}
v.identifierFilters = res;
}
if (d.hasKeyAndValue<ghoul::Dictionary>(KeyFilterSeverity)) {
ghoul::Dictionary f = d.value<ghoul::Dictionary>(KeyFilterSeverity);
std::vector<std::string> res;
for (size_t i = 1; i <= f.size(); ++i) {
res.push_back(f.value<std::string>(std::to_string(i)));
}
v.severityFilters = res;
}
}
else if constexpr (std::is_same_v<T, Configuration::HTTPProxy>) {
Configuration::HTTPProxy& v = static_cast<Configuration::HTTPProxy&>(value);
ghoul::Dictionary d = ghoul::lua::value<ghoul::Dictionary>(L);
d.getValue(KeyActivate, v.usingHttpProxy);
d.getValue(KeyAddress, v.address);
double p = static_cast<double>(v.port);
d.getValue(KeyPort, p);
v.port = static_cast<unsigned int>(p);
d.getValue(KeyAuthentication, v.authentication);
d.getValue(KeyUser, v.user);
d.getValue(KeyPassword, v.password);
}
else {
value = ghoul::lua::value<T>(L);
}
}
void parseLuaState(Configuration& configuration) {
using namespace ghoul::lua;
// Shorten the rest of this function
Configuration& c = configuration;
LuaState& s = c.state;
getValue(s, KeySGCTConfig, c.windowConfiguration);
getValue(s, KeyAsset, c.asset);
getValue(s, KeyGlobalCustomizationScripts, c.globalCustomizationScripts);
getValue(s, KeyPaths, c.pathTokens);
getValue(s, KeyFonts, c.fonts);
getValue(s, KeyScriptLog, c.scriptLog);
getValue(s, KeyUseMultithreadedInitialization, c.useMultithreadedInitialization);
getValue(s, KeyCheckOpenGLState, c.isCheckingOpenGLState);
getValue(s, KeyLogEachOpenGLCall, c.isLoggingOpenGLCalls);
getValue(s, KeyShutdownCountdown, c.shutdownCountdown);
getValue(s, KeyScreenshotUseDate, c.shouldUseScreenshotDate);
getValue(s, KeyOnScreenTextScaling, c.onScreenTextScaling);
getValue(s, KeyPerSceneCache, c.usePerSceneCache);
getValue(s, KeyDisableRenderingOnMaster, c.isRenderingOnMasterDisabled);
getValue(s, KeyDisableSceneOnMaster, c.isSceneTranslationOnMasterDisabled);
getValue(s, KeyRenderingMethod, c.renderingMethod);
getValue(s, KeyServerPasskey, c.serverPasskey);
getValue(s, KeyRequireSocketAuthentication, c.doesRequireSocketAuthentication);
getValue(s, KeyClientAddressWhitelist, c.clientAddressWhitelist);
getValue(s, "WebHelperLocation", c.webHelperLocation);
getValue(s, "CefWebGuiUrl", c.cefWebGuiUrl);
getValue(s, KeyLogging, c.logging);
getValue(s, KeyDocumentation, c.documentation);
getValue(s, KeyLoadingScreen, c.loadingScreen);
getValue(s, KeyModuleConfigurations, c.moduleConfigurations);
getValue(s, KeyOpenGLDebugContext, c.openGLDebugContext);
getValue(s, KeyHttpProxy, c.httpProxy);
}
std::string findConfiguration(const std::string& filename) {
using ghoul::filesystem::Directory;
Directory directory = FileSys.currentDirectory();
while (true) {
std::string fullPath = FileSys.pathByAppendingComponent(
directory,
filename
);
if (FileSys.fileExists(fullPath)) {
// We have found the configuration file and can bail out
return fullPath;
}
// Otherwise, we traverse the directory tree up
Directory nextDirectory = directory.parentDirectory(
ghoul::filesystem::Directory::AbsolutePath::Yes
);
if (directory.path() == nextDirectory.path()) {
// We have reached the root of the file system and did not find the file
throw ghoul::RuntimeError(
"Could not find configuration file '" + filename + "'",
"ConfigurationManager"
);
}
directory = nextDirectory;
}
}
Configuration loadConfigurationFromFile(const std::string& filename) {
ghoul_assert(!filename.empty(), "Filename must not be empty");
ghoul_assert(FileSys.fileExists(filename), "File must exist");
Configuration result;
// Register the base path as the directory where 'filename' lives
std::string basePath = ghoul::filesystem::File(filename).directoryName();
FileSys.registerPathToken(BasePathToken, basePath);
// If there is an initial config helper file, load it into the state
if (FileSys.fileExists(absPath(InitialConfigHelper))) {
ghoul::lua::runScriptFile(result.state, absPath(InitialConfigHelper));
}
// Load the configuration file into the state
ghoul::lua::runScriptFile(result.state, filename);
parseLuaState(result);
return result;
}
} // namespace openspace

View File

@@ -27,22 +27,20 @@
namespace openspace {
documentation::Documentation ConfigurationManager::Documentation() {
using namespace documentation;
return {
"OpenSpace Configuration",
"openspace_configuraion",
using namespace documentation;
documentation::Documentation Configuration::Documentation = {
"OpenSpace Configuration",
"openspace_configuraion",
{
{
{
ConfigurationManager::KeyConfigSgct,
KeySGCTConfig,
new StringAnnotationVerifier("A valid SGCT configuration file"),
Optional::No,
"The SGCT configuration file that determines the window and view frustum "
"settings that are being used when OpenSpace is started."
},
{
ConfigurationManager::KeyConfigAsset,
KeyAsset,
new StringAnnotationVerifier(
"A valid scene file as described in the Scene documentation"
),
@@ -53,7 +51,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"the Scene documentation."
},
{
ConfigurationManager::KeyGlobalCustomizationScripts,
KeyGlobalCustomizationScripts,
new StringListVerifier,
Optional::Yes,
"This value names a list of scripts that get executed after initialization "
@@ -61,7 +59,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"such as a global rebinding of keys from the default."
},
{
ConfigurationManager::KeyPaths,
KeyPaths,
new StringListVerifier,
Optional::No,
"A list of paths that are automatically registered with the file system. "
@@ -69,14 +67,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"in all other configuration files or scripts."
},
{
ConfigurationManager::KeyCachePath,
new StringVerifier,
Optional::No,
"The path to be used as a cache folder. If per scene caching is enabled, the "
"name of the scene will be appended to this folder"
},
{
ConfigurationManager::KeyFonts,
KeyFonts,
new StringListVerifier("Font paths loadable by FreeType"),
Optional::Yes,
"A list of all fonts that will automatically be loaded on startup. Each "
@@ -84,23 +75,23 @@ documentation::Documentation ConfigurationManager::Documentation() {
"for a font."
},
{
ConfigurationManager::KeyLogging,
KeyLogging,
new TableVerifier({
{
ConfigurationManager::PartLogDir,
KeyLogDir,
new StringVerifier,
Optional::Yes,
"The directory for logs. Default value is \"${BASE}\""
},
{
ConfigurationManager::PartLogPerformancePrefix,
KeyPerformancePrefix,
new StringVerifier,
Optional::Yes,
"A string to prefix PerformanceMeasurement logfiles."
"Default value is \"PM-\""
},
{
ConfigurationManager::PartLogLevel,
KeyLogLevel,
new StringInListVerifier(
// List from logmanager.cpp::levelFromString
{ "Trace", "Debug", "Info", "Warning", "Error", "Fatal", "None" }
@@ -112,7 +103,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"severities is: Debug < Info < Warning < Error < Fatal < None."
},
{
ConfigurationManager::PartImmediateFlush,
KeyImmediateFlush,
new BoolVerifier,
Optional::Yes,
"Determines whether error messages will be displayed immediately "
@@ -122,7 +113,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"logged."
},
{
ConfigurationManager::PartLogs,
KeyLogs,
new TableVerifier({
{
"*",
@@ -138,7 +129,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"be used additionally."
},
{
ConfigurationManager::PartCapabilitiesVerbosity,
KeyCapabilitiesVerbosity,
new StringInListVerifier(
// List from OpenspaceEngine::initialize
{ "None", "Minimal", "Default", "Full" }
@@ -154,22 +145,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"other information."
},
{
ConfigurationManager::KeyLuaDocumentation,
new StringVerifier,
Optional::Yes,
"The filename that will be created on startup containing the documentation "
"of available Lua functions that can be executed in scene files or per "
"console. Any existing file will be silently overwritten."
},
{
ConfigurationManager::KeyPropertyDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing a list of all "
"properties in the scene. Any existing file will be silently overwritten."
},
{
ConfigurationManager::KeyScriptLog,
KeyScriptLog,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the log of all Lua "
@@ -177,78 +153,84 @@ documentation::Documentation ConfigurationManager::Documentation() {
"the results from previous runs) will be silently overwritten."
},
{
ConfigurationManager::KeyKeyboardShortcuts,
new StringVerifier,
KeyDocumentation,
new TableVerifier({
{
KeyLuaDocumentation,
new StringVerifier,
Optional::Yes,
"The filename that will be created on startup containing the "
"documentation of available Lua functions that can be executed in "
"scene files or per console. Any existing file will be silently "
"overwritten."
},
{
KeyPropertyDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing a list of all "
"properties in the scene. Any existing file will be silently "
"overwritten."
},
{
KeyKeyboardShortcuts,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the list of all "
"keyboard bindings with their respective Lua scripts. For each key, "
"it mentions which scripts will be executed in the current session."
},
{
KeyDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing this "
"documentation. Any previous file in this location will be silently "
"overwritten."
},
{
KeyFactoryDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the factory "
"documentation which shows the different types of objects that can "
"be created in the current application configuration. Any previous "
"file in this location will be silently overritten."
},
{
KeyLicenseDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the scene "
"license information. Any previous file in this location will be "
"silently overwritten."
},
}),
Optional::Yes,
"The file that will be created on startup containing the list of all "
"keyboard bindings with their respective Lua scripts. For each key, it "
"mentions which scripts will be executed in the current session."
"All documentations that are generated at application startup."
},
{
ConfigurationManager::KeyDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing this documentation. Any "
"previous file in this location will be silently overwritten."
},
{
ConfigurationManager::KeyFactoryDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the factory "
"documentation which shows the different types of objects that can be "
"created in the current application configuration. Any previous file in this "
"location will be silently overritten."
},
{
ConfigurationManager::KeyRequireSocketAuthentication,
KeyRequireSocketAuthentication,
new BoolVerifier,
Optional::Yes,
"If socket connections should be authenticated or not before they are "
"allowed to get or set information. Defaults to 'true'."
},
{
ConfigurationManager::KeyServerPasskey,
KeyServerPasskey,
new StringVerifier,
Optional::Yes,
"Passkey to limit server access. Used to authorize incoming connections."
},
{
ConfigurationManager::KeyServerClientAddressWhitelist,
new StringVerifier,
KeyClientAddressWhitelist,
new StringListVerifier,
Optional::Yes,
"String containing white listed client IP addresses that won't need to be "
"String containing white listed client IP addresses that won't need to be"
"authorized with the server. Space separated"
},
{
ConfigurationManager::KeySceneLicenseDocumentation,
new StringVerifier,
Optional::Yes,
"The file that will be created on startup containing the scene license "
"information. Any previous file in this location will be silently "
"overwritten."
},
{
ConfigurationManager::KeyLauncher,
new TableVerifier({
{
ConfigurationManager::PartLogLevel,
new StringInListVerifier(
// List from logmanager.cpp::levelFromString
{ "Trace", "Debug", "Info", "Warning", "Error", "Fatal", "None" }
),
Optional::Yes,
"The severity of log messages that will be displayed. Only "
"messages of the selected level or higher will be displayed. All "
"levels below will be silently discarded. The order of "
"severities is: Debug < Info < Warning < Error < Fatal < None."
},
}),
Optional::Yes,
"Configurations for the Launcher & syncing application."
},
{
ConfigurationManager::KeyShutdownCountdown,
KeyShutdownCountdown,
new DoubleGreaterEqualVerifier(0.0),
Optional::Yes,
"The countdown that the application will wait between pressing ESC and "
@@ -256,7 +238,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"shutdown is aborted."
},
{
ConfigurationManager::KeyPerSceneCache,
KeyPerSceneCache,
new BoolVerifier,
Optional::Yes,
"If this is set to 'true', the name of the scene will be appended to the "
@@ -265,7 +247,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"the caches should be retained. This value defaults to 'false'."
},
{
ConfigurationManager::KeyOnScreenTextScaling,
KeyOnScreenTextScaling,
new StringInListVerifier({
// Values from RenderEngine:updateRenderer
"window", "framebuffer"
@@ -277,7 +259,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"rendering resolution ('framebuffer'). This value defaults to 'window'."
},
{
ConfigurationManager::KeyRenderingMethod,
KeyRenderingMethod,
new StringInListVerifier(
// List from RenderEngine::setRendererFromString
{ "Framebuffer", "ABuffer" }
@@ -287,7 +269,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"support for at least OpenGL 4.3"
},
{
ConfigurationManager::KeyDisableMasterRendering,
KeyDisableRenderingOnMaster,
new BoolVerifier,
Optional::Yes,
"Toggles whether the master in a multi-application setup should be rendering "
@@ -295,7 +277,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"the master computer does not have the resources to render a scene."
},
{
ConfigurationManager::KeyDisableSceneOnMaster,
KeyDisableSceneOnMaster,
new BoolVerifier,
Optional::Yes,
"Toggles whether a potential scene transformation matrix, for example as "
@@ -305,7 +287,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"default is false."
},
{
ConfigurationManager::KeyScreenshotUseDate,
KeyScreenshotUseDate,
new BoolVerifier,
Optional::Yes,
"Toggles whether screenshots generated by OpenSpace contain the date when "
@@ -314,22 +296,28 @@ documentation::Documentation ConfigurationManager::Documentation() {
"individual frames pass beyond local midnight."
},
{
ConfigurationManager::KeyHttpProxy,
KeyHttpProxy,
new TableVerifier({
{
ConfigurationManager::PartHttpProxyAddress,
KeyActivate,
new BoolVerifier,
Optional::Yes,
"Determines whether the proxy is being used"
},
{
KeyAddress,
new StringVerifier,
Optional::No,
"The address of the http proxy"
},
{
ConfigurationManager::PartHttpProxyPort,
new StringVerifier,
KeyPort,
new IntVerifier,
Optional::No,
"The port of the http proxy"
},
{
ConfigurationManager::PartHttpProxyAuthentication,
KeyAuthentication,
new StringInListVerifier(
{ "basic", "ntlm", "digest", "any" }
),
@@ -337,13 +325,13 @@ documentation::Documentation ConfigurationManager::Documentation() {
"The authentication method of the http proxy"
},
{
ConfigurationManager::PartHttpProxyUser,
KeyUser,
new StringVerifier,
Optional::Yes,
"The user of the http proxy"
},
{
ConfigurationManager::PartHttpProxyPassword,
KeyPassword,
new StringVerifier,
Optional::Yes,
"The password of the http proxy"
@@ -354,16 +342,16 @@ documentation::Documentation ConfigurationManager::Documentation() {
"No proxy will be used if this is left out."
},
{
ConfigurationManager::KeyOpenGLDebugContext,
KeyOpenGLDebugContext,
new TableVerifier({
{
ConfigurationManager::PartActivate,
KeyActivate,
new BoolVerifier,
Optional::No,
"Determines whether the OpenGL context should be a debug context"
},
{
ConfigurationManager::PartSynchronous,
KeySynchronous,
new BoolVerifier,
Optional::Yes,
"Determines whether the OpenGL debug callbacks are performed "
@@ -372,18 +360,18 @@ documentation::Documentation ConfigurationManager::Documentation() {
"triggered the message. The default value is <True>."
},
{
ConfigurationManager::PartFilterIdentifier,
KeyFilterIdentifier,
new TableVerifier({{
"*",
new TableVerifier({
{
ConfigurationManager::PartFilterIdentifierIdentifier,
KeyIdentifier,
new IntVerifier,
Optional::No,
"The identifier that is to be filtered"
},
{
ConfigurationManager::PartFilterIdentifierSource,
KeySource,
new StringInListVerifier({
// Taken from ghoul::debugcontext.cpp
"API", "Window System", "Shader Compiler",
@@ -393,7 +381,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"The source of the identifier to be filtered"
},
{
ConfigurationManager::PartFilterIdentifierType,
KeyType,
new StringInListVerifier({
// Taken from ghoul::debugcontext.cpp
"Error", "Deprecated", "Undefined", "Portability",
@@ -411,7 +399,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"A list of OpenGL debug messages identifiers that are filtered"
},
{
ConfigurationManager::PartFilterSeverity,
KeyFilterSeverity,
new TableVerifier({
{
"*",
@@ -430,7 +418,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"Determines the settings for the creation of an OpenGL debug context.",
},
{
ConfigurationManager::KeyCheckOpenGLState,
KeyCheckOpenGLState,
new BoolVerifier,
Optional::Yes,
"Determines whether the OpenGL state is checked after each OpenGL function "
@@ -438,7 +426,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"OpenGL errors easier. This defaults to 'false'."
},
{
ConfigurationManager::KeyLogEachOpenGLCall,
KeyLogEachOpenGLCall,
new BoolVerifier,
Optional::Yes,
"Determines whether each OpenGL call that happens should be logged using the "
@@ -447,7 +435,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"defaults to 'false'."
},
{
ConfigurationManager::KeyUseMultithreadedInitialization,
KeyUseMultithreadedInitialization,
new BoolVerifier,
Optional::Yes,
"This value determines whether the initialization of the scene graph should "
@@ -456,17 +444,17 @@ documentation::Documentation ConfigurationManager::Documentation() {
"debugging support."
},
{
ConfigurationManager::KeyLoadingScreen,
KeyLoadingScreen,
new TableVerifier({
{
ConfigurationManager::PartShowMessage,
KeyShowMessage,
new BoolVerifier,
Optional::Yes,
"If this value is set to 'true', the loading screen will display a "
"message information about the current phase the loading is in."
},
{
ConfigurationManager::PartShowNodeNames,
KeyShowNodeNames,
new BoolVerifier,
Optional::Yes,
"If this value is set to 'true', the loading screen will display a "
@@ -474,7 +462,7 @@ documentation::Documentation ConfigurationManager::Documentation() {
"loaded, initialized)."
},
{
ConfigurationManager::PartShowProgressbar,
KeyShowProgressbar,
new BoolVerifier,
Optional::Yes,
"If this value is set to 'true', the loading screen will contain a "
@@ -486,14 +474,12 @@ documentation::Documentation ConfigurationManager::Documentation() {
"displayed while the scene graph is created and initialized."
},
{
ConfigurationManager::KeyModuleConfigurations,
KeyModuleConfigurations,
new TableVerifier,
Optional::Yes,
"Configurations for each module"
}
}
};
}
}
};
} // namespace openspace

View File

@@ -1,144 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#include <openspace/engine/configurationmanager.h>
#include <openspace/documentation/documentation.h>
#include <ghoul/fmt.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/lua/luastate.h>
#include <ghoul/misc/exception.h>
using std::string;
#include "configurationmanager_doc.inl"
namespace {
const char* _configurationFile = "openspace.cfg";
const char* _keyBasePath = "BASE";
// We can't use ${SCRIPTS} here as that hasn't been defined by this point
const char* _initialConfigHelper = "${BASE}/scripts/configuration_helper.lua";
} // namespace
namespace openspace {
string ConfigurationManager::findConfiguration(const string& filename) {
using ghoul::filesystem::Directory;
Directory directory = FileSys.currentDirectory();
while (true) {
std::string fullPath = FileSys.pathByAppendingComponent(
directory,
_configurationFile
);
if (FileSys.fileExists(fullPath)) {
// We have found the configuration file and can bail out
return fullPath;
}
// Otherwise, we traverse the directory tree up
Directory nextDirectory = directory.parentDirectory(
ghoul::filesystem::Directory::AbsolutePath::Yes
);
if (directory.path() == nextDirectory.path()) {
// We have reached the root of the file system and did not find the file
throw ghoul::RuntimeError(
"Could not find configuration file '" + filename + "'",
"ConfigurationManager"
);
}
directory = nextDirectory;
}
}
void ConfigurationManager::loadFromFile(const string& filename) {
using ghoul::filesystem::FileSystem;
ghoul_assert(!filename.empty(), "Filename must not be empty");
ghoul_assert(FileSys.fileExists(filename), "File must exist");
// ${BASE}
string basePathToken = FileSystem::TokenOpeningBraces + string(_keyBasePath) +
FileSystem::TokenClosingBraces;
// Retrieving the directory in which the configuration file lies
string basePath = ghoul::filesystem::File(filename).directoryName();
FileSys.registerPathToken(basePathToken, basePath);
ghoul::lua::LuaState state;
if (FileSys.fileExists(absPath(_initialConfigHelper))) {
ghoul::lua::runScriptFile(state, absPath(_initialConfigHelper));
}
// Loading the configuration file into ourselves
ghoul::lua::loadDictionaryFromFile(filename, *this, state);
// Perform testing against the documentation/specification
openspace::documentation::testSpecificationAndThrow(
ConfigurationManager::Documentation(),
*this,
"ConfigurationManager"
);
// Register all the paths
ghoul::Dictionary dictionary = value<ghoul::Dictionary>(KeyPaths);
for (std::string key : dictionary.keys()) {
std::string p = dictionary.value<std::string>(key);
std::string fullKey =
FileSystem::TokenOpeningBraces + key + FileSystem::TokenClosingBraces;
LDEBUGC("ConfigurationManager",
fmt::format("Registering path {}: {}", fullKey, p)
);
bool override = (basePathToken == fullKey);
if (override) {
LINFOC(
"ConfigurationManager",
fmt::format("Overriding base path with '{}'", p)
);
}
using Override = ghoul::filesystem::FileSystem::Override;
FileSys.registerPathToken(
std::move(fullKey),
std::move(p),
override ? Override::Yes : Override::No
);
}
// 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);
}
} // namespace openspace

View File

@@ -46,12 +46,15 @@ ModuleEngine::ModuleEngine()
: properties::PropertyOwner({"Modules"})
{}
void ModuleEngine::initialize(const ghoul::Dictionary& moduleConfigurations) {
void ModuleEngine::initialize(
const std::map<std::string, ghoul::Dictionary>& moduleConfigurations)
{
for (OpenSpaceModule* m : AllModules()) {
const std::string identifier = m->identifier();
auto it = moduleConfigurations.find(identifier);
ghoul::Dictionary configuration;
if (moduleConfigurations.hasKey(identifier)) {
moduleConfigurations.getValue(identifier, configuration);
if (it != moduleConfigurations.end()) {
configuration = it->second;
}
registerModule(std::unique_ptr<OpenSpaceModule>(m), configuration);
}

View File

@@ -28,7 +28,7 @@
#include <openspace/documentation/core_registration.h>
#include <openspace/documentation/documentationengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/downloadmanager.h>
#include <openspace/engine/logfactory.h>
#include <openspace/engine/moduleengine.h>
@@ -111,7 +111,6 @@ using namespace ghoul::cmdparser;
namespace {
constexpr const char* _loggerCat = "OpenSpaceEngine";
constexpr const char* SgctDefaultConfigFile = "${CONFIG}/single.xml";
constexpr const char* SgctConfigArgumentCommand = "-config";
@@ -150,7 +149,7 @@ OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr;
OpenSpaceEngine::OpenSpaceEngine(std::string programName,
std::unique_ptr<WindowWrapper> windowWrapper)
: _configurationManager(new ConfigurationManager)
: _configuration(new Configuration)
, _scene(nullptr)
, _dashboard(new Dashboard)
, _downloadManager(nullptr)
@@ -309,8 +308,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName;
if (configurationFilePath.empty()) {
LDEBUG("Finding configuration");
configurationFilePath =
ConfigurationManager::findConfiguration(configurationFilePath);
configurationFilePath = findConfiguration();
}
configurationFilePath = absPath(configurationFilePath);
@@ -324,7 +322,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
// Loading configuration from disk
LDEBUG("Loading configuration from disk");
try {
_engine->configurationManager().loadFromFile(configurationFilePath);
*_engine->_configuration = loadConfigurationFromFile(configurationFilePath);
}
catch (const documentation::SpecificationError& e) {
LFATAL(fmt::format(
@@ -346,19 +344,45 @@ void OpenSpaceEngine::create(int argc, char** argv,
throw;
}
// Registering Path tokens. If the BASE path is set, it is the only one that will
// overwrite the default path of the cfg directory
for (const std::pair<std::string, std::string>& path :
_engine->_configuration->pathTokens)
{
std::string fullKey =
FileSystem::TokenOpeningBraces + path.first + FileSystem::TokenClosingBraces;
LDEBUGC(
"ConfigurationManager",
fmt::format("Registering path {}: {}", fullKey, path.second)
);
bool override = (fullKey == "${BASE}");
if (override) {
LINFOC(
"ConfigurationManager",
fmt::format("Overriding base path with '{}'", path.second)
);
}
using Override = ghoul::filesystem::FileSystem::Override;
FileSys.registerPathToken(
std::move(fullKey),
std::move(path.second),
override ? Override::Yes : Override::No
);
}
const bool hasCacheCommandline = !commandlineArgumentPlaceholders.cacheFolder.empty();
const bool hasCacheConfig = _engine->configurationManager().hasKeyAndValue<bool>(
ConfigurationManager::KeyPerSceneCache
);
const bool hasCacheConfig = _engine->_configuration->usePerSceneCache;
std::string cacheFolder = absPath("${CACHE}");
if (hasCacheCommandline || hasCacheConfig) {
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
}
if (hasCacheConfig) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigAsset
);
std::string scene = _engine->_configuration->asset;
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
@@ -385,18 +409,8 @@ void OpenSpaceEngine::create(int argc, char** argv,
LINFOC("OpenSpace Version", std::string(OPENSPACE_VERSION_STRING_FULL));
LINFOC("Commit", std::string(OPENSPACE_GIT_FULL));
ghoul::Dictionary moduleConfigurations;
if (_engine->configurationManager().hasKeyAndValue<ghoul::Dictionary>(
ConfigurationManager::KeyModuleConfigurations))
{
_engine->configurationManager().getValue<ghoul::Dictionary>(
ConfigurationManager::KeyModuleConfigurations,
moduleConfigurations
);
}
// Register modules
_engine->_moduleEngine->initialize(moduleConfigurations);
_engine->_moduleEngine->initialize(_engine->_configuration->moduleConfigurations);
// After registering the modules, the documentations for the available classes
// can be added as well
@@ -406,6 +420,8 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
}
DocEng.addDocumentation(Configuration::Documentation);
// Create the cachemanager
try {
FileSys.createCacheManager(cacheFolder, CacheVersion);
@@ -420,10 +436,8 @@ void OpenSpaceEngine::create(int argc, char** argv,
// Determining SGCT configuration file
LDEBUG("Determining SGCT configuration file");
std::string sgctConfigurationPath = SgctDefaultConfigFile;
_engine->configurationManager().getValue(
ConfigurationManager::KeyConfigSgct, sgctConfigurationPath);
std::string sgctConfigurationPath = _engine->_configuration->windowConfiguration;
if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) {
LDEBUG(fmt::format(
"Overwriting SGCT configuration file with commandline argument: {}",
@@ -509,27 +523,24 @@ void OpenSpaceEngine::initialize() {
LDEBUG("Detecting capabilities");
SysCap.detectCapabilities();
using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity;
Verbosity verbosity = Verbosity::Default;
if (configurationManager().hasKey(ConfigurationManager::KeyCapabilitiesVerbosity)) {
static const std::map<std::string, Verbosity> VerbosityMap = {
{ "None", Verbosity::None },
{ "Minimal", Verbosity::Minimal },
{ "Default", Verbosity::Default },
{ "Full", Verbosity::Full }
};
std::string v = configurationManager().value<std::string>(
ConfigurationManager::KeyCapabilitiesVerbosity
);
ghoul_assert(
VerbosityMap.find(v) != VerbosityMap.end(),
"Missing check for syscaps verbosity in openspace.cfg documentation"
);
verbosity = VerbosityMap.find(v)->second;
}
using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity;
static const std::map<std::string, Verbosity> VerbosityMap = {
{ "None", Verbosity::None },
{ "Minimal", Verbosity::Minimal },
{ "Default", Verbosity::Default },
{ "Full", Verbosity::Full }
};
std::string v = _engine->_configuration->logging.capabilitiesVerbosity;
ghoul_assert(
VerbosityMap.find(v) != VerbosityMap.end(),
"Missing check for syscaps verbosity in openspace.cfg documentation"
);
Verbosity verbosity = VerbosityMap.find(v)->second;
SysCap.logCapabilities(verbosity);
// Check the required OpenGL versions of the registered modules
ghoul::systemcapabilities::Version version =
_engine->_moduleEngine->requiredOpenGLVersion();
@@ -563,18 +574,11 @@ void OpenSpaceEngine::initialize() {
scriptEngine().initialize();
writeStaticDocumentation();
if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) {
_shutdown.waitTime = static_cast<float>(configurationManager().value<double>(
ConfigurationManager::KeyShutdownCountdown
));
}
_shutdown.waitTime = _engine->_configuration->shutdownCountdown;
if (!commandlineArgumentPlaceholders.sceneName.empty()) {
configurationManager().setValue(
ConfigurationManager::KeyConfigAsset,
commandlineArgumentPlaceholders.sceneName
);
_engine->_configuration->asset = commandlineArgumentPlaceholders.sceneName;
}
// Initialize the NavigationHandler
@@ -592,8 +596,7 @@ void OpenSpaceEngine::initialize() {
func();
}
std::string assetPath = "";
configurationManager().getValue(ConfigurationManager::KeyConfigAsset, assetPath);
std::string assetPath = _engine->_configuration->asset;
_engine->_assetManager->initialize();
scheduleLoadSingleAsset(assetPath);
@@ -606,26 +609,10 @@ void OpenSpaceEngine::scheduleLoadSingleAsset(std::string assetPath) {
}
std::unique_ptr<LoadingScreen> OpenSpaceEngine::createLoadingScreen() {
bool showMessage = true;
constexpr const char* kMessage = ConfigurationManager::KeyLoadingScreenShowMessage;
if (configurationManager().hasKey(kMessage)) {
showMessage = configurationManager().value<bool>(kMessage);
}
bool showMessage = _configuration->loadingScreen.isShowingMessages;
bool showNodeNames = _configuration->loadingScreen.isShowingNodeNames;
bool showProgressbar = _configuration->loadingScreen.isShowingProgressbar;
bool showNodeNames = true;
constexpr const char* kNames = ConfigurationManager::KeyLoadingScreenShowNodeNames;
if (configurationManager().hasKey(kNames)) {
showNodeNames = configurationManager().value<bool>(kNames);
}
bool showProgressbar = true;
constexpr const char* kProgress =
ConfigurationManager::KeyLoadingScreenShowProgressbar;
if (configurationManager().hasKey(kProgress)) {
showProgressbar = configurationManager().value<bool>(kProgress);
}
return std::make_unique<LoadingScreen>(
LoadingScreen::ShowMessage(showMessage),
LoadingScreen::ShowNodeNames(showNodeNames),
@@ -656,12 +643,8 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
_rootPropertyOwner->removePropertySubOwner(_scene.get());
}
bool multiThreadedInitialization = configurationManager().hasKeyAndValue<bool>(
ConfigurationManager::KeyUseMultithreadedInitialization
) && configurationManager().value<bool>(
ConfigurationManager::KeyUseMultithreadedInitialization
);
bool multiThreadedInitialization = _configuration->useMultithreadedInitialization;
std::unique_ptr<SceneInitializer> sceneInitializer;
if (multiThreadedInitialization) {
unsigned int nAvailableThreads = std::thread::hardware_concurrency();
@@ -796,29 +779,18 @@ void OpenSpaceEngine::deinitialize() {
void OpenSpaceEngine::writeStaticDocumentation() {
// If a LuaDocumentationFile was specified, generate it now
if (configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentation)) {
_scriptEngine->writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyLuaDocumentation
))
);
if (!_configuration->documentation.lua.empty()) {
_scriptEngine->writeDocumentation(absPath(_configuration->documentation.lua));
}
// If a general documentation was specified, generate it now
if (configurationManager().hasKey(ConfigurationManager::KeyDocumentation)) {
DocEng.writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyDocumentation
))
);
if (!_configuration->documentation.documentation.empty()) {
DocEng.writeDocumentation(absPath(_configuration->documentation.documentation));
}
// If a factory documentation was specified, generate it now
if (configurationManager().hasKey(ConfigurationManager::KeyFactoryDocumentation)) {
if (!_configuration->documentation.factory.empty()) {
FactoryManager::ref().writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyFactoryDocumentation
))
absPath(_configuration->documentation.factory)
);
}
}
@@ -857,49 +829,44 @@ void OpenSpaceEngine::runGlobalCustomizationScripts() {
ghoul::lua::LuaState state;
OsEng.scriptEngine().initializeLuaState(state);
std::string k = ConfigurationManager::KeyGlobalCustomizationScripts;
if (_configurationManager->hasKey(k)) {
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(k);
for (int i = 1; i <= static_cast<int>(dict.size()); ++i) {
std::string script = absPath(dict.value<std::string>(std::to_string(i)));
if (FileSys.fileExists(script)) {
try {
LINFO(fmt::format("Running global customization script: {}", script));
ghoul::lua::runScriptFile(state, script);
} catch (ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
else {
LDEBUG(fmt::format("Ignoring non-existing script file: {}", script));
for (const std::string& script : _configuration->globalCustomizationScripts) {
std::string s = absPath(script);
if (FileSys.fileExists(s)) {
try {
LINFO(fmt::format("Running global customization script: {}", s));
ghoul::lua::runScriptFile(state, s);
} catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
else {
LDEBUG(fmt::format("Ignoring non-existing script file: {}", s));
}
}
}
void OpenSpaceEngine::loadFonts() {
ghoul::Dictionary fonts;
configurationManager().getValue(ConfigurationManager::KeyFonts, fonts);
_fontManager = std::make_unique<ghoul::fontrendering::FontManager>(FontAtlasSize);
for (const std::string& key : fonts.keys()) {
std::string font = absPath(fonts.value<std::string>(key));
for (const std::pair<std::string, std::string>& font : _configuration->fonts) {
std::string key = font.first;
std::string fontName = absPath(font.second);
if (!FileSys.fileExists(font)) {
LERROR(fmt::format("Could not find font '{}'", font));
if (!FileSys.fileExists(fontName)) {
LERROR(fmt::format("Could not find font '{}' for key '{}'", fontName, key));
continue;
}
LDEBUG(fmt::format("Registering font '{}' with key '{}'", font, key));
bool success = _fontManager->registerFontPath(key, font);
LDEBUG(fmt::format("Registering font '{}' with key '{}'", fontName, key));
bool success = _fontManager->registerFontPath(key, fontName);
if (!success) {
LERROR(fmt::format("Error registering font '{}' with key '{}'", font, key));
LERROR(fmt::format(
"Error registering font '{}' with key '{}'", fontName, key
));
}
}
try {
bool initSuccess = ghoul::fontrendering::FontRenderer::initialize();
if (!initSuccess) {
@@ -919,42 +886,28 @@ void OpenSpaceEngine::loadFonts() {
}
void OpenSpaceEngine::configureLogging(bool consoleLog) {
constexpr const char* KeyLogLevel = ConfigurationManager::KeyLoggingLogLevel;
constexpr const char* KeyLogImmediateFlush =
ConfigurationManager::KeyLoggingImmediateFlush;
constexpr const char* KeyLogs = ConfigurationManager::KeyLoggingLogs;
// We previously initialized the LogManager with a console log to provide some logging
// until we know which logs should be added
LogManager::deinitialize();
if (configurationManager().hasKeyAndValue<std::string>(KeyLogLevel)) {
std::string logLevel = "Info";
configurationManager().getValue(KeyLogLevel, logLevel);
LogLevel level = ghoul::logging::levelFromString(_configuration->logging.level);
bool immediateFlush = _configuration->logging.forceImmediateFlush;
bool immediateFlush = false;
configurationManager().getValue(KeyLogImmediateFlush, immediateFlush);
LogLevel level = ghoul::logging::levelFromString(logLevel);
LogManager::deinitialize();
using ImmediateFlush = ghoul::logging::LogManager::ImmediateFlush;
LogManager::initialize(
level,
immediateFlush ? ImmediateFlush::Yes : ImmediateFlush::No
);
if (consoleLog) {
LogMgr.addLog(std::make_unique<ConsoleLog>());
}
using ImmediateFlush = ghoul::logging::LogManager::ImmediateFlush;
LogManager::initialize(
level,
immediateFlush ? ImmediateFlush::Yes : ImmediateFlush::No
);
if (consoleLog) {
LogMgr.addLog(std::make_unique<ConsoleLog>());
}
if (configurationManager().hasKeyAndValue<ghoul::Dictionary>(KeyLogs)) {
ghoul::Dictionary logs = configurationManager().value<ghoul::Dictionary>(KeyLogs);
for (size_t i = 1; i <= logs.size(); ++i) {
ghoul::Dictionary logInfo = logs.value<ghoul::Dictionary>(std::to_string(i));
try {
LogMgr.addLog(createLog(logInfo));
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
for (const ghoul::Dictionary& log : _configuration->logging.logs) {
try {
LogMgr.addLog(createLog(log));
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
@@ -980,40 +933,25 @@ void OpenSpaceEngine::configureLogging(bool consoleLog) {
void OpenSpaceEngine::writeSceneDocumentation() {
// Write keyboard documentation.
if (configurationManager().hasKey(ConfigurationManager::KeyKeyboardShortcuts)) {
if (!_configuration->documentation.keyboard.empty()) {
keyBindingManager().writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyKeyboardShortcuts
))
absPath(_configuration->documentation.keyboard)
);
}
if (configurationManager().hasKey(ConfigurationManager::KeySceneLicenseDocumentation))
{
if (!_configuration->documentation.license.empty()) {
_scene->writeSceneLicenseDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeySceneLicenseDocumentation
))
absPath(_configuration->documentation.license)
);
}
// If a PropertyDocumentationFile was specified, generate it now.
if (configurationManager().hasKey(
ConfigurationManager::KeyScenePropertyDocumentation
))
{
_scene->writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyScenePropertyDocumentation
))
);
if (!_configuration->documentation.sceneProperty.empty()) {
_scene->writeDocumentation(absPath(_configuration->documentation.sceneProperty));
}
if (configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentation)) {
if (!_configuration->documentation.property.empty()) {
_rootPropertyOwner->writeDocumentation(
absPath(configurationManager().value<std::string>(
ConfigurationManager::KeyPropertyDocumentation
))
absPath(_configuration->documentation.property)
);
}
}
@@ -1031,200 +969,149 @@ void OpenSpaceEngine::initializeGL() {
}
LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(end)");
if (_configurationManager->hasKey(ConfigurationManager::KeyOpenGLDebugContext)) {
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)");
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(
ConfigurationManager::KeyOpenGLDebugContext
);
bool debug = dict.value<bool>(ConfigurationManager::PartActivate);
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)");
bool debugActive = _configuration->openGLDebugContext.isActive;
// Debug output is not available before 4.3
const ghoul::systemcapabilities::Version minVersion = { 4, 3, 0 };
if (OpenGLCap.openGLVersion() < minVersion) {
LINFO("OpenGL Debug context requested, but insufficient version available");
debug = false;
}
if (debug) {
using namespace ghoul::opengl::debug;
bool synchronous = true;
if (dict.hasKey(ConfigurationManager::PartSynchronous)) {
synchronous = dict.value<bool>(ConfigurationManager::PartSynchronous);
}
setDebugOutput(DebugOutput(debug), SynchronousOutput(synchronous));
if (dict.hasKey(ConfigurationManager::PartFilterIdentifier)) {
ghoul::Dictionary filterDict = dict.value<ghoul::Dictionary>(
ConfigurationManager::PartFilterIdentifier
);
for (size_t i = 1; i <= filterDict.size(); ++i) {
ghoul::Dictionary id = filterDict.value<ghoul::Dictionary>(
std::to_string(i)
);
const unsigned int identifier = static_cast<unsigned int>(
id.value<double>(
ConfigurationManager::PartFilterIdentifierIdentifier
)
);
const std::string s = id.value<std::string>(
ConfigurationManager::PartFilterIdentifierSource
);
const std::string t = id.value<std::string>(
ConfigurationManager::PartFilterIdentifierType
);
setDebugMessageControl(
ghoul::from_string<Source>(s),
ghoul::from_string<Type>(t),
{ identifier },
Enabled::No
);
}
}
if (dict.hasKey(ConfigurationManager::PartFilterSeverity)) {
ghoul::Dictionary filterDict = dict.value<ghoul::Dictionary>(
ConfigurationManager::PartFilterIdentifier
);
for (size_t i = 1; i <= filterDict.size(); ++i) {
std::string severity = filterDict.value<std::string>(
std::to_string(i)
);
setDebugMessageControl(
Source::DontCare,
Type::DontCare,
ghoul::from_string<Severity>(severity),
Enabled::No
);
}
}
auto callback = [](Source source, Type type, Severity severity,
unsigned int id, std::string message) -> void
{
const std::string s = std::to_string(source);
const std::string t = std::to_string(type);
const std::string category =
"OpenGL (" + s + ") [" + t + "] {" + std::to_string(id) + "}";
switch (severity) {
case Severity::High:
LERRORC(category, message);
break;
case Severity::Medium:
LWARNINGC(category, message);
break;
case Severity::Low:
LINFOC(category, message);
break;
case Severity::Notification:
LDEBUGC(category, message);
break;
default:
throw ghoul::MissingCaseException();
}
};
ghoul::opengl::debug::setDebugCallback(callback);
}
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(end)");
// Debug output is not available before 4.3
const ghoul::systemcapabilities::Version minVersion = { 4, 3, 0 };
if (debugActive && OpenGLCap.openGLVersion() < minVersion) {
LINFO("OpenGL Debug context requested, but insufficient version available");
debugActive = false;
}
if (debugActive) {
using namespace ghoul::opengl::debug;
bool synchronous = _configuration->openGLDebugContext.isSynchronous;
setDebugOutput(DebugOutput(debugActive), SynchronousOutput(synchronous));
using IdFilter = Configuration::OpenGLDebugContext::IdentifierFilter;
for (const IdFilter&f : _configuration->openGLDebugContext.identifierFilters) {
setDebugMessageControl(
ghoul::from_string<Source>(f.source),
ghoul::from_string<Type>(f.type),
{ f.identifier },
Enabled::No
);
}
for (const std::string& sev : _configuration->openGLDebugContext.severityFilters)
{
setDebugMessageControl(
Source::DontCare,
Type::DontCare,
ghoul::from_string<Severity>(sev),
Enabled::No
);
}
auto callback = [](Source source, Type type, Severity severity,
unsigned int id, std::string message) -> void
{
const std::string s = std::to_string(source);
const std::string t = std::to_string(type);
const std::string category =
"OpenGL (" + s + ") [" + t + "] {" + std::to_string(id) + "}";
switch (severity) {
case Severity::High:
LERRORC(category, message);
break;
case Severity::Medium:
LWARNINGC(category, message);
break;
case Severity::Low:
LINFOC(category, message);
break;
case Severity::Notification:
LDEBUGC(category, message);
break;
default:
throw ghoul::MissingCaseException();
}
};
ghoul::opengl::debug::setDebugCallback(callback);
}
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(end)");
// The ordering of the KeyCheckOpenGLState and KeyLogEachOpenGLCall are important as
// the callback mask in glbinding is stateful for each context, and since
// KeyLogEachOpenGLCall is more specific, we want it to be able to overwrite the
// state from KeyCheckOpenGLState
if (_configurationManager->hasKey(ConfigurationManager::KeyCheckOpenGLState)) {
const bool val = _configurationManager->value<bool>(
ConfigurationManager::KeyCheckOpenGLState
);
if (val) {
using namespace glbinding;
setCallbackMaskExcept(CallbackMask::After, { "glGetError" });
setAfterCallback([](const FunctionCall& f) {
const GLenum error = glGetError();
switch (error) {
case GL_NO_ERROR:
break;
case GL_INVALID_ENUM:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_ENUM", f.toString())
);
break;
case GL_INVALID_VALUE:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_VALUE", f.toString())
);
break;
case GL_INVALID_OPERATION:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_OPERATION", f.toString())
);
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
LERRORC(
"OpenGL Invalid State",
fmt::format(
"Function {}: GL_INVALID_FRAMEBUFFER_OPERATION",
f.toString()
)
);
break;
case GL_OUT_OF_MEMORY:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_OUT_OF_MEMORY", f.toString())
);
break;
default:
LERRORC(
"OpenGL Invalid State",
fmt::format("Unknown error code: {0:x}", error)
);
}
});
}
if (_configuration->isCheckingOpenGLState) {
using namespace glbinding;
// Infinite loop -- welcome to the danger zone
setCallbackMaskExcept(CallbackMask::After, { "glGetError" });
setAfterCallback([](const FunctionCall& f) {
const GLenum error = glGetError();
switch (error) {
case GL_NO_ERROR:
break;
case GL_INVALID_ENUM:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_ENUM", f.toString())
);
break;
case GL_INVALID_VALUE:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_VALUE", f.toString())
);
break;
case GL_INVALID_OPERATION:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_INVALID_OPERATION", f.toString())
);
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
LERRORC(
"OpenGL Invalid State",
fmt::format(
"Function {}: GL_INVALID_FRAMEBUFFER_OPERATION",
f.toString()
)
);
break;
case GL_OUT_OF_MEMORY:
LERRORC(
"OpenGL Invalid State",
fmt::format("Function {}: GL_OUT_OF_MEMORY", f.toString())
);
break;
default:
LERRORC(
"OpenGL Invalid State",
fmt::format("Unknown error code: {0:x}", error)
);
}
});
}
if (_configurationManager->hasKey(ConfigurationManager::KeyLogEachOpenGLCall)) {
const bool val = _configurationManager->value<bool>(
ConfigurationManager::KeyLogEachOpenGLCall
);
if (_configuration->isLoggingOpenGLCalls) {
using namespace glbinding;
setCallbackMask(CallbackMask::After | CallbackMask::ParametersAndReturnValue);
glbinding::setAfterCallback([](const glbinding::FunctionCall& call) {
std::string arguments = std::accumulate(
call.parameters.begin(),
call.parameters.end(),
std::string("("),
[](std::string a, AbstractValue* v) {
return a + ", " + v->asString();
}
);
if (val) {
using namespace glbinding;
setCallbackMask(CallbackMask::After | CallbackMask::ParametersAndReturnValue);
glbinding::setAfterCallback([](const glbinding::FunctionCall& call) {
std::string arguments = std::accumulate(
call.parameters.begin(),
call.parameters.end(),
std::string("("),
[](std::string a, AbstractValue* v) {
return a + ", " + v->asString();
}
);
std::string returnValue = call.returnValue ?
" -> " + call.returnValue->asString() :
"";
std::string returnValue = call.returnValue ?
" -> " + call.returnValue->asString() :
"";
LTRACEC(
"OpenGL",
call.function->name() + arguments + returnValue
);
});
}
LTRACEC(
"OpenGL",
call.function->name() + arguments + returnValue
);
});
}
LDEBUG("Initializing Rendering Engine");
@@ -1683,9 +1570,8 @@ void OpenSpaceEngine::registerModuleMouseScrollWheelCallback(
_moduleCallbacks.mouseScrollWheel.push_back(std::move(function));
}
ConfigurationManager& OpenSpaceEngine::configurationManager() {
ghoul_assert(_configurationManager, "ConfigurationManager must not be nullptr");
return *_configurationManager;
const Configuration& OpenSpaceEngine::configuration() const {
return *_configuration;
}
LuaConsole& OpenSpaceEngine::console() {

View File

@@ -27,7 +27,7 @@
#include <openspace/util/syncdata.h>
#include <openspace/openspace.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/navigationhandler.h>
@@ -261,22 +261,9 @@ RenderEngine::RenderEngine()
_doPerformanceMeasurements.onChange([this](){
if (_doPerformanceMeasurements) {
if (!_performanceManager) {
std::string loggingDir = "${BASE}";
constexpr const char* KeyDir = ConfigurationManager::LoggingDirectory;
if (OsEng.configurationManager().hasKey(KeyDir)) {
loggingDir = OsEng.configurationManager().value<std::string>(KeyDir);
}
std::string prefix = "PM-";
constexpr const char* KeyPrefix =
ConfigurationManager::LoggingPerformancePrefix;
if (OsEng.configurationManager().hasKey(KeyPrefix)) {
prefix = OsEng.configurationManager().value<std::string>(KeyPrefix);
}
_performanceManager = std::make_shared<performance::PerformanceManager>(
loggingDir,
prefix
OsEng.configuration().logging.directory,
OsEng.configuration().logging.performancePrefix
);
}
}
@@ -352,14 +339,9 @@ void RenderEngine::setRendererFromString(const std::string& renderingMethod) {
void RenderEngine::initialize() {
_frameNumber = 0;
std::string renderingMethod = DefaultRenderingMethod;
// If the user specified a rendering method that he would like to use, use that
ConfigurationManager& confManager = OsEng.configurationManager();
if (confManager.hasKeyAndValue<std::string>(KeyRenderingMethod)) {
renderingMethod = confManager.value<std::string>(KeyRenderingMethod);
}
else {
std::string renderingMethod = OsEng.configuration().renderingMethod;
if (renderingMethod == "ABuffer") {
using Version = ghoul::systemcapabilities::Version;
// The default rendering method has a requirement of OpenGL 4.3, so if we are
@@ -370,17 +352,9 @@ void RenderEngine::initialize() {
}
}
if (confManager.hasKey(ConfigurationManager::KeyDisableMasterRendering)) {
_disableMasterRendering = confManager.value<bool>(
ConfigurationManager::KeyDisableMasterRendering
);
}
if (confManager.hasKey(ConfigurationManager::KeyDisableSceneOnMaster)) {
_disableSceneTranslationOnMaster = confManager.value<bool>(
ConfigurationManager::KeyDisableSceneOnMaster
);
}
_disableMasterRendering = OsEng.configuration().isRenderingOnMasterDisabled;
_disableSceneTranslationOnMaster =
OsEng.configuration().isSceneTranslationOnMasterDisabled;
_raycasterManager = std::make_unique<RaycasterManager>();
_deferredcasterManager = std::make_unique<DeferredcasterManager>();
@@ -531,16 +505,11 @@ glm::ivec2 RenderEngine::renderingResolution() const {
}
glm::ivec2 RenderEngine::fontResolution() const {
std::string value;
bool hasValue = OsEng.configurationManager().getValue(
ConfigurationManager::KeyOnScreenTextScaling,
value
);
if (hasValue && value == "framebuffer") {
const std::string& value = OsEng.configuration().onScreenTextScaling;
if (value == "framebuffer") {
return OsEng.windowWrapper().currentWindowResolution();
}
else {
// The default is to use the window size
return OsEng.windowWrapper().currentWindowSize();
}
}

View File

@@ -25,7 +25,6 @@
#include <openspace/scene/scene.h>
#include <openspace/openspace.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/navigationhandler.h>

View File

@@ -30,7 +30,7 @@
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/exception.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/network/parallelpeer.h>
#include <openspace/util/syncbuffer.h>
@@ -587,16 +587,8 @@ bool ScriptEngine::writeLog(const std::string& script) {
// Check that logging is enabled and initialize if necessary
if (!_logFileExists) {
// If a ScriptLogFile was specified, generate it now
const bool hasFile = OsEng.configurationManager().hasKey(
ConfigurationManager::KeyScriptLog
);
if (hasFile) {
OsEng.configurationManager().getValue(
ConfigurationManager::KeyScriptLog,
_logFilename
);
_logFilename = absPath(_logFilename);
if (!OsEng.configuration().scriptLog.empty()) {
_logFilename = absPath(OsEng.configuration().scriptLog);
_logFileExists = true;
LDEBUG(fmt::format(

View File

@@ -49,7 +49,6 @@
#define GHL_THROW_ON_ASSERT
#endif // GHL_THROW_ON_ASSERTGHL_THROW_ON_ASSERT
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/util/factorymanager.h>