Turn Configuration keys from std::string to constexpr const char* for better startup performance

This commit is contained in:
Alexander Bock
2018-03-08 19:24:03 +01:00
parent ae3b6fe850
commit 9709b22bac
6 changed files with 194 additions and 142 deletions

View File

@@ -42,137 +42,196 @@ namespace documentation { struct Documentation; }
class ConfigurationManager : public ghoul::Dictionary {
public:
/// The key that stores the subdirectory containing all predefined path tokens
static const std::string KeyPaths;
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 const std::string KeyCache;
static constexpr const char* KeyCachePath = "Paths.CACHE";
/// The key that stores the main directory for fonts
static const std::string KeyFonts;
static constexpr const char* KeyFonts = "Fonts";
/// The key that stores the location of the SGCT configuration file that is used on
/// application launch
static const std::string KeyConfigSgct;
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 const std::string KeyGlobalCustomizationScripts;
static constexpr const char* KeyGlobalCustomizationScripts =
"GlobalCustomizationScripts";
/// The part of the key that defines the type
static const std::string PartType;
// static constexpr const char* PartType = "Type";
/// The part of the key that defines the file
static const std::string PartFile;
// static constexpr const char* PartFile = "File";
/// The key that stores the Lua documentation
static const std::string KeyLuaDocumentation;
static constexpr const char* KeyLuaDocumentation = "LuaDocumentation";
/// The key that stores the scripting log
static const std::string KeyScriptLog;
static constexpr const char* KeyScriptLog = "ScriptLog";
/// The key that stores the Scene Property documentation
static const std::string KeyScenePropertyDocumentation;
static constexpr const char* KeyScenePropertyDocumentation =
"ScenePropertyDocumentation";
/// The key that stores the Root Property documentation
static const std::string KeyPropertyDocumentation;
static constexpr const char* KeyPropertyDocumentation = "PropertyDocumentation";
/// The key that stores the keyboard bindings that should be stored
static const std::string KeyKeyboardShortcuts;
static constexpr const char* KeyKeyboardShortcuts = "KeyboardShortcuts";
/// The key that stores the main documentation
static const std::string KeyDocumentation;
static constexpr const char* KeyDocumentation = "Documentation";
/// The key that stores the factory documentation values
static const std::string KeyFactoryDocumentation;
static constexpr const char* KeyFactoryDocumentation = "FactoryDocumentation";
/// The key that stores the location of the asset file that is initially loaded
static const std::string KeyConfigAsset;
static constexpr const char* KeyConfigAsset = "Asset";
/// The key that stores the scene license documentation values
static const std::string KeySceneLicenseDocumentation;
/// The key that stores the subdirectory containing a list of all startup scripts to
/// be executed on application start before the scene file is loaded
static const std::string KeyStartupScript;
/// The key that stores the subdirectory containing a list of all settings scripts to
/// be executed on application start and after the scene file is loaded
static const std::string KeySettingsScript;
static constexpr const char* KeySceneLicenseDocumentation = "LicenseDocumentation";
/// The key that stores the settings for determining log-related settings
static const std::string KeyLogging;
static constexpr const char* KeyLogging = "Logging";
/// The key that stores the directory for Logging
static const std::string PartLogDir;
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 const std::string PartLogLevel;
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 const std::string PartImmediateFlush;
static constexpr const char* KeyLoggingImmediateFlush = "Logging.ImmediateFlush";
static constexpr const char* PartImmediateFlush = "ImmediateFlush";
/// The key for prefixing PerformanceMeasurement logfiles
static const std::string PartLogPerformancePrefix;
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 const std::string PartLogs;
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 const std::string PartAppend;
static constexpr const char* PartAppend = "Append";
/// The key that stores the verbosity (None, Minimal, Default, Full) of the system
/// capabilities components
static const std::string PartCapabilitiesVerbosity;
static constexpr const char* PartCapabilitiesVerbosity = "CapabilitiesVerbosity";
/// The key that stores the settings for determining Launcher-related settings
static const std::string KeyLauncher;
static constexpr const char* KeyLauncher = "Launcher";
/// The full key that stores the verbosity of the system capabilities component
static const std::string KeyCapabilitiesVerbosity;
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 const std::string KeyShutdownCountdown;
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 const std::string KeyOnScreenTextScaling;
static constexpr const char* KeyOnScreenTextScaling = "OnScreenTextScaling";
/// The key that stores whether the master node should perform rendering just function
/// as a pure manager
static const std::string KeyDisableMasterRendering;
static constexpr const char* KeyDisableMasterRendering = "DisableRenderingOnMaster";
/// The key that stores whether the master node should apply the scene transformation
static const std::string KeyDisableSceneOnMaster;
static constexpr const char* KeyDisableSceneOnMaster = "DisableSceneOnMaster";
/// The key that stores the switch for enabling/disabling the rendering on a master
/// computer
static const std::string KeyRenderingMethod;
static constexpr const char* KeyRenderingMethod = "RenderingMethod";
/// The key that determines whether a new cache folder is used for each scene file
static const std::string KeyPerSceneCache;
static constexpr const char* KeyPerSceneCache = "PerSceneCache";
/// The key that stores the http proxy settings for the downloadmanager
static const std::string KeyHttpProxy;
static constexpr const char* KeyHttpProxy = "HttpProxy";
/// The key that stores the address of the http proxy
static const std::string PartHttpProxyAddress;
static constexpr const char* PartHttpProxyAddress = "Address";
/// The key that stores the port of the http proxy
static const std::string PartHttpProxyPort;
static constexpr const char* PartHttpProxyPort = "Port";
/// The key that stores the authentication method of the http proxy
static const std::string PartHttpProxyAuthentication;
static constexpr const char* PartHttpProxyAuthentication = "Authentication";
/// Key that stores the username to use for authentication to access the http proxy
static const std::string PartHttpProxyUser;
static constexpr const char* PartHttpProxyUser = "User";
/// Key that stores the password to use for authentication to access the http proxy
static const std::string PartHttpProxyPassword;
static constexpr const char* PartHttpProxyPassword = "Password";
/// The key that stores the dictionary containing information about debug contexts
static const std::string KeyOpenGLDebugContext;
static constexpr const char* KeyOpenGLDebugContext = "OpenGLDebugContext";
/// The part of the key storing whether an OpenGL Debug context should be created
static const std::string PartActivate;
static constexpr const char* PartActivate = "Activate";
/// The part of the key storing whether the debug callbacks are performed synchronous
static const std::string PartSynchronous;
static constexpr const char* PartSynchronous = "Synchronous";
/// The part of the key storing a list of identifiers that should be filtered out
static const std::string PartFilterIdentifier;
static constexpr const char* PartFilterIdentifier = "FilterIdentifier";
/// The part of the key that stores the source of the ignored identifier
static const std::string PartFilterIdentifierSource;
static constexpr const char* PartFilterIdentifierSource = "Source";
/// The part of the key that stores the type of the ignored identifier
static const std::string PartFilterIdentifierType;
static constexpr const char* PartFilterIdentifierType = "Type";
/// The part of the key that stores the identifier of the ignored identifier
static const std::string PartFilterIdentifierIdentifier;
static constexpr const char* PartFilterIdentifierIdentifier = "Identifier";
/// The part of the key storing a list of severities that should be filtered out
static const std::string PartFilterSeverity;
static constexpr const char* PartFilterSeverity = "PartFilterSeverity";
/// The part of the key storing whether the OpenGL state should be checked each call
static const std::string KeyCheckOpenGLState;
static constexpr const char* KeyCheckOpenGLState = "CheckOpenGLState";
/// The part of the key storing whether each OpenGL call should be logged
static const std::string KeyLogEachOpenGLCall;
static constexpr const char* KeyLogEachOpenGLCall = "LogEachOpenGLCall";
/// This key determines whether the scene graph nodes should initialized multithreaded
static const std::string KeyUseMultithreadedInitialization;
static constexpr const char* KeyUseMultithreadedInitialization =
"UseMultithreadedInitialization";
/// The key under which all of the loading settings are grouped
static const std::string KeyLoadingScreen;
static constexpr const char* KeyLoadingScreen = "LoadingScreen";
/// The part of the key storing whether the loading screen should display the message
/// about current status
static const std::string PartShowMessage;
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 const std::string PartShowNodeNames;
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 const std::string PartShowProgressbar;
static constexpr const char* KeyLoadingScreenShowProgressbar =
"LoadingScreen.ShowProgressbar";
static constexpr const char* PartShowProgressbar = "ShowProgressbar";
/// The key used to specify module specific configurations
static const std::string KeyModuleConfigurations;
static constexpr const char* KeyModuleConfigurations = "ModuleConfigurations";
/// The key used to specify whether screenshots should contain the current date
static const std::string KeyScreenshotUseDate;
static constexpr const char* KeyScreenshotUseDate = "ScreenshotUseDate";
/**
@@ -202,6 +261,7 @@ public:
*/
void loadFromFile(const std::string& filename);
static documentation::Documentation Documentation();
};

View File

@@ -76,7 +76,7 @@ namespace {
// [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
constexpr const char* KeyColorTableRanges = "ColorTableRanges";
// [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
constexpr const char* KeyMaskingRanges = "MaskingRanges"
constexpr const char* KeyMaskingRanges = "MaskingRanges";
// [STRING] Value should be path to folder where states are saved (JSON/CDF input
// => osfls output & oslfs input => JSON output)
constexpr const char* KeyOutputFolder = "OutputFolder";

View File

@@ -47,80 +47,80 @@ namespace {
namespace openspace {
const string ConfigurationManager::KeyPaths = "Paths";
const string ConfigurationManager::KeyCache = "CACHE";
const string ConfigurationManager::KeyFonts = "Fonts";
const string ConfigurationManager::KeyConfigSgct = "SGCTConfig";
const string ConfigurationManager::KeyGlobalCustomizationScripts =
"GlobalCustomizationScripts";
// static constexpr const char* ConfigurationManager::KeyPaths = "Paths";
// const string ConfigurationManager::KeyCache = "CACHE";
// const string ConfigurationManager::KeyFonts = "Fonts";
// const string ConfigurationManager::KeyConfigSgct = "SGCTConfig";
// const string ConfigurationManager::KeyGlobalCustomizationScripts =
// "GlobalCustomizationScripts";
const string ConfigurationManager::PartType = "Type";
const string ConfigurationManager::PartFile = "File";
// const string ConfigurationManager::PartType = "Type";
// const string ConfigurationManager::PartFile = "File";
const string ConfigurationManager::KeyLuaDocumentation = "LuaDocumentation";
const string ConfigurationManager::KeyScriptLog = "ScriptLog";
const string ConfigurationManager::KeyPropertyDocumentation = "PropertyDocumentation";
const string ConfigurationManager::KeyScenePropertyDocumentation =
"ScenePropertyDocumentation";
const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts";
const string ConfigurationManager::KeyDocumentation = "Documentation";
const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation";
// const string ConfigurationManager::KeyLuaDocumentation = "LuaDocumentation";
// const string ConfigurationManager::KeyScriptLog = "ScriptLog";
// const string ConfigurationManager::KeyPropertyDocumentation = "PropertyDocumentation";
// const string ConfigurationManager::KeyScenePropertyDocumentation =
// "ScenePropertyDocumentation";
// const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts";
// const string ConfigurationManager::KeyDocumentation = "Documentation";
// const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation";
const string ConfigurationManager::KeyConfigAsset = "Asset";
const string ConfigurationManager::KeySceneLicenseDocumentation = "LicenseDocumentation";
// const string ConfigurationManager::KeyConfigAsset = "Asset";
// const string ConfigurationManager::KeySceneLicenseDocumentation = "LicenseDocumentation";
const string ConfigurationManager::KeyLogging = "Logging";
const string ConfigurationManager::PartLogDir = "LogDir";
const string ConfigurationManager::PartLogLevel = "LogLevel";
const string ConfigurationManager::PartImmediateFlush = "ImmediateFlush";
const string ConfigurationManager::PartLogPerformancePrefix = "PerformancePrefix";
// const string ConfigurationManager::KeyLogging = "Logging";
// const string ConfigurationManager::PartLogDir = "LogDir";
// const string ConfigurationManager::PartLogLevel = "LogLevel";
// const string ConfigurationManager::PartImmediateFlush = "ImmediateFlush";
// const string ConfigurationManager::PartLogPerformancePrefix = "PerformancePrefix";
const string ConfigurationManager::PartLogs = "Logs";
const string ConfigurationManager::PartAppend = "Append";
const string ConfigurationManager::PartCapabilitiesVerbosity = "CapabilitiesVerbosity";
// const string ConfigurationManager::PartLogs = "Logs";
// const string ConfigurationManager::PartAppend = "Append";
// const string ConfigurationManager::PartCapabilitiesVerbosity = "CapabilitiesVerbosity";
const string ConfigurationManager::KeyLauncher = "Launcher";
// const string ConfigurationManager::KeyLauncher = "Launcher";
const string ConfigurationManager::KeyCapabilitiesVerbosity =
KeyLogging + "." + PartCapabilitiesVerbosity;
// const string ConfigurationManager::KeyCapabilitiesVerbosity =
// KeyLogging + "." + PartCapabilitiesVerbosity;
const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown";
const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster";
const string ConfigurationManager::KeyDisableSceneOnMaster = "DisableSceneOnMaster";
const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache";
const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod";
// const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown";
// const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster";
// const string ConfigurationManager::KeyDisableSceneOnMaster = "DisableSceneOnMaster";
// const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache";
// const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod";
const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling";
// const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling";
const string ConfigurationManager::KeyHttpProxy = "HttpProxy";
const string ConfigurationManager::PartHttpProxyAddress = "Address";
const string ConfigurationManager::PartHttpProxyPort = "Port";
const string ConfigurationManager::PartHttpProxyAuthentication = "Authentication";
const string ConfigurationManager::PartHttpProxyUser = "User";
const string ConfigurationManager::PartHttpProxyPassword = "Password";
// const string ConfigurationManager::KeyHttpProxy = "HttpProxy";
// const string ConfigurationManager::PartHttpProxyAddress = "Address";
// const string ConfigurationManager::PartHttpProxyPort = "Port";
// const string ConfigurationManager::PartHttpProxyAuthentication = "Authentication";
// const string ConfigurationManager::PartHttpProxyUser = "User";
// const string ConfigurationManager::PartHttpProxyPassword = "Password";
const string ConfigurationManager::KeyOpenGLDebugContext = "OpenGLDebugContext";
const string ConfigurationManager::PartActivate = "Activate";
const string ConfigurationManager::PartSynchronous = "Synchronous";
const string ConfigurationManager::PartFilterIdentifier = "FilterIdentifier";
const string ConfigurationManager::PartFilterIdentifierSource = "Source";
const string ConfigurationManager::PartFilterIdentifierType = "Type";
const string ConfigurationManager::PartFilterIdentifierIdentifier = "Identifier";
const string ConfigurationManager::PartFilterSeverity = "PartFilterSeverity";
const string ConfigurationManager::KeyCheckOpenGLState = "CheckOpenGLState";
const string ConfigurationManager::KeyLogEachOpenGLCall = "LogEachOpenGLCall";
// const string ConfigurationManager::KeyOpenGLDebugContext = "OpenGLDebugContext";
// const string ConfigurationManager::PartActivate = "Activate";
// const string ConfigurationManager::PartSynchronous = "Synchronous";
// const string ConfigurationManager::PartFilterIdentifier = "FilterIdentifier";
// const string ConfigurationManager::PartFilterIdentifierSource = "Source";
// const string ConfigurationManager::PartFilterIdentifierType = "Type";
// const string ConfigurationManager::PartFilterIdentifierIdentifier = "Identifier";
// const string ConfigurationManager::PartFilterSeverity = "PartFilterSeverity";
// const string ConfigurationManager::KeyCheckOpenGLState = "CheckOpenGLState";
// const string ConfigurationManager::KeyLogEachOpenGLCall = "LogEachOpenGLCall";
const string ConfigurationManager::KeyUseMultithreadedInitialization =
"UseMultithreadedInitialization";
// const string ConfigurationManager::KeyUseMultithreadedInitialization =
// "UseMultithreadedInitialization";
const string ConfigurationManager::KeyLoadingScreen = "LoadingScreen";
const string ConfigurationManager::PartShowMessage = "ShowMessage";
const string ConfigurationManager::PartShowNodeNames = "ShowNodeNames";
const string ConfigurationManager::PartShowProgressbar = "ShowProgressbar";
// const string ConfigurationManager::KeyLoadingScreen = "LoadingScreen";
// const string ConfigurationManager::PartShowMessage = "ShowMessage";
// const string ConfigurationManager::PartShowNodeNames = "ShowNodeNames";
// const string ConfigurationManager::PartShowProgressbar = "ShowProgressbar";
const string ConfigurationManager::KeyScreenshotUseDate = "ScreenshotUseDate";
// const string ConfigurationManager::KeyScreenshotUseDate = "ScreenshotUseDate";
const string ConfigurationManager::KeyModuleConfigurations = "ModuleConfigurations";
// const string ConfigurationManager::KeyModuleConfigurations = "ModuleConfigurations";
string ConfigurationManager::findConfiguration(const string& filename) {
using ghoul::filesystem::Directory;

View File

@@ -69,7 +69,8 @@ documentation::Documentation ConfigurationManager::Documentation() {
"in all other configuration files or scripts."
},
{
ConfigurationManager::KeyPaths + '.' + ConfigurationManager::KeyCache,
ConfigurationManager::KeyCachePath,
new StringVerifier,
Optional::No,
"The path to be used as a cache folder. If per scene caching is enabled, the "

View File

@@ -603,26 +603,21 @@ void OpenSpaceEngine::scheduleLoadSingleAsset(std::string assetPath) {
std::unique_ptr<LoadingScreen> OpenSpaceEngine::createLoadingScreen() {
bool showMessage = true;
std::string kMessage =
ConfigurationManager::KeyLoadingScreen + "." +
ConfigurationManager::PartShowMessage;
constexpr const char* kMessage = ConfigurationManager::KeyLoadingScreenShowMessage;
if (configurationManager().hasKey(kMessage)) {
showMessage = configurationManager().value<bool>(kMessage);
}
bool showNodeNames = true;
std::string kNames =
ConfigurationManager::KeyLoadingScreen + "." +
ConfigurationManager::PartShowNodeNames;
constexpr const char* kNames = ConfigurationManager::KeyLoadingScreenShowNodeNames;
if (configurationManager().hasKey(kNames)) {
showNodeNames = configurationManager().value<bool>(kNames);
}
bool showProgressbar = true;
std::string kProgress =
ConfigurationManager::KeyLoadingScreen + "." +
ConfigurationManager::PartShowProgressbar;
constexpr const char* kProgress =
ConfigurationManager::KeyLoadingScreenShowProgressbar;
if (configurationManager().hasKey(kProgress)) {
showProgressbar = configurationManager().value<bool>(kProgress);
@@ -917,12 +912,10 @@ void OpenSpaceEngine::loadFonts() {
}
void OpenSpaceEngine::configureLogging(bool consoleLog) {
const std::string KeyLogLevel =
ConfigurationManager::KeyLogging + '.' + ConfigurationManager::PartLogLevel;
const std::string KeyLogImmediateFlush =
ConfigurationManager::KeyLogging + '.' + ConfigurationManager::PartImmediateFlush;
const std::string KeyLogs =
ConfigurationManager::KeyLogging + '.' + ConfigurationManager::PartLogs;
constexpr const char* KeyLogLevel = ConfigurationManager::KeyLoggingLogLevel;
constexpr const char* KeyLogImmediateFlush =
ConfigurationManager::KeyLoggingImmediateFlush;
constexpr const char* KeyLogs = ConfigurationManager::KeyLoggingLogs;
if (configurationManager().hasKeyAndValue<std::string>(KeyLogLevel)) {
std::string logLevel = "Info";

View File

@@ -261,16 +261,14 @@ RenderEngine::RenderEngine()
if (_doPerformanceMeasurements) {
if (!_performanceManager) {
std::string loggingDir = "${BASE}";
const std::string KeyDir = ConfigurationManager::KeyLogging + "." +
ConfigurationManager::PartLogDir;
constexpr const char* KeyDir = ConfigurationManager::LoggingDirectory;
if (OsEng.configurationManager().hasKey(KeyDir)) {
loggingDir = OsEng.configurationManager().value<std::string>(KeyDir);
}
std::string prefix = "PM-";
const std::string KeyPrefix = ConfigurationManager::KeyLogging + "." +
ConfigurationManager::PartLogPerformancePrefix;
constexpr const char* KeyPrefix =
ConfigurationManager::LoggingPerformancePrefix;
if (OsEng.configurationManager().hasKey(KeyPrefix)) {
prefix = OsEng.configurationManager().value<std::string>(KeyPrefix);
}