Skip to content

Commit

Permalink
Merge pull request #38614 from peterfpeterson/cppcheck_2_16_ornlnext
Browse files Browse the repository at this point in the history
Update cppcheck to 2.16.0 - ornlnext
  • Loading branch information
peterfpeterson authored Jan 17, 2025
2 parents 5fc96e8 + 6f33404 commit 40dd317
Show file tree
Hide file tree
Showing 99 changed files with 5,019 additions and 2,394 deletions.
4 changes: 3 additions & 1 deletion Framework/API/inc/MantidAPI/WorkspaceGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ class MANTID_API_DLL WorkspaceGroup : public Workspace {
/// This method returns true if the group is empty (no member workspace)
bool isEmpty() const;
bool areNamesSimilar() const;
/// Inidicates that the workspace group can be treated as multiperiod.
/// Indicates that the workspace group can be treated as multiperiod.
bool isMultiperiod() const;
/// Check if the workspace group contains just peak workspaces
bool isGroupPeaksWorkspaces() const;
/// Check if a workspace is included in this group or any nested groups.
bool isInGroup(const Workspace &workspaceToCheck, size_t level = 0) const;
/// Prints the group to the screen using the logger at debug
Expand Down
15 changes: 12 additions & 3 deletions Framework/API/src/WorkspaceGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidKernel/IPropertyManager.h"
Expand Down Expand Up @@ -455,6 +456,14 @@ bool WorkspaceGroup::isMultiperiod() const {
return true;
}

/**
* @return :: True if all of the workspaces in the group are peak workspaces
*/
bool WorkspaceGroup::isGroupPeaksWorkspaces() const {
return std::all_of(m_workspaces.begin(), m_workspaces.end(),
[](auto ws) { return dynamic_cast<IPeaksWorkspace *>(ws.get()) != nullptr; });
}

/**
* @param workspaceToCheck :: A workspace to check.
* @param level :: The current nesting level. Intended for internal use only
Expand All @@ -471,7 +480,7 @@ bool WorkspaceGroup::isInGroup(const Workspace &workspaceToCheck, size_t level)
for (const auto &workspace : m_workspaces) {
if (workspace.get() == &workspaceToCheck)
return true;
auto *group = dynamic_cast<WorkspaceGroup *>(workspace.get());
const auto *group = dynamic_cast<WorkspaceGroup *>(workspace.get());
if (group) {
if (group->isInGroup(workspaceToCheck, level + 1))
return true;
Expand Down Expand Up @@ -503,7 +512,7 @@ namespace Mantid::Kernel {
template <>
MANTID_API_DLL Mantid::API::WorkspaceGroup_sptr
IPropertyManager::getValue<Mantid::API::WorkspaceGroup_sptr>(const std::string &name) const {
auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::WorkspaceGroup_sptr> *>(getPointerToProperty(name));
const auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::WorkspaceGroup_sptr> *>(getPointerToProperty(name));
if (prop) {
return *prop;
} else {
Expand All @@ -516,7 +525,7 @@ IPropertyManager::getValue<Mantid::API::WorkspaceGroup_sptr>(const std::string &
template <>
MANTID_API_DLL Mantid::API::WorkspaceGroup_const_sptr
IPropertyManager::getValue<Mantid::API::WorkspaceGroup_const_sptr>(const std::string &name) const {
auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::WorkspaceGroup_sptr> *>(getPointerToProperty(name));
const auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::WorkspaceGroup_sptr> *>(getPointerToProperty(name));
if (prop) {
return prop->operator()();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include "MantidAPI/Algorithm.h"
#include "MantidAPI/WorkspaceGroup_fwd.h"
#include "MantidAlgorithms/DllConfig.h"
#include <memory>
#include <optional>
Expand Down Expand Up @@ -36,11 +37,18 @@ class MANTID_ALGORITHMS_DLL PolarizationCorrectionFredrikze final : public API::
void init() override;
void exec() override;
std::shared_ptr<Mantid::API::MatrixWorkspace> getEfficiencyWorkspace(const std::string &label);
std::shared_ptr<Mantid::API::WorkspaceGroup> execPA(const std::shared_ptr<Mantid::API::WorkspaceGroup> &inWS);
std::shared_ptr<Mantid::API::WorkspaceGroup> execPNR(const std::shared_ptr<Mantid::API::WorkspaceGroup> &inWS);
std::shared_ptr<Mantid::API::MatrixWorkspace> add(std::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS,
std::shared_ptr<Mantid::API::WorkspaceGroup> execPA(const std::shared_ptr<Mantid::API::WorkspaceGroup> &inWS,
const std::vector<std::string> &inputSpinStates,
const std::vector<std::string> &outputSpinStates,
const bool addSpinStateLog);

std::shared_ptr<Mantid::API::WorkspaceGroup> execPNR(const std::shared_ptr<Mantid::API::WorkspaceGroup> &inWS,
const std::vector<std::string> &inputSpinStates,
const std::vector<std::string> &outputSpinStates,
const bool addSpinStateLog);
std::shared_ptr<Mantid::API::MatrixWorkspace> add(const std::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS,
const double &rhs);
std::shared_ptr<Mantid::API::MatrixWorkspace> multiply(std::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS,
std::shared_ptr<Mantid::API::MatrixWorkspace> multiply(const std::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS,
const double &rhs);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ class MANTID_ALGORITHMS_DLL PolarizationCorrectionWildes final : public API::Alg
WorkspaceMap twoInputCorrections(const WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
WorkspaceMap threeInputCorrections(const WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
WorkspaceMap fullCorrections(const WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
API::WorkspaceGroup_sptr groupOutput(const WorkspaceMap &outputs);
API::WorkspaceGroup_sptr groupOutput(const WorkspaceMap &outputs, const bool hasAnalyser);
WorkspaceMap mapInputsToDirections(const std::vector<std::string> &flippers);
void threeInputsSolve01(WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
void threeInputsSolve10(WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
void twoInputsSolve01And10(WorkspaceMap &fullInputs, const WorkspaceMap &inputs, const EfficiencyMap &efficiencies);
void addSpinStateOutput(std::vector<std::string> &names, const std::string &spinStateOrder,
const std::string &baseName, const API::MatrixWorkspace_sptr &ws,
const std::string &spinState);
const std::string &spinState, const bool addSpinStateLog, const bool hasAnalyser);
void addSpinStateLogToWs(const API::MatrixWorkspace_sptr &ws, const std::string &spinState, const bool hasAnalyser);
};
} // namespace Algorithms
} // namespace Mantid
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,47 @@ MANTID_ALGORITHMS_DLL std::vector<std::string> splitSpinStateString(const std::s
} // namespace PolarizationCorrectionsHelpers

namespace FlipperConfigurations {
auto constexpr OFF_ON = "01";
auto constexpr ON_OFF = "10";
auto constexpr OFF_OFF = "00";
auto constexpr ON_ON = "11";
auto constexpr OFF = "0";
auto constexpr ON = "1";
static const std::string OFF_ON = "01";
static const std::string ON_OFF = "10";
static const std::string OFF_OFF = "00";
static const std::string ON_ON = "11";
static const std::string OFF = "0";
static const std::string ON = "1";
} // namespace FlipperConfigurations

namespace SpinStateConfigurationsFredrikze {
auto constexpr PARA_ANTI = "pa";
auto constexpr ANTI_PARA = "ap";
auto constexpr PARA_PARA = "pp";
auto constexpr ANTI_ANTI = "aa";
auto constexpr PARA = "p";
auto constexpr ANTI = "a";
static const std::string PARA_ANTI = "pa";
static const std::string ANTI_PARA = "ap";
static const std::string PARA_PARA = "pp";
static const std::string ANTI_ANTI = "aa";
static const std::string PARA = "p";
static const std::string ANTI = "a";
} // namespace SpinStateConfigurationsFredrikze

namespace SpinStateConfigurationsWildes {
auto constexpr MINUS_PLUS = "-+";
auto constexpr PLUS_MINUS = "+-";
auto constexpr MINUS_MINUS = "--";
auto constexpr PLUS_PLUS = "++";
auto constexpr MINUS = "-";
auto constexpr PLUS = "+";
static const std::string MINUS_PLUS = "-+";
static const std::string PLUS_MINUS = "+-";
static const std::string MINUS_MINUS = "--";
static const std::string PLUS_PLUS = "++";
static const std::string MINUS = "-";
static const std::string PLUS = "+";
} // namespace SpinStateConfigurationsWildes

namespace SpinStatesORSO {
/*
* Polarization constants and helper methods to support the Reflectometry ORSO file format
*/
static const std::string PP = "pp";
static const std::string PM = "pm";
static const std::string MP = "mp";
static const std::string MM = "mm";
static const std::string PO = "po";
static const std::string MO = "mo";

static const std::string LOG_NAME = "spin_state_ORSO";

MANTID_ALGORITHMS_DLL const std::string &getORSONotationForSpinState(const std::string &spinState);
MANTID_ALGORITHMS_DLL void addORSOLogForSpinState(const Mantid::API::MatrixWorkspace_sptr &ws,
const std::string &spinState);
} // namespace SpinStatesORSO
} // namespace Mantid::Algorithms
5 changes: 4 additions & 1 deletion Framework/Algorithms/inc/MantidAlgorithms/SofQWCentre.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/DeprecatedAlgorithm.h"
#include "MantidAlgorithms/DllConfig.h"
#include "MantidAlgorithms/SofQCommon.h"

Expand All @@ -33,8 +34,10 @@ common bins. </LI>
@author Russell Taylor, Tessella plc
@date 24/02/2010
*/
class MANTID_ALGORITHMS_DLL SofQWCentre final : public API::Algorithm {
class MANTID_ALGORITHMS_DLL SofQWCentre final : public API::Algorithm, public API::DeprecatedAlgorithm {
public:
/// Default constructor
SofQWCentre();
/// Algorithm's name
const std::string name() const override { return "SofQWCentre"; }
/// Summary of algorithms purpose
Expand Down
3 changes: 2 additions & 1 deletion Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/DeprecatedAlgorithm.h"
#include "MantidAlgorithms/Rebin2D.h"
#include "MantidAlgorithms/SofQCommon.h"
#include <list>
Expand Down Expand Up @@ -38,7 +39,7 @@ common bins. </LI>
@author Martyn Giggg
@date 2011-07-15
*/
class MANTID_ALGORITHMS_DLL SofQWPolygon : public Rebin2D {
class MANTID_ALGORITHMS_DLL SofQWPolygon : public Rebin2D, public API::DeprecatedAlgorithm {
public:
/// Default constructor
SofQWPolygon();
Expand Down
2 changes: 1 addition & 1 deletion Framework/Algorithms/src/ConvertToConstantL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ConvertToConstantL2::exec() {
throw std::runtime_error(errorMsg.str());
}

// subract the diference in l2
// subtract the difference in l2
double thisDetL2 = inputSpecInfo.l2(i);
double deltaL2 = std::abs(thisDetL2 - m_l2);
double deltaTOF = calculateTOF(deltaL2);
Expand Down
Loading

0 comments on commit 40dd317

Please sign in to comment.