Add an option to the configuration manager to append the scene name to the cache directory (closing #159)

This commit is contained in:
Alexander Bock
2016-11-07 13:38:17 +01:00
parent 921f5060c4
commit 70af0f0073
5 changed files with 41 additions and 6 deletions

View File

@@ -109,6 +109,8 @@ public:
/// The key that stores the switch for enabling/disabling the rendering on a master
/// computer
static const std::string KeyRenderingMethod;
/// The key that determines whether a new cache folder is used for each scene file
static const std::string KeyPerSceneCache;
/// The key that stores the http proxy settings for the downloadmanager
static const std::string KeyHttpProxy;
/// The key that stores the address of the http proxy

View File

@@ -66,6 +66,7 @@ return {
File = "${DOCUMENTATION}/FactoryDocumentation.html"
},
ShutdownCountdown = 3,
-- PerSceneCache = true,
DownloadRequestURL = "http://data.openspaceproject.com/request.cgi",
RenderingMethod = "Framebuffer"
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer"

View File

@@ -70,6 +70,7 @@ const string ConfigurationManager::KeyCapabilitiesVerbosity =
const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown";
const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster";
const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL";
const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache";
const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod";
const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling";

View File

@@ -199,8 +199,8 @@ Documentation ConfigurationManager::Documentation() {
new StringInListVerifier(
// List taken from ScriptEngine::writeLog
{ "text" }
),
"The type of logfile that will be created."
),
"The type of logfile that will be created."
},
{
ConfigurationManager::PartFile,
@@ -211,8 +211,8 @@ Documentation ConfigurationManager::Documentation() {
}
}),
"Contains a log of all Lua scripts that were executed in the last "
"session.",
Optional::Yes
"session.",
Optional::Yes
},
{
ConfigurationManager::KeyKeyboardShortcuts,
@@ -292,6 +292,15 @@ Documentation ConfigurationManager::Documentation() {
"shutdown is aborted.",
Optional::Yes
},
{
ConfigurationManager::KeyPerSceneCache,
new BoolVerifier,
"If this is set to 'true', the name of the scene will be appended to the "
"cache directory, thus not reusing the same directory. This is useful in "
"cases where the same instance of OpenSpace is run with multiple scenes, but "
"the caches should be retained. This value defaults to 'false'.",
Optional::Yes
},
{
ConfigurationManager::KeyOnScreenTextScaling,
new StringInListVerifier({

View File

@@ -289,10 +289,32 @@ bool OpenSpaceEngine::create(int argc, char** argv,
return false;
}
if (!commandlineArgumentPlaceholders.cacheFolder.empty()) {
bool hasCacheCommandline = !commandlineArgumentPlaceholders.cacheFolder.empty();
bool hasCacheConfiguration = _engine->configurationManager().hasKeyAndValue<bool>(
ConfigurationManager::KeyPerSceneCache
);
std::string cacheFolder = absPath("${CACHE}");
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
//FileSys.registerPathToken(
// "${CACHE}",
// commandlineArgumentPlaceholders.cacheFolder,
// ghoul::filesystem::FileSystem::Override::Yes
//);
}
if (hasCacheConfiguration) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigScene
);
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
if (hasCacheCommandline || hasCacheConfiguration) {
LINFO("Old cache: " << absPath("${CACHE}"));
LINFO("New cache: " << cacheFolder);
FileSys.registerPathToken(
"${CACHE}",
commandlineArgumentPlaceholders.cacheFolder,
cacheFolder,
ghoul::filesystem::FileSystem::Override::Yes
);
}