Mantid
Loading...
Searching...
No Matches
SaveNXcanSAS.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7
10#include "MantidAPI/Progress.h"
13
14using namespace Mantid::API;
15
16namespace Mantid::DataHandling {
17// Register the algorithm into the AlgorithmFactory
19
20
22
24
25std::map<std::string, std::string> SaveNXcanSAS::validateInputs() { return validateStandardInputs(); }
26
28 const Mantid::API::Workspace_sptr &workspace = getProperty("InputWorkspace");
29 if (workspace && workspace->isGroup())
30 return true;
31 return false;
32}
33
36 auto const &group = std::dynamic_pointer_cast<WorkspaceGroup>(workspace)->getAllItems();
37 std::ranges::for_each(group.cbegin(), group.cend(), [&](auto const &wsChild) {
38 m_workspaces.push_back(std::dynamic_pointer_cast<MatrixWorkspace>(wsChild));
39 });
40
42 return true;
43}
44
46 m_progress = std::make_unique<API::Progress>(this, 0.1, 1.0, 3 * m_workspaces.size());
47 auto baseFilename = getPropertyValue("Filename");
48 for (size_t wksIndex = 0; wksIndex < m_workspaces.size(); wksIndex++) {
50 NXcanSAS::prepareFilename(baseFilename, m_workspaces.size() > 1, wksIndex));
51 }
52}
53
56 m_workspaces.push_back(std::dynamic_pointer_cast<MatrixWorkspace>(workspace));
57
59}
60
61} // namespace Mantid::DataHandling
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
IPeaksWorkspace_sptr workspace
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
std::map< std::string, std::string > validateStandardInputs() const
std::unique_ptr< API::Progress > m_progress
void saveSingleWorkspaceFile(const API::MatrixWorkspace_sptr &workspace, const std::filesystem::path &path) const
Saves NXcanSAS data for a matrix workspace.
SaveNXcanSAS : Saves a reduced workspace in the NXcanSAS format.
std::vector< API::MatrixWorkspace_sptr > m_workspaces
bool checkGroups() override
Override processGroups.
void init() override
Initialisation code.
void exec() override
Execution code.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
bool processGroups() override
Process WorkspaceGroup inputs.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::filesystem::path MANTID_DATAHANDLING_DLL prepareFilename(const std::string &baseFilename, bool addDigitSuffix=false, size_t index=0)