Apply getValueSafe/getValue change of Dictionary to the codebase

This commit is contained in:
Alexander Bock
2014-09-27 19:23:24 +02:00
parent cfcf0247be
commit f3fb8cd95e
11 changed files with 32 additions and 32 deletions

View File

@@ -63,7 +63,7 @@ bool ConfigurationManager::loadFromFile(const std::string& filename) {
// Register all the paths
ghoul::Dictionary dictionary;
const bool success = getValueSafe(keyPaths, dictionary);
const bool success = getValue(keyPaths, dictionary);
if (!success) {
LERROR("Configuration does not contain the key '" << keyPaths << "'");
return false;

View File

@@ -189,7 +189,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
// Determining SGCT configuration file
LDEBUG("Determining SGCT configuration file");
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
_engine->configurationManager().getValueSafe(constants::configurationmanager::keyConfigSgct,
_engine->configurationManager().getValue(constants::configurationmanager::keyConfigSgct,
sgctConfigurationPath);
// Prepend the outgoing sgctArguments with the program name
@@ -247,7 +247,7 @@ bool OpenSpaceEngine::initialize()
SysCap.logCapabilities();
std::string timeKernel;
OsEng.configurationManager().getValueSafe(constants::configurationmanager::keyConfigTimekernel, timeKernel);
OsEng.configurationManager().getValue(constants::configurationmanager::keyConfigTimekernel, timeKernel);
// initialize OpenSpace helpers
SpiceManager::initialize();
@@ -281,7 +281,7 @@ bool OpenSpaceEngine::initialize()
sceneGraph->initialize();
std::string sceneDescriptionPath;
bool success = OsEng.configurationManager().getValueSafe(
bool success = OsEng.configurationManager().getValue(
constants::configurationmanager::keyConfigScene, sceneDescriptionPath);
if (success)
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
@@ -300,7 +300,7 @@ bool OpenSpaceEngine::initialize()
// Run start up scripts
ghoul::Dictionary scripts;
success = _engine->configurationManager().getValueSafe(
success = _engine->configurationManager().getValue(
constants::configurationmanager::keyStartupScript, scripts);
for (size_t i = 1; i <= scripts.size(); ++i) {
std::stringstream stream;

View File

@@ -87,7 +87,7 @@ int Property::typeLua() const {
const std::string& Property::guiName() const {
std::string result;
_metaData.getValueSafe(_metaDataKeyGuiName, result);
_metaData.getValue(_metaDataKeyGuiName, result);
return std::move(result);
}
@@ -97,7 +97,7 @@ void Property::setGroupIdentifier(std::string groupId) {
std::string Property::groupIdentifier() const {
std::string result;
_metaData.getValueSafe(_metaDataKeyGroup, result);
_metaData.getValue(_metaDataKeyGroup, result);
return std::move(result);
}

View File

@@ -37,7 +37,7 @@ namespace planetgeometry {
PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary)
{
std::string geometryType;
const bool success = dictionary.getValueSafe(
const bool success = dictionary.getValue(
constants::planetgeometry::keyType, geometryType);
if (!success) {
LERROR("PlanetGeometry did not contain a correct value of the key '"

View File

@@ -59,7 +59,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
assert(success);
ghoul::Dictionary geometryDictionary;
success = dictionary.getValueSafe(
success = dictionary.getValue(
constants::renderableplanet::keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
@@ -73,7 +73,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
// TODO: textures need to be replaced by a good system similar to the geometry as soon
// as the requirements are fixed (ab)
std::string texturePath = "";
success = dictionary.getValueSafe("Textures.Color", texturePath);
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = path + "/" + texturePath;

View File

@@ -57,7 +57,7 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
assert(success);
glm::vec2 radius;
success = dictionary.getValueSafe(keyRadius, radius);
success = dictionary.getValue(keyRadius, radius);
if (!success) {
LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '"
<< keyRadius << "'");
@@ -66,7 +66,7 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
_radius = radius;
double segments;
success = dictionary.getValueSafe(keySegments, segments);
success = dictionary.getValue(keySegments, segments);
if (!success) {
LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '"
<< keySegments << "'");

View File

@@ -43,7 +43,7 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary
assert(success);
std::string renderableType;
success = dictionary.getValueSafe(constants::renderable::keyType, renderableType);
success = dictionary.getValue(constants::renderable::keyType, renderableType);
if (!success) {
LERROR("Renderable '" << name << "' did not have key '"
<< constants::renderable::keyType << "'");
@@ -67,7 +67,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary)
setName("renderable");
// get path if available
const bool success = dictionary.getValueSafe(constants::scenegraph::keyPathModule, _relativePath);
const bool success = dictionary.getValue(constants::scenegraph::keyPathModule, _relativePath);
if (success)
_relativePath += ghoul::filesystem::FileSystem::PathSeparator;

View File

@@ -53,7 +53,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
assert(success);
ghoul::Dictionary fieldlines;
success = dictionary.getValueSafe(keyFieldlines, fieldlines);
success = dictionary.getValue(keyFieldlines, fieldlines);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' did not contain a '" <<
keyFieldlines << "' key");
@@ -61,7 +61,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
}
for (const std::string& key : fieldlines.keys()) {
ghoul::Dictionary fieldline;
success = fieldlines.getValueSafe(key, fieldline);
success = fieldlines.getValue(key, fieldline);
if (!success) {
LERROR("Key '" << key << "' in '" << keyFieldlines <<
@@ -71,13 +71,13 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
}
std::string fileName;
fieldline.getValueSafe(keyFilename, fileName);
fieldline.getValue(keyFilename, fileName);
fileName = findPath(fileName);
if (fileName.empty())
LERROR("File not found!");
else {
ghoul::Dictionary hintsDictionary;
fieldline.getValueSafe(keyHints, hintsDictionary);
fieldline.getValue(keyHints, hintsDictionary);
_filenames.push_back(fileName);
_hintsDictionaries.push_back(hintsDictionary);
@@ -85,7 +85,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
}
ghoul::Dictionary shaderDictionary;
success = dictionary.getValueSafe(keyShaders, shaderDictionary);
success = dictionary.getValue(keyShaders, shaderDictionary);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' does not contain a '" <<
keyShaders << "' table");
@@ -93,7 +93,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
}
std::string vshaderpath;
success = shaderDictionary.getValueSafe(keyVertexShader, vshaderpath);
success = shaderDictionary.getValue(keyVertexShader, vshaderpath);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' does not have a '" <<
keyVertexShader << "'");
@@ -102,7 +102,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
vshaderpath = findPath(vshaderpath);
std::string fshaderpath;
success = shaderDictionary.getValueSafe(keyFragmentShader, fshaderpath);
success = shaderDictionary.getValue(keyFragmentShader, fshaderpath);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' does not have a '" <<
keyFragmentShader << "'");
@@ -117,7 +117,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
ShaderCreator sc = OsEng.shaderBuilder();
_fieldlinesProgram = sc.buildShader("FieldlinesProgram", vshaderpath, fshaderpath);
dictionary.getValueSafe("UpdateOnSave", _programUpdateOnSave);
dictionary.getValue("UpdateOnSave", _programUpdateOnSave);
setBoundingSphere(PowerScaledScalar::CreatePSS(5)); // FIXME a non-magic number perhaps
}

View File

@@ -56,7 +56,7 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
assert(success);
_filename = "";
success = dictionary.getValueSafe(constants::renderablevolumegl::keyVolume,
success = dictionary.getValue(constants::renderablevolumegl::keyVolume,
_filename);
if (!success) {
LERROR("Node '" << name << "' did not contain a valid '" <<
@@ -67,12 +67,12 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
LDEBUG("Volume Filename: " << _filename);
dictionary.getValueSafe(constants::renderablevolumegl::keyHints, _hintsDictionary);
dictionary.getValue(constants::renderablevolumegl::keyHints, _hintsDictionary);
_transferFunction = nullptr;
_transferFunctionFile = nullptr;
_transferFunctionPath = "";
success = dictionary.getValueSafe(
success = dictionary.getValue(
constants::renderablevolumegl::keyTransferFunction, _transferFunctionPath);
if (!success) {
LERROR("Node '" << name << "' did not contain a valid '" <<
@@ -83,7 +83,7 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
_transferFunctionFile = new ghoul::filesystem::File(_transferFunctionPath, true);
_samplerFilename = "";
success = dictionary.getValueSafe(constants::renderablevolumegl::keySampler,
success = dictionary.getValue(constants::renderablevolumegl::keySampler,
_samplerFilename);
if (!success) {
LERROR("Node '" << name << "' did not contain a valid '" <<
@@ -93,14 +93,14 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
_samplerFilename = findPath(_samplerFilename);
glm::vec4 scalingVec4(_boxScaling, _w);
success = dictionary.getValueSafe(constants::renderablevolumegl::keyBoxScaling,
success = dictionary.getValue(constants::renderablevolumegl::keyBoxScaling,
scalingVec4);
if (success) {
_boxScaling = scalingVec4.xyz;
_w = scalingVec4.w;
}
else {
success = dictionary.getValueSafe(constants::renderablevolumegl::keyBoxScaling,
success = dictionary.getValue(constants::renderablevolumegl::keyBoxScaling,
_boxScaling);
if (!success) {
LERROR("Node '" << name << "' did not contain a valid '" <<
@@ -109,8 +109,8 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
}
}
dictionary.getValueSafe(constants::renderablevolumegl::keyVolumeName, _volumeName);
dictionary.getValueSafe(constants::renderablevolumegl::keyTransferFunctionName,
dictionary.getValue(constants::renderablevolumegl::keyVolumeName, _volumeName);
dictionary.getValue(constants::renderablevolumegl::keyTransferFunctionName,
_transferFunctionName);
setBoundingSphere(PowerScaledScalar::CreatePSS(glm::length(_boxScaling)*pow(10,_w)));

View File

@@ -466,7 +466,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
std::string&& sceneDescriptionDirectory =
ghoul::filesystem::File(sceneDescriptionFilePath).directoryName();
std::string moduleDirectory(".");
dictionary.getValueSafe(constants::scenegraph::keyPathScene, moduleDirectory);
dictionary.getValue(constants::scenegraph::keyPathScene, moduleDirectory);
// The scene path could either be an absolute or relative path to the description
// paths directory