Commit 2357c748 authored by David Fairbrother's avatar David Fairbrother
Browse files

Clang-tidy pass by ref

Runs clang-tidy pass by ref across the codebase to fix-up various
warnings we are seeing in cppcheck
parent 08088625
......@@ -406,7 +406,7 @@ void AlgorithmFactoryImpl::fillHiddenCategories(
* @returns the name of the algroithm
*/
const std::string AlgorithmFactoryImpl::extractAlgName(
const boost::shared_ptr<IAlgorithm> alg) const {
const boost::shared_ptr<IAlgorithm> &alg) const {
return alg->name();
}
......@@ -415,7 +415,7 @@ const std::string AlgorithmFactoryImpl::extractAlgName(
* @returns the version of the algroithm
*/
int AlgorithmFactoryImpl::extractAlgVersion(
const boost::shared_ptr<IAlgorithm> alg) const {
const boost::shared_ptr<IAlgorithm> &alg) const {
return alg->version();
}
......
......@@ -21,6 +21,7 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <sstream>
#include <utility>
namespace Mantid {
namespace API {
......@@ -85,7 +86,7 @@ AlgorithmHistory::AlgorithmHistory(const std::string &name, int vers,
std::size_t uexeccount)
: m_name(name), m_version(vers), m_executionDate(start),
m_executionDuration(duration), m_execCount(uexeccount),
m_childHistories(), m_uuid(uuid) {}
m_childHistories(), m_uuid(std::move(uuid)) {}
/**
* Set the history properties for an algorithm pointer
......@@ -162,7 +163,7 @@ void AlgorithmHistory::addProperty(const std::string &name,
/** Add a child algorithm history to history
* @param childHist :: The child history
*/
void AlgorithmHistory::addChildHistory(AlgorithmHistory_sptr childHist) {
void AlgorithmHistory::addChildHistory(const AlgorithmHistory_sptr &childHist) {
// Don't copy one's own history onto oneself
if (this == &(*childHist)) {
return;
......
......@@ -7,8 +7,10 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/AlgorithmObserver.h"
#include <utility>
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AlgorithmObserver.h"
namespace Mantid {
namespace API {
......@@ -26,13 +28,13 @@ AlgorithmObserver::AlgorithmObserver()
alg.
@param alg :: Algorithm to be observed
*/
AlgorithmObserver::AlgorithmObserver(IAlgorithm_const_sptr alg)
AlgorithmObserver::AlgorithmObserver(const IAlgorithm_const_sptr &alg)
: m_progressObserver(*this, &AlgorithmObserver::_progressHandle),
m_startObserver(*this, &AlgorithmObserver::_startHandle),
m_finishObserver(*this, &AlgorithmObserver::_finishHandle),
m_errorObserver(*this, &AlgorithmObserver::_errorHandle),
m_startingObserver(*this, &AlgorithmObserver::_startingHandle) {
observeAll(alg);
observeAll(std::move(alg));
}
/// Virtual destructor
......@@ -41,7 +43,7 @@ AlgorithmObserver::~AlgorithmObserver() = default;
/** Connect to algorithm alg and observe all its notifications
@param alg :: Algorithm to be observed
*/
void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::observeAll(const IAlgorithm_const_sptr &alg) {
alg->addObserver(m_progressObserver);
alg->addObserver(m_startObserver);
alg->addObserver(m_finishObserver);
......@@ -51,7 +53,7 @@ void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) {
/** Connect to algorithm alg and observe its progress notification
@param alg :: Algorithm to be observed
*/
void AlgorithmObserver::observeProgress(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::observeProgress(const IAlgorithm_const_sptr &alg) {
alg->addObserver(m_progressObserver);
}
......@@ -65,21 +67,21 @@ void AlgorithmObserver::observeStarting() {
/** Connect to algorithm alg and observe its start notification
@param alg :: Algorithm to be observed
*/
void AlgorithmObserver::observeStart(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::observeStart(const IAlgorithm_const_sptr &alg) {
alg->addObserver(m_startObserver);
}
/** Connect to algorithm alg and observe its finish notification
@param alg :: Algorithm to be observed
*/
void AlgorithmObserver::observeFinish(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::observeFinish(const IAlgorithm_const_sptr &alg) {
alg->addObserver(m_finishObserver);
}
/** Connect to algorithm alg and observe its error notification
@param alg :: Algorithm to be observed
*/
void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::observeError(const IAlgorithm_const_sptr &alg) {
alg->addObserver(m_errorObserver);
}
......@@ -87,7 +89,7 @@ void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) {
inherited classes.
@param alg :: Algorithm to be disconnected
*/
void AlgorithmObserver::stopObserving(IAlgorithm_const_sptr alg) {
void AlgorithmObserver::stopObserving(const IAlgorithm_const_sptr &alg) {
this->stopObserving(alg.get());
}
......
......@@ -12,6 +12,8 @@
#include <json/value.h>
#include <utility>
namespace Mantid {
namespace API {
......@@ -29,8 +31,8 @@ namespace API {
AlgorithmProperty::AlgorithmProperty(const std::string &propName,
Kernel::IValidator_sptr validator,
unsigned int direction)
: Kernel::PropertyWithValue<HeldType>(propName, HeldType(), validator,
direction),
: Kernel::PropertyWithValue<HeldType>(propName, HeldType(),
std::move(validator), direction),
m_algmStr() {}
/**
......
......@@ -21,7 +21,7 @@ namespace Mantid {
namespace API {
/// Constructor
AlgorithmProxy::AlgorithmProxy(Algorithm_sptr alg)
AlgorithmProxy::AlgorithmProxy(const Algorithm_sptr &alg)
: PropertyManagerOwner(),
m_executeAsync(new Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy>(
this, &AlgorithmProxy::executeAsyncImpl)),
......
......@@ -10,8 +10,9 @@ namespace Mantid {
namespace API {
template <>
std::string checkForMandatoryInstrumentDefault(
Mantid::API::Algorithm *const alg, std::string propName,
Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) {
Mantid::API::Algorithm *const alg, const std::string &propName,
const Mantid::Geometry::Instrument_const_sptr &instrument,
const std::string &idf_name) {
auto algProperty = alg->getPointerToProperty(propName);
if (algProperty->isDefault()) {
auto defaults = instrument->getStringParameter(idf_name);
......@@ -28,8 +29,9 @@ std::string checkForMandatoryInstrumentDefault(
template <>
boost::optional<std::string> checkForOptionalInstrumentDefault(
Mantid::API::Algorithm *const alg, std::string propName,
Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) {
Mantid::API::Algorithm *const alg, const std::string &propName,
const Mantid::Geometry::Instrument_const_sptr &instrument,
const std::string &idf_name) {
auto algProperty = alg->getPointerToProperty(propName);
if (algProperty->isDefault()) {
auto defaults = instrument->getStringParameter(idf_name);
......
......@@ -296,8 +296,9 @@ void BoxController::clearFileBacked() {
*@param fileName -- if newFileIO comes without opened file, this is the file
*name to open for the file based IO operations
*/
void BoxController::setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO,
const std::string &fileName) {
void BoxController::setFileBacked(
const boost::shared_ptr<IBoxControllerIO> &newFileIO,
const std::string &fileName) {
if (!newFileIO->isOpened())
newFileIO->openFile(fileName, "w");
......
......@@ -16,7 +16,7 @@ CompositeCatalog::CompositeCatalog() : m_catalogs() {}
* Add a catalog to the catalog container.
* @param catalog :: The catalog to add to the container.
*/
void CompositeCatalog::add(const ICatalog_sptr catalog) {
void CompositeCatalog::add(const ICatalog_sptr &catalog) {
m_catalogs.emplace_back(catalog);
}
......
......@@ -21,7 +21,7 @@ namespace API {
* @param ws :: Pointer to a workspace.
* @param maxDomainSize :: The maximum size each domain can have.
*/
CompositeDomainMD::CompositeDomainMD(IMDWorkspace_const_sptr ws,
CompositeDomainMD::CompositeDomainMD(const IMDWorkspace_const_sptr &ws,
size_t maxDomainSize)
: m_iterator(ws->createIterator()) {
m_totalSize = m_iterator->getDataSize();
......
......@@ -19,6 +19,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/shared_array.hpp>
#include <sstream>
#include <utility>
namespace Mantid {
namespace API {
......@@ -468,21 +469,21 @@ void CompositeFunction::removeFunction(size_t i) {
* a member of this composite function nothing happens
* @param f_new :: A pointer to the new function
*/
void CompositeFunction::replaceFunctionPtr(const IFunction_sptr f_old,
IFunction_sptr f_new) {
void CompositeFunction::replaceFunctionPtr(const IFunction_sptr &f_old,
const IFunction_sptr &f_new) {
std::vector<IFunction_sptr>::const_iterator it =
std::find(m_functions.begin(), m_functions.end(), f_old);
if (it == m_functions.end())
return;
std::vector<IFunction_sptr>::difference_type iFun = it - m_functions.begin();
replaceFunction(iFun, f_new);
replaceFunction(iFun, std::move(f_new));
}
/** Replace a function with a new one. The old function is deleted.
* @param i :: The index of the function to replace
* @param f :: A pointer to the new function
*/
void CompositeFunction::replaceFunction(size_t i, IFunction_sptr f) {
void CompositeFunction::replaceFunction(size_t i, const IFunction_sptr &f) {
if (i >= nFunctions()) {
throw std::out_of_range("Function index (" + std::to_string(i) +
") out of range (" + std::to_string(nFunctions()) +
......
......@@ -19,6 +19,8 @@
#include "MantidKernel/System.h"
#include "Poco/Path.h"
#include <stdexcept>
#include <utility>
#ifdef MPI_BUILD
#include <boost/mpi.hpp>
#endif
......@@ -135,7 +137,7 @@ void GenericDataProcessorAlgorithm<Base>::mapPropertyName(
*/
template <class Base>
void GenericDataProcessorAlgorithm<Base>::copyProperty(
API::Algorithm_sptr alg, const std::string &name) {
const API::Algorithm_sptr &alg, const std::string &name) {
if (!alg->existsProperty(name)) {
std::stringstream msg;
msg << "Algorithm \"" << alg->name() << "\" does not have property \""
......@@ -232,7 +234,7 @@ GenericDataProcessorAlgorithm<Base>::loadChunk(const size_t rowIndex) {
template <class Base>
Workspace_sptr
GenericDataProcessorAlgorithm<Base>::assemble(Workspace_sptr partialWS) {
Workspace_sptr outputWS = partialWS;
Workspace_sptr outputWS = std::move(partialWS);
#ifdef MPI_BUILD
IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces");
gatherAlg->setLogging(true);
......
......@@ -30,8 +30,9 @@ double getQSign() {
* @param instrument :: the instrument to find detectors in
* @param detInfo :: the Geometry::DetectorInfo object for this instrument
*/
DetectorSearcher::DetectorSearcher(Geometry::Instrument_const_sptr instrument,
const Geometry::DetectorInfo &detInfo)
DetectorSearcher::DetectorSearcher(
const Geometry::Instrument_const_sptr &instrument,
const Geometry::DetectorInfo &detInfo)
: m_usingFullRayTrace(instrument->containsRectDetectors() ==
Geometry::Instrument::ContainsState::Full),
m_crystallography_convention(getQSign()), m_detInfo(detInfo),
......
......@@ -711,7 +711,7 @@ double ExperimentInfo::getEFixed(const detid_t detID) const {
* @return The current efixed value
*/
double ExperimentInfo::getEFixed(
const boost::shared_ptr<const Geometry::IDetector> detector) const {
const boost::shared_ptr<const Geometry::IDetector> &detector) const {
populateIfNotLoaded();
Kernel::DeltaEMode::Type emode = getEMode();
if (emode == Kernel::DeltaEMode::Direct) {
......
......@@ -22,7 +22,7 @@ size_t FunctionDomainGeneral::size() const {
size_t FunctionDomainGeneral::columnCount() const { return m_columns.size(); }
/// Add a new column. All columns must have the same size.
void FunctionDomainGeneral::addColumn(boost::shared_ptr<Column> column) {
void FunctionDomainGeneral::addColumn(const boost::shared_ptr<Column> &column) {
if (!column) {
throw std::runtime_error(
"Cannot add null column to FunctionDomainGeneral.");
......
......@@ -21,8 +21,8 @@ namespace API {
* @param start :: Index of the first iterator in this domain.
* @param length :: Size of this domain. If 0 use all workspace.
*/
FunctionDomainMD::FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start,
size_t length)
FunctionDomainMD::FunctionDomainMD(const IMDWorkspace_const_sptr &ws,
size_t start, size_t length)
: m_iterator(ws->createIterator()), m_startIndex(start), m_currentIndex(0),
m_justReset(true), m_workspace(ws) {
size_t dataSize = m_iterator->getDataSize();
......
......@@ -271,7 +271,7 @@ void FunctionFactoryImpl::inputError(const std::string &str) const {
* separated by commas ','
* and enclosed in brackets "(...)" .
*/
void FunctionFactoryImpl::addConstraints(IFunction_sptr fun,
void FunctionFactoryImpl::addConstraints(const IFunction_sptr &fun,
const Expression &expr) const {
if (expr.name() == ",") {
for (auto it = expr.begin(); it != expr.end(); ++it) {
......@@ -305,7 +305,7 @@ void FunctionFactoryImpl::addConstraints(IFunction_sptr fun,
* @param fun :: The function
* @param expr :: The constraint expression.
*/
void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun,
void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun,
const Expression &expr) const {
auto c = std::unique_ptr<IConstraint>(
ConstraintFactory::Instance().createInitialized(fun.get(), expr));
......@@ -319,7 +319,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun,
* @param constraint_expr :: The constraint expression.
* @param penalty_expr :: The penalty expression.
*/
void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun,
void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun,
const Expression &constraint_expr,
const Expression &penalty_expr) const {
auto c = std::unique_ptr<IConstraint>(
......@@ -335,7 +335,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun,
* @param expr :: The tie expression: either parName = TieString or a list
* of name = string pairs
*/
void FunctionFactoryImpl::addTies(IFunction_sptr fun,
void FunctionFactoryImpl::addTies(const IFunction_sptr &fun,
const Expression &expr) const {
if (expr.name() == "=") {
addTie(fun, expr);
......@@ -350,7 +350,7 @@ void FunctionFactoryImpl::addTies(IFunction_sptr fun,
* @param fun :: The function
* @param expr :: The tie expression: parName = TieString
*/
void FunctionFactoryImpl::addTie(IFunction_sptr fun,
void FunctionFactoryImpl::addTie(const IFunction_sptr &fun,
const Expression &expr) const {
if (expr.size() > 1) { // if size > 2 it is interpreted as setting a tie (last
// expr.term) to multiple parameters, e.g
......
......@@ -4,6 +4,8 @@
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include <utility>
#include "MantidAPI/FunctionGenerator.h"
#include "MantidAPI/IConstraint.h"
#include "MantidAPI/ParameterTie.h"
......@@ -14,7 +16,7 @@ namespace API {
using namespace Kernel;
/// Constructor
FunctionGenerator::FunctionGenerator(IFunction_sptr source)
FunctionGenerator::FunctionGenerator(const IFunction_sptr &source)
: m_source(source), m_dirty(true) {
if (source) {
m_nOwnParams = source->nParams();
......@@ -27,7 +29,7 @@ void FunctionGenerator::init() {}
/// Set the source function
/// @param source :: New source function.
void FunctionGenerator::setSource(IFunction_sptr source) const {
m_source = source;
m_source = std::move(source);
}
/// Set i-th parameter
......
......@@ -17,7 +17,7 @@ namespace Mantid {
namespace API {
void GridDomain1D::initialize(double &startX, double &endX, size_t &n,
const std::string scaling) {
const std::string &scaling) {
m_points.resize(n);
m_points.front() = startX;
m_points.back() = endX;
......
......@@ -16,6 +16,7 @@
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeList.h>
#include <boost/make_shared.hpp>
#include <utility>
using namespace Poco::XML;
......@@ -27,7 +28,7 @@ namespace API {
* @param instrument :: [input] Instrument
*/
GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument)
: m_instrument(instrument) {}
: m_instrument(std::move(instrument)) {}
/** Constructor with field direction
* @param instrument :: [input] Instrument
......@@ -35,7 +36,8 @@ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument)
*/
GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument,
const std::string &mainFieldDirection)
: m_instrument(instrument), m_mainFieldDirection(mainFieldDirection) {}
: m_instrument(std::move(instrument)),
m_mainFieldDirection(mainFieldDirection) {}
//----------------------------------------------------------------------------------------------
/** Destructor
......@@ -248,7 +250,7 @@ boost::shared_ptr<Grouping> GroupingLoader::getDummyGrouping() {
* Construct a Grouping from a table
* @param table :: [input] Table to construct from
*/
Grouping::Grouping(ITableWorkspace_sptr table) {
Grouping::Grouping(const ITableWorkspace_sptr &table) {
for (size_t row = 0; row < table->rowCount(); ++row) {
std::vector<int> detectors = table->cell<std::vector<int>>(row, 0);
......
......@@ -7,13 +7,15 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <utility>
#include "MantidAPI/HistoryItem.h"
namespace Mantid {
namespace API {
HistoryItem::HistoryItem(AlgorithmHistory_const_sptr algHist)
: m_algorithmHistory(algHist), m_unrolled(false) {}
: m_algorithmHistory(std::move(algHist)), m_unrolled(false) {}
} // namespace API
} // namespace Mantid
Markdown is supported
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