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