Commit 325e1c59 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Refs #14988. Naming fixes..

parent 36b8b0f4
......@@ -355,12 +355,12 @@ void Algorithm::lockWorkspaces() {
// First, Write-lock the output workspaces
auto &debugLog = g_log.debug();
for (auto &m_outputWorkspaceProp : m_outputWorkspaceProps) {
Workspace_sptr ws = m_outputWorkspaceProp->getWorkspace();
for (auto &outputWorkspaceProp : m_outputWorkspaceProps) {
Workspace_sptr ws = outputWorkspaceProp->getWorkspace();
if (ws) {
// The workspace property says to do locking,
// AND it has NOT already been write-locked
if (m_outputWorkspaceProp->isLocking() &&
if (outputWorkspaceProp->isLocking() &&
std::find(m_writeLockedWorkspaces.begin(),
m_writeLockedWorkspaces.end(),
ws) == m_writeLockedWorkspaces.end()) {
......@@ -373,12 +373,12 @@ void Algorithm::lockWorkspaces() {
}
// Next read-lock the input workspaces
for (auto &m_inputWorkspaceProp : m_inputWorkspaceProps) {
Workspace_sptr ws = m_inputWorkspaceProp->getWorkspace();
for (auto &inputWorkspaceProp : m_inputWorkspaceProps) {
Workspace_sptr ws = inputWorkspaceProp->getWorkspace();
if (ws) {
// The workspace property says to do locking,
// AND it has NOT already been write-locked
if (m_inputWorkspaceProp->isLocking() &&
if (inputWorkspaceProp->isLocking() &&
std::find(m_writeLockedWorkspaces.begin(),
m_writeLockedWorkspaces.end(),
ws) == m_writeLockedWorkspaces.end()) {
......@@ -458,7 +458,7 @@ bool Algorithm::execute() {
if (!validateProperties()) {
// Reset name on input workspaces to trigger attempt at collection from ADS
const std::vector<Property *> &props = getProperties();
for (auto prop : props) {
for (auto &prop : props) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (wsProp && !(wsProp->getWorkspace())) {
// Setting it's name to the same one it already had
......@@ -1124,12 +1124,12 @@ bool Algorithm::checkGroups() {
// Unroll the groups or single inputs into vectors of workspace
m_groups.clear();
m_groupWorkspaces.clear();
for (auto &m_inputWorkspaceProp : m_inputWorkspaceProps) {
auto *prop = dynamic_cast<Property *>(m_inputWorkspaceProp);
auto *wsGroupProp = dynamic_cast<WorkspaceProperty<WorkspaceGroup> *>(prop);
for (auto inputWorkspaceProp : m_inputWorkspaceProps) {
auto prop = dynamic_cast<Property *>(inputWorkspaceProp);
auto wsGroupProp = dynamic_cast<WorkspaceProperty<WorkspaceGroup> *>(prop);
std::vector<Workspace_sptr> thisGroup;
Workspace_sptr ws = m_inputWorkspaceProp->getWorkspace();
Workspace_sptr ws = inputWorkspaceProp->getWorkspace();
WorkspaceGroup_sptr wsGroup =
boost::dynamic_pointer_cast<WorkspaceGroup>(ws);
......@@ -1231,8 +1231,8 @@ bool Algorithm::processGroups() {
std::vector<WorkspaceGroup_sptr> outGroups;
// ---------- Create all the output workspaces ----------------------------
for (auto &m_pureOutputWorkspaceProp : m_pureOutputWorkspaceProps) {
Property *prop = dynamic_cast<Property *>(m_pureOutputWorkspaceProp);
for (auto &pureOutputWorkspaceProp : m_pureOutputWorkspaceProps) {
Property *prop = dynamic_cast<Property *>(pureOutputWorkspaceProp);
if (prop) {
WorkspaceGroup_sptr outWSGrp = WorkspaceGroup_sptr(new WorkspaceGroup());
outGroups.push_back(outWSGrp);
......
......@@ -149,9 +149,9 @@ void AlgorithmManagerImpl::setMaxAlgorithms(int n) {
*/
IAlgorithm_sptr AlgorithmManagerImpl::getAlgorithm(AlgorithmID id) const {
Mutex::ScopedLock _lock(this->m_managedMutex);
for (const auto &m_managed_alg : m_managed_algs) {
if ((*m_managed_alg).getAlgorithmID() == id)
return m_managed_alg;
for (const auto &managed_alg : m_managed_algs) {
if ((*managed_alg).getAlgorithmID() == id)
return managed_alg;
}
return IAlgorithm_sptr();
}
......@@ -220,9 +220,9 @@ std::vector<IAlgorithm_const_sptr> AlgorithmManagerImpl::runningInstancesOf(
/// Requests cancellation of all running algorithms
void AlgorithmManagerImpl::cancelAll() {
Mutex::ScopedLock _lock(this->m_managedMutex);
for (auto &m_managed_alg : m_managed_algs) {
if (m_managed_alg->isRunning())
m_managed_alg->cancel();
for (auto &managed_alg : m_managed_algs) {
if (managed_alg->isRunning())
managed_alg->cancel();
}
}
......
......@@ -55,15 +55,15 @@ ICatalog_sptr CatalogManagerImpl::getCatalog(const std::string &sessionID) {
if (sessionID.empty()) {
auto composite = boost::make_shared<CompositeCatalog>();
for (auto &m_activeCatalog : m_activeCatalogs) {
composite->add(m_activeCatalog.second);
for (auto &activeCatalog : m_activeCatalogs) {
composite->add(activeCatalog.second);
}
return composite;
}
for (auto &m_activeCatalog : m_activeCatalogs) {
if (sessionID == m_activeCatalog.first->getSessionId())
return m_activeCatalog.second;
for (auto &activeCatalog : m_activeCatalogs) {
if (sessionID == activeCatalog.first->getSessionId())
return activeCatalog.second;
}
// If we reached this point then the session is corrupt/invalid.
......@@ -79,8 +79,8 @@ ICatalog_sptr CatalogManagerImpl::getCatalog(const std::string &sessionID) {
*/
void CatalogManagerImpl::destroyCatalog(const std::string &sessionID) {
if (sessionID.empty()) {
for (auto &m_activeCatalog : m_activeCatalogs) {
m_activeCatalog.second->logout();
for (auto &activeCatalog : m_activeCatalogs) {
activeCatalog.second->logout();
}
m_activeCatalogs.clear();
}
......@@ -100,9 +100,9 @@ void CatalogManagerImpl::destroyCatalog(const std::string &sessionID) {
*/
std::vector<CatalogSession_sptr> CatalogManagerImpl::getActiveSessions() {
std::vector<CatalogSession_sptr> sessions;
for (auto &m_activeCatalog : m_activeCatalogs) {
sessions.push_back(m_activeCatalog.first);
sessions.reserve(m_activeCatalogs.size());
for (auto &activeCatalog : m_activeCatalogs) {
sessions.push_back(activeCatalog.first);
}
return sessions;
......
......@@ -37,8 +37,8 @@ CatalogSession_sptr CompositeCatalog::login(const std::string &username,
* Log the user out of all catalogues in the container.
*/
void CompositeCatalog::logout() {
for (auto &m_catalog : m_catalogs) {
m_catalog->logout();
for (auto &catalog : m_catalogs) {
catalog->logout();
}
}
......@@ -54,8 +54,8 @@ void CompositeCatalog::logout() {
void CompositeCatalog::search(const ICat::CatalogSearchParam &inputs,
ITableWorkspace_sptr &outputws, const int &offset,
const int &limit) {
for (auto &m_catalog : m_catalogs) {
m_catalog->search(inputs, outputws, offset, limit);
for (auto &catalog : m_catalogs) {
catalog->search(inputs, outputws, offset, limit);
}
}
......@@ -66,8 +66,8 @@ void CompositeCatalog::search(const ICat::CatalogSearchParam &inputs,
int64_t CompositeCatalog::getNumberOfSearchResults(
const ICat::CatalogSearchParam &inputs) {
int64_t numberOfSearchResults = 0;
for (auto &m_catalog : m_catalogs) {
numberOfSearchResults += m_catalog->getNumberOfSearchResults(inputs);
for (auto &catalog : m_catalogs) {
numberOfSearchResults += catalog->getNumberOfSearchResults(inputs);
}
return numberOfSearchResults;
}
......@@ -78,8 +78,8 @@ int64_t CompositeCatalog::getNumberOfSearchResults(
* @param outputws :: The workspace to store the results.
*/
void CompositeCatalog::myData(ITableWorkspace_sptr &outputws) {
for (auto &m_catalog : m_catalogs) {
m_catalog->myData(outputws);
for (auto &catalog : m_catalogs) {
catalog->myData(outputws);
}
}
......@@ -91,8 +91,8 @@ void CompositeCatalog::myData(ITableWorkspace_sptr &outputws) {
*/
void CompositeCatalog::getDataSets(const std::string &investigationId,
ITableWorkspace_sptr &outputws) {
for (auto &m_catalog : m_catalogs) {
m_catalog->getDataSets(investigationId, outputws);
for (auto &catalog : m_catalogs) {
catalog->getDataSets(investigationId, outputws);
}
}
......@@ -104,8 +104,8 @@ void CompositeCatalog::getDataSets(const std::string &investigationId,
*/
void CompositeCatalog::getDataFiles(const std::string &investigationId,
ITableWorkspace_sptr &outputws) {
for (auto &m_catalog : m_catalogs) {
m_catalog->getDataFiles(investigationId, outputws);
for (auto &catalog : m_catalogs) {
catalog->getDataFiles(investigationId, outputws);
}
}
......@@ -114,8 +114,8 @@ void CompositeCatalog::getDataFiles(const std::string &investigationId,
* @param instruments :: A reference to the vector to store the results.
*/
void CompositeCatalog::listInstruments(std::vector<std::string> &instruments) {
for (auto &m_catalog : m_catalogs) {
m_catalog->listInstruments(instruments);
for (auto &catalog : m_catalogs) {
catalog->listInstruments(instruments);
}
}
......@@ -125,8 +125,8 @@ void CompositeCatalog::listInstruments(std::vector<std::string> &instruments) {
*/
void CompositeCatalog::listInvestigationTypes(
std::vector<std::string> &invstTypes) {
for (auto &m_catalog : m_catalogs) {
m_catalog->listInvestigationTypes(invstTypes);
for (auto &catalog : m_catalogs) {
catalog->listInvestigationTypes(invstTypes);
}
}
......@@ -134,8 +134,8 @@ void CompositeCatalog::listInvestigationTypes(
* Keep each catalog session alive in the container.
*/
void CompositeCatalog::keepAlive() {
for (auto &m_catalog : m_catalogs) {
m_catalog->keepAlive();
for (auto &catalog : m_catalogs) {
catalog->keepAlive();
}
}
}
......
......@@ -368,7 +368,7 @@ void CompositeFunction::checkFunction() {
std::vector<IFunction_sptr> functions(m_functions.begin(), m_functions.end());
m_functions.clear();
for (auto f : functions) {
for (auto &f : functions) {
CompositeFunction_sptr cf =
boost::dynamic_pointer_cast<CompositeFunction>(f);
if (cf)
......
......@@ -73,8 +73,8 @@ void ExperimentInfo::copyExperimentInfoFrom(const ExperimentInfo *other) {
if (other->m_moderatorModel)
m_moderatorModel = other->m_moderatorModel->clone();
m_choppers.clear();
for (const auto &m_chopper : other->m_choppers) {
m_choppers.push_back(m_chopper->clone());
for (const auto &chopper : other->m_choppers) {
m_choppers.push_back(chopper->clone());
}
}
......
......@@ -360,8 +360,8 @@ void Expression::logPrint(const std::string &pads) const {
std::string myPads = pads + " ";
if (m_terms.size()) {
std::cerr << myPads << m_op << '[' << m_funct << ']' << "(" << '\n';
for (const auto &m_term : m_terms)
m_term.logPrint(myPads);
for (const auto &term : m_terms)
term.logPrint(myPads);
std::cerr << myPads << ")" << '\n';
} else
std::cerr << myPads << m_op << m_funct << '\n';
......@@ -452,11 +452,11 @@ std::string Expression::str() const {
if (m_terms.size()) {
if (brackets)
res << '(';
for (const auto &m_term : m_terms) {
res << m_term.operator_name();
size_t prec1 = op_prec(m_term.m_funct);
for (const auto &term : m_terms) {
res << term.operator_name();
size_t prec1 = op_prec(term.m_funct);
bool isItUnary = false;
if (m_term.size() == 1 && is_unary(m_term.m_funct)) {
if (term.size() == 1 && is_unary(term.m_funct)) {
prec1 = 0; // unary operator
isItUnary = true;
}
......@@ -465,7 +465,7 @@ std::string Expression::str() const {
res << '(';
if (isItUnary)
res << ' ';
res << m_term.str();
res << term.str();
if (bk)
res << ')';
}
......
......@@ -249,8 +249,8 @@ void FunctionFactoryImpl::inputError(const std::string &str) const {
void FunctionFactoryImpl::addConstraints(IFunction_sptr fun,
const Expression &expr) const {
if (expr.name() == ",") {
for (const auto &i : expr) {
addConstraint(fun, i);
for (const auto &constraint : expr) {
addConstraint(fun, constraint);
}
} else {
addConstraint(fun, expr);
......@@ -279,8 +279,8 @@ void FunctionFactoryImpl::addTies(IFunction_sptr fun,
if (expr.name() == "=") {
addTie(fun, expr);
} else if (expr.name() == ",") {
for (const auto &i : expr) {
addTie(fun, i);
for (const auto &constraint : expr) {
addTie(fun, constraint);
}
}
}
......
......@@ -18,18 +18,20 @@ Kernel::Logger g_log("GridDomain");
size_t GridDomain::size() const {
if (!m_grids.size())
return 0;
size_t n = 1;
for (const auto &m_grid : m_grids)
n *= m_grid->size();
return n;
else
return std::accumulate(
m_grids.begin(), m_grids.end(), size_t{1},
[](size_t n, const boost::shared_ptr<GridDomain> &grid) {
return n * grid->size();
});
}
/// number of dimensions of the grid
size_t GridDomain::nDimensions() {
size_t n = 0;
for (auto &m_grid : m_grids)
n += m_grid->nDimensions();
return n;
return std::accumulate(m_grids.begin(), m_grids.end(), size_t{0},
[](size_t n, boost::shared_ptr<GridDomain> &grid) {
return n + grid->nDimensions();
});
}
/* return item of member m_grids
......@@ -46,8 +48,8 @@ GridDomain_sptr GridDomain::getGrid(size_t index) {
}
void GridDomain::reScale(const std::string &scaling) {
for (auto &m_grid : m_grids)
m_grid->reScale(scaling);
for (auto &grid : m_grids)
grid->reScale(scaling);
}
} // namespace API
......
......@@ -1000,8 +1000,8 @@ void IFunction::setAttributeValue(const std::string &attName,
std::vector<std::string> IFunction::getAttributeNames() const {
std::vector<std::string> names(nAttributes(), "");
size_t index(0);
for (const auto &m_attr : m_attrs) {
names[index] = m_attr.first;
for (const auto &attr : m_attrs) {
names[index] = attr.first;
++index;
}
return names;
......
......@@ -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_alias : m_aliases) {
if (m_alias.second == i)
return m_alias.first;
for (const auto &alias : m_aliases) {
if (alias.second == i)
return alias.first;
}
return CompositeFunction::parameterName(i);
}
......
......@@ -2,17 +2,17 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/JointDomain.h"
#include <numeric>
namespace Mantid {
namespace API {
/// Return the overall size the domain which is a sum of sizes of the
/// member domains.
size_t JointDomain::size() const {
size_t n = 0;
for (const auto &m_domain : m_domains) {
n += (*m_domain).size();
};
return n;
return std::accumulate(m_domains.begin(), m_domains.end(), size_t{0},
[](size_t n, const FunctionDomain_sptr &domain) {
return n + domain->size();
});
}
/// Return the number of parts in the domain
size_t JointDomain::getNParts() const { return m_domains.size(); }
......
......@@ -131,11 +131,17 @@ MDGeometry::getDimension(size_t index) const {
*/
boost::shared_ptr<const Mantid::Geometry::IMDDimension>
MDGeometry::getDimensionWithId(std::string id) const {
for (const auto &m_dimension : m_dimensions)
if (m_dimension->getDimensionId() == id)
return m_dimension;
throw std::invalid_argument("Dimension tagged " + id +
" was not found in the Workspace");
auto dimension = std::find_if(
m_dimensions.begin(), m_dimensions.end(),
[&id](
const boost::shared_ptr<const Mantid::Geometry::IMDDimension> &dim) {
return dim->getDimensionId() == id;
});
if (dimension != m_dimensions.end())
return *dimension;
else
throw std::invalid_argument("Dimension tagged " + id +
" was not found in the Workspace");
}
// --------------------------------------------------------------------------------------------
......@@ -280,14 +286,11 @@ void MDGeometry::setBasisVector(size_t index, const Mantid::Kernel::VMD &vec) {
* @return True ONLY if ALL the basis vectors have been normalized.
*/
bool MDGeometry::allBasisNormalized() const {
bool allNormalized = true;
for (const auto &m_basisVector : m_basisVectors) {
if (m_basisVector.length() != 1.0) {
allNormalized = false;
break;
}
}
return allNormalized;
auto normalized = std::find_if(m_basisVectors.begin(), m_basisVectors.end(),
[](const Mantid::Kernel::VMD &basisVector) {
return basisVector.length() != 1.0;
});
return normalized == m_basisVectors.end();
}
//---------------------------------------------------------------------------------------------------
......
......@@ -78,8 +78,8 @@ MatrixWorkspace::MatrixWorkspace(const MatrixWorkspace &other)
// RJT, 3/10/07: The Analysis Data Service needs to be able to delete
// workspaces, so I moved this from protected to public.
MatrixWorkspace::~MatrixWorkspace() {
for (auto &m_axis : m_axes) {
delete m_axis;
for (auto &axis : m_axes) {
delete axis;
}
}
......@@ -469,8 +469,8 @@ detid2index_map MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(
map[*detList.begin()] = workspaceIndex;
} else {
// Allow multiple detectors per workspace index
for (auto it : detList)
map[it] = workspaceIndex;
for (auto det : detList)
map[det] = workspaceIndex;
}
// Ignore if the detector list is empty.
......@@ -519,12 +519,12 @@ void MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(
// Allow multiple detectors per workspace index, or,
// If only one is allowed, then this has thrown already
for (auto it : detList) {
int index = it + offset;
for (auto det : detList) {
int index = det + offset;
if (index < 0 || index >= outSize) {
g_log.debug() << "MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
"): detector ID found (" << it
<< " at workspace index " << workspaceIndex
"): detector ID found ("
<< det << " at workspace index " << workspaceIndex
<< ") is invalid." << std::endl;
} else
// Save it at that point.
......@@ -602,11 +602,11 @@ void MatrixWorkspace::getIndicesFromDetectorIDs(
indexList.clear();
indexList.reserve(detIdList.size());
for (int j : detIdList) {
auto wsIndices = detectorIDtoWSIndices.find(j);
for (const auto detId : detIdList) {
auto wsIndices = detectorIDtoWSIndices.find(detId);
if (wsIndices != detectorIDtoWSIndices.end()) {
for (auto it : wsIndices->second) {
indexList.push_back(it);
for (auto index : wsIndices->second) {
indexList.push_back(index);
}
}
}
......@@ -627,13 +627,13 @@ void MatrixWorkspace::getSpectraFromDetectorIDs(
spectraList.clear();
// Try every detector in the list
for (int it : detIdList) {
for (int detId : detIdList) {
bool foundDet = false;
specid_t foundSpecNum = 0;
// Go through every histogram
for (size_t i = 0; i < this->getNumberHistograms(); i++) {
if (this->getSpectrum(i)->hasDetectorID(it)) {
if (this->getSpectrum(i)->hasDetectorID(detId)) {
foundDet = true;
foundSpecNum = this->getSpectrum(i)->getSpectrumNo();
break;
......@@ -1011,11 +1011,11 @@ void MatrixWorkspace::maskWorkspaceIndex(const std::size_t index) {
spec->clearData();
const std::set<detid_t> dets = spec->getDetectorIDs();
for (auto iter : dets) {
for (auto detId : dets) {
try {
if (const Geometry::Detector *det =
dynamic_cast<const Geometry::Detector *>(
sptr_instrument->getDetector(iter).get())) {
sptr_instrument->getDetector(detId).get())) {
m_parmap->addBool(det, "masked", true); // Thread-safe method
}
} catch (Kernel::Exception::NotFoundError &) {
......
......@@ -44,9 +44,9 @@ void MultiDomainFunction::setDomainIndices(
*/
void MultiDomainFunction::countNumberOfDomains() {
std::set<size_t> dSet;
for (auto &m_domain : m_domains) {
if (m_domain.second.size()) {
dSet.insert(m_domain.second.begin(), m_domain.second.end());
for (auto &domain : m_domains) {
if (domain.second.size()) {
dSet.insert(domain.second.begin(), domain.second.end());
}
}
m_nDomains = dSet.size();
......@@ -319,12 +319,12 @@ MultiDomainFunction::createEquivalentFunctions() const {
std::vector<size_t> domains;
getDomainIndices(iFun, nDomains, domains);
for (auto j : domains) {
CompositeFunction_sptr cf = compositeFunctions[j];
for (auto domainIndex : domains) {
CompositeFunction_sptr cf = compositeFunctions[domainIndex];
if (!cf) {
// create a composite function for each domain
cf = CompositeFunction_sptr(new CompositeFunction());
compositeFunctions[j] = cf;
compositeFunctions[domainIndex] = cf;
}
// add copies of all functions applied to j-th domain to a single
// compositefunction
......
......@@ -97,9 +97,10 @@ uint16_t MultipleExperimentInfos::getNumExperimentInfo() const {
void MultipleExperimentInfos::copyExperimentInfos(
const MultipleExperimentInfos &other) {
m_expInfos.clear();
m_expInfos.reserve(other.m_expInfos.size());
// Do a deep copy of ExperimentInfo's
for (const auto &m_expInfo : other.m_expInfos) {
ExperimentInfo_sptr copy(new ExperimentInfo(*m_expInfo));
for (const auto &expInfo : other.m_expInfos) {
ExperimentInfo_sptr copy(new ExperimentInfo(*expInfo));
m_expInfos.push_back(copy);
}
}
......
......@@ -21,12 +21,12 @@ Kernel::Logger g_log("ParamFunction");
/// Destructor
ParamFunction::~ParamFunction() {
for (auto &m_tie : m_ties) {
delete m_tie;
for (auto &tie : m_ties) {
delete tie;
}
m_ties.clear();
for (auto &m_constraint : m_constraints) {
delete m_constraint;
for (auto &constraint : m_constraints) {
delete constraint;
}
m_constraints.clear();
}
......@@ -99,7 +99,6 @@ double ParamFunction::getParameter(size_t i) const {
void ParamFunction::setParameter(const std::string &name, const double &value,
bool explicitlySet) {
std::string ucName(name);
// std::transform(name.begin(), name.end(), ucName.begin(), toupper);
std::vector<std::string>::const_iterator it =