Commit 561c98fa authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Refs #14988. Started making changes suggested by Simon.

parent f94132a9
......@@ -91,7 +91,7 @@ protected:
private:
/// Keep paramater aliases
std::map<std::string, size_t> m_alias;
std::map<std::string, size_t> m_aliases;
};
} // namespace API
......
......@@ -234,13 +234,8 @@ const std::vector<std::string> Algorithm::workspaceMethodOn() const {
WORKSPACE_TYPES_SEPARATOR,
Poco::StringTokenizer::TOK_TRIM |
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
std::vector<std::string> res;
res.reserve(tokenizer.count());
for (const auto &iter : tokenizer) {
res.push_back(iter);
}
return res;
return std::vector<std::string>(tokenizer.begin(), tokenizer.end());
}
/**
......@@ -405,13 +400,13 @@ void Algorithm::unlockWorkspaces() {
if (this->isChild())
return;
auto &debugLog = g_log.debug();
for (auto ws : m_writeLockedWorkspaces) {
for (auto &ws : m_writeLockedWorkspaces) {
if (ws) {
debugLog << "Unlocking " << ws->getName() << std::endl;
ws->getLock()->unlock();
}
}
for (auto ws : m_readLockedWorkspaces) {
for (auto &ws : m_readLockedWorkspaces) {
if (ws) {
debugLog << "Unlocking " << ws->getName() << std::endl;
ws->getLock()->unlock();
......
......@@ -62,9 +62,8 @@ std::string CompositeFunction::asString() const {
getAttribute("NumDeriv").asBool() == true) {
ostr << "composite=" << name();
std::vector<std::string> attr = this->getAttributeNames();
for (auto &i : attr) {
std::string attName = i;
std::string attValue = this->getAttribute(i).value();
for (const auto &attName : attr) {
std::string attValue = this->getAttribute(attName).value();
if (!attValue.empty()) {
ostr << ',' << attName << '=' << attValue;
}
......
......@@ -159,9 +159,8 @@ std::string IFunction::asString() const {
ostr << "name=" << this->name();
// print the attributes
std::vector<std::string> attr = this->getAttributeNames();
for (auto &i : attr) {
std::string attName = i;
std::string attValue = this->getAttribute(i).value();
for (const auto &attName : attr) {
std::string attValue = this->getAttribute(attName).value();
if (!attValue.empty() && attValue != "\"\"") {
ostr << ',' << attName << '=' << attValue;
}
......
......@@ -37,8 +37,8 @@ void ImmutableCompositeFunction::addFunction(IFunction *fun) {
void ImmutableCompositeFunction::setParameter(const std::string &name,
const double &value,
bool explicitlySet) {
auto alias = m_alias.find(name);
if (alias != m_alias.end()) {
auto alias = m_aliases.find(name);
if (alias != m_aliases.end()) {
CompositeFunction::setParameter(alias->second, value, explicitlySet);
} else {
CompositeFunction::setParameter(name, value, explicitlySet);
......@@ -52,8 +52,8 @@ void ImmutableCompositeFunction::setParameter(const std::string &name,
*/
void ImmutableCompositeFunction::setParameterDescription(
const std::string &name, const std::string &description) {
auto alias = m_alias.find(name);
if (alias != m_alias.end()) {
auto alias = m_aliases.find(name);
if (alias != m_aliases.end()) {
CompositeFunction::setParameterDescription(alias->second, description);
} else {
CompositeFunction::setParameterDescription(name, description);
......@@ -66,8 +66,8 @@ void ImmutableCompositeFunction::setParameterDescription(
* @return :: The parameter value.
*/
double ImmutableCompositeFunction::getParameter(const std::string &name) const {
auto alias = m_alias.find(name);
if (alias != m_alias.end()) {
auto alias = m_aliases.find(name);
if (alias != m_aliases.end()) {
return CompositeFunction::getParameter(alias->second);
}
return CompositeFunction::getParameter(name);
......@@ -79,8 +79,8 @@ double ImmutableCompositeFunction::getParameter(const std::string &name) const {
*/
size_t
ImmutableCompositeFunction::parameterIndex(const std::string &name) const {
auto alias = m_alias.find(name);
if (alias != m_alias.end()) {
auto alias = m_aliases.find(name);
if (alias != m_aliases.end()) {
return alias->second;
}
return CompositeFunction::parameterIndex(name);
......@@ -90,9 +90,9 @@ ImmutableCompositeFunction::parameterIndex(const std::string &name) const {
* Returns the alias or name of parameter i
*/
std::string ImmutableCompositeFunction::parameterName(size_t i) const {
for (const auto &m_alia : m_alias) {
if (m_alia.second == i)
return m_alia.first;
for (const auto &m_alias : m_aliases) {
if (m_alias.second == i)
return m_alias.first;
}
return CompositeFunction::parameterName(i);
}
......@@ -107,10 +107,10 @@ std::string ImmutableCompositeFunction::parameterName(size_t i) const {
void ImmutableCompositeFunction::setAlias(const std::string &parName,
const std::string &alias) {
// make sure the alias is unique
if (m_alias.count(alias) > 0) {
if (m_aliases.count(alias) > 0) {
throw Kernel::Exception::ExistsError("ImmutableCompositeFunction", alias);
}
m_alias[alias] = CompositeFunction::parameterIndex(parName);
m_aliases[alias] = CompositeFunction::parameterIndex(parName);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment