8#include <unordered_map>
14 std::function<std::string(std::size_t)>
const &
getName,
15 std::function<
void(
Workspace_sptr,
const std::string &)>
const &renamer) {
16 std::unordered_map<std::string, std::size_t> nameCount;
17 for (
auto i = 0u; i < groupWorkspace->size(); ++i) {
19 auto count = nameCount.find(name);
21 if (
count == nameCount.end()) {
22 renamer(groupWorkspace->getItem(i), name);
30 renamer->setProperty(
"InputWorkspace",
workspace);
31 renamer->setProperty(
"OutputWorkspace", newName);
32 renamer->executeAsChildAlg();
36 const auto &first = workspaces.front();
37 return std::any_of(workspaces.cbegin(), workspaces.cend(),
38 [&first](
const auto &
workspace) { return workspace != first; });
43 std::string
const &, std::function<std::string(std::size_t)>
const &getNameSuffix) {
44 Progress renamerProg(qensFit, 0.98, 1.0, outputGroup->size() + 1);
45 renamerProg.
report(
"Renaming group workspaces...");
47 auto getName = [&](std::size_t i) {
48 std::string name = outputBaseName +
"_" + getNameSuffix(i);
54 renamerProg.
report(
"Renamed workspace in group.");
IPeaksWorkspace_sptr workspace
std::string getName(const IMDDimension &self)
Base class from which all concrete algorithm classes should be derived.
Helper class for reporting progress from algorithms.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
void renameWorkspacesInQENSFit(Algorithm *qensFit, IAlgorithm_sptr renameAlgorithm, const WorkspaceGroup_sptr &outputGroup, std::string const &outputBaseName, std::string const &groupSuffix, std::function< std::string(std::size_t)> const &getNameSuffix)
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
void renameWorkspacesWith(const WorkspaceGroup_sptr &groupWorkspace, std::function< std::string(std::size_t)> const &getName, std::function< void(Workspace_sptr, const std::string &)> const &renamer)
void renameWorkspace(const IAlgorithm_sptr &renamer, const Workspace_sptr &workspace, const std::string &newName)
bool containsMultipleData(const std::vector< MatrixWorkspace_sptr > &workspaces)
std::string to_string(const wide_integer< Bits, Signed > &n)