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
......@@ -288,7 +288,7 @@ public:
const std::string &name, const double startProgress = -1.,
const double endProgress = -1., const bool enableLogging = true,
const int &version = -1);
void setupAsChildAlgorithm(boost::shared_ptr<Algorithm> algorithm,
void setupAsChildAlgorithm(const boost::shared_ptr<Algorithm> &algorithm,
const double startProgress = -1.,
const double endProgress = -1.,
const bool enableLogging = true);
......
......@@ -129,9 +129,9 @@ private:
/// Extract the name of an algorithm
const std::string
extractAlgName(const boost::shared_ptr<IAlgorithm> alg) const;
extractAlgName(const boost::shared_ptr<IAlgorithm> &alg) const;
/// Extract the version of an algorithm
int extractAlgVersion(const boost::shared_ptr<IAlgorithm> alg) const;
int extractAlgVersion(const boost::shared_ptr<IAlgorithm> &alg) const;
/// Create an algorithm object with the specified name
boost::shared_ptr<Algorithm> createAlgorithm(const std::string &name,
......
......@@ -63,7 +63,7 @@ public:
bool isdefault, const unsigned int &direction = 99);
/// add a child algorithm history record to this history object
void addChildHistory(AlgorithmHistory_sptr childHist);
void addChildHistory(const AlgorithmHistory_sptr &childHist);
// get functions
/// get name of algorithm in history const
const std::string &name() const { return m_name; }
......
......@@ -17,6 +17,7 @@
#include <deque>
#include <mutex>
#include <string>
#include <utility>
namespace Mantid {
namespace API {
......@@ -26,7 +27,7 @@ namespace API {
class AlgorithmStartingNotification : public Poco::Notification {
public:
AlgorithmStartingNotification(IAlgorithm_sptr alg)
: Poco::Notification(), m_alg(alg) {}
: Poco::Notification(), m_alg(std::move(alg)) {}
/// Returns the algorithm that is starting
IAlgorithm_sptr getAlgorithm() const { return m_alg; }
......
......@@ -23,17 +23,17 @@ Hides Poco::Notification API from the user.
class MANTID_API_DLL AlgorithmObserver {
public:
AlgorithmObserver();
AlgorithmObserver(IAlgorithm_const_sptr alg);
AlgorithmObserver(const IAlgorithm_const_sptr &alg);
virtual ~AlgorithmObserver();
void observeAll(IAlgorithm_const_sptr alg);
void observeProgress(IAlgorithm_const_sptr alg);
void observeAll(const IAlgorithm_const_sptr &alg);
void observeProgress(const IAlgorithm_const_sptr &alg);
void observeStarting();
void observeStart(IAlgorithm_const_sptr alg);
void observeFinish(IAlgorithm_const_sptr alg);
void observeError(IAlgorithm_const_sptr alg);
void observeStart(const IAlgorithm_const_sptr &alg);
void observeFinish(const IAlgorithm_const_sptr &alg);
void observeError(const IAlgorithm_const_sptr &alg);
void stopObserving(IAlgorithm_const_sptr alg);
void stopObserving(const IAlgorithm_const_sptr &alg);
void stopObserving(const Mantid::API::IAlgorithm *alg);
void stopObservingManager();
......
......@@ -50,7 +50,7 @@ http://proj-gaudi.web.cern.ch/proj-gaudi/)
class MANTID_API_DLL AlgorithmProxy : public IAlgorithm,
public Kernel::PropertyManagerOwner {
public:
AlgorithmProxy(Algorithm_sptr alg);
AlgorithmProxy(const Algorithm_sptr &alg);
AlgorithmProxy(const AlgorithmProxy &) = delete;
AlgorithmProxy &operator=(const AlgorithmProxy &) = delete;
~AlgorithmProxy() override;
......
......@@ -36,8 +36,9 @@ value of type boost::optional<T> will be returned.
*/
template <typename T>
T 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->getNumberParameter(idf_name);
......@@ -68,8 +69,9 @@ T checkForMandatoryInstrumentDefault(
*/
template <typename T>
boost::optional<T> 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->getNumberParameter(idf_name);
......@@ -90,12 +92,14 @@ boost::optional<T> checkForOptionalInstrumentDefault(
*/
template <>
MANTID_API_DLL 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);
template <>
MANTID_API_DLL 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);
} // namespace API
} // namespace Mantid
......@@ -399,7 +399,7 @@ public:
IBoxControllerIO *getFileIO() { return m_fileIO.get(); }
/// makes box controller file based by providing class, responsible for
/// fileIO.
void setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO,
void setFileBacked(const boost::shared_ptr<IBoxControllerIO> &newFileIO,
const std::string &fileName = "");
void clearFileBacked();
//-----------------------------------------------------------------------------------
......
......@@ -25,7 +25,7 @@ public:
/// Constructor
CompositeCatalog();
/// Adds a catalog to the list of catalogs (m_catalogs)
void add(const ICatalog_sptr catalog);
void add(const ICatalog_sptr &catalog);
/// Log the user into the catalog system.
CatalogSession_sptr login(const std::string &username,
const std::string &password,
......
......@@ -27,7 +27,7 @@ class FunctionDomainMD;
*/
class MANTID_API_DLL CompositeDomainMD : public CompositeDomain {
public:
CompositeDomainMD(IMDWorkspace_const_sptr ws, size_t maxDomainSize);
CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize);
~CompositeDomainMD() override;
/// Return the total number of arguments in the domain
size_t size() const override { return m_totalSize; }
......
......@@ -148,9 +148,10 @@ public:
/// Remove a function
void removeFunction(size_t i);
/// Replace a function
void replaceFunction(size_t i, IFunction_sptr f);
void replaceFunction(size_t i, const IFunction_sptr &f);
/// Replace a function
void replaceFunctionPtr(const IFunction_sptr f_old, IFunction_sptr f_new);
void replaceFunctionPtr(const IFunction_sptr &f_old,
const IFunction_sptr &f_new);
/// Get the function index
std::size_t functionIndex(std::size_t i) const;
/// Returns the index of parameter i as it declared in its function
......
......@@ -45,7 +45,7 @@ protected:
void setPropManagerPropName(const std::string &propName);
void mapPropertyName(const std::string &nameInProp,
const std::string &nameInPropManager);
void copyProperty(API::Algorithm_sptr alg, const std::string &name);
void copyProperty(const API::Algorithm_sptr &alg, const std::string &name);
virtual ITableWorkspace_sptr determineChunk(const std::string &filename);
virtual MatrixWorkspace_sptr loadChunk(const size_t rowIndex);
Workspace_sptr load(const std::string &inputData,
......
......@@ -43,7 +43,7 @@ public:
using DetectorSearchResult = std::tuple<bool, size_t>;
/// Create a new DetectorSearcher with the given instrument & detectors
DetectorSearcher(Geometry::Instrument_const_sptr instrument,
DetectorSearcher(const Geometry::Instrument_const_sptr &instrument,
const Geometry::DetectorInfo &detInfo);
/// Find a detector that intsects with the given Qlab vector
DetectorSearchResult findDetectorIndex(const Kernel::V3D &q);
......
......@@ -6,6 +6,8 @@
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include <utility>
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Workspace_fwd.h"
#include "MantidKernel/DataService.h"
......@@ -35,7 +37,7 @@ public:
*/
EnabledWhenWorkspaceIsType(std::string otherPropName,
bool enabledSetting = true)
: IPropertySettings(), m_otherPropName(otherPropName),
: IPropertySettings(), m_otherPropName(std::move(otherPropName)),
m_enabledSetting(enabledSetting) {}
//--------------------------------------------------------------------------------------------
......
......@@ -107,9 +107,9 @@ public:
/// Easy access to the efixed value for this run & detector ID
double getEFixed(const detid_t detID) const;
/// Easy access to the efixed value for this run & optional detector
double getEFixed(const boost::shared_ptr<const Geometry::IDetector> detector =
boost::shared_ptr<const Geometry::IDetector>{
nullptr}) const;
double
getEFixed(const boost::shared_ptr<const Geometry::IDetector> &detector =
boost::shared_ptr<const Geometry::IDetector>{nullptr}) const;
/// Set the efixed value for a given detector ID
void setEFixed(const detid_t detID, const double value);
......
......@@ -25,7 +25,7 @@ public:
/// Get the number of columns
size_t columnCount() const;
/// Add a new column. All columns must have the same size.
void addColumn(boost::shared_ptr<Column> column);
void addColumn(const boost::shared_ptr<Column> &column);
/// Get i-th column
boost::shared_ptr<Column> getColumn(size_t i) const;
......
......@@ -22,7 +22,7 @@ namespace API {
class MANTID_API_DLL FunctionDomainMD : public FunctionDomain {
public:
/// Constructor.
FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start = 0,
FunctionDomainMD(const IMDWorkspace_const_sptr &ws, size_t start = 0,
size_t length = 0);
/// Destructor.
~FunctionDomainMD() override;
......
......@@ -90,19 +90,21 @@ private:
/// Throw an exception
void inputError(const std::string &str = "") const;
/// Add constraints to the created function
void addConstraints(boost::shared_ptr<IFunction> fun,
void addConstraints(const boost::shared_ptr<IFunction> &fun,
const Expression &expr) const;
/// Add a single constraint to the created function
void addConstraint(boost::shared_ptr<IFunction> fun,
void addConstraint(const boost::shared_ptr<IFunction> &fun,
const Expression &expr) const;
/// Add a single constraint to the created function with non-default penalty
void addConstraint(boost::shared_ptr<IFunction> fun,
void addConstraint(const boost::shared_ptr<IFunction> &fun,
const Expression &constraint_expr,
const Expression &penalty_expr) const;
/// Add ties to the created function
void addTies(boost::shared_ptr<IFunction> fun, const Expression &expr) const;
void addTies(const boost::shared_ptr<IFunction> &fun,
const Expression &expr) const;
/// Add a tie to the created function
void addTie(boost::shared_ptr<IFunction> fun, const Expression &expr) const;
void addTie(const boost::shared_ptr<IFunction> &fun,
const Expression &expr) const;
mutable std::map<std::string, std::vector<std::string>> m_cachedFunctionNames;
mutable std::mutex m_mutex;
......
......@@ -31,7 +31,7 @@ belongs to. By default if a name has the signature of a composite function
class MANTID_API_DLL FunctionGenerator : public IFunction {
public:
/// Constructor
FunctionGenerator(IFunction_sptr source);
FunctionGenerator(const IFunction_sptr &source);
/// @name Overrides implementing composition of two functions:
/// m_source and m_target.
......
......@@ -26,7 +26,8 @@ namespace API {
class MANTID_API_DLL GridDomain1D : public API::GridDomain {
public:
/// initialize
void initialize(double &startX, double &endX, size_t &n, std::string scaling);
void initialize(double &startX, double &endX, size_t &n,
const std::string &scaling);
/// number of grid point s
size_t size() const override { return m_points.size(); }
/// number of dimensions in the grid
......
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