20using namespace Kernel;
29 declareProperty<bool>(
"RenameMonitors",
false,
30 "If true, and monitor workspace found attached"
31 " to the source workspace, the monitors workspace is renamed too.\n"
32 "The monitor workspace name is created from the new workspace "
33 "name: NewWSName by adding the _monitors suffix"
34 " (e.g.: NewWSName_monitors)",
38 declareProperty<bool>(
"OverwriteExisting",
true,
39 "If true any existing workspaces with the output name will be"
40 " overwritten. Defaults to true to maintain backwards compatibility.",
51 map<string, string> errorList;
56 bool overrideWorkspaces =
getProperty(
"OverwriteExisting");
60 errorList[
"InputWorkspace"] =
"Input and output workspace"
61 " names must be different";
62 errorList[
"OutputWorkspace"] =
"Input and output workspace"
63 " names must be different";
69 if (!overrideWorkspaces) {
74 errorList[
"OutputWorkspace"] =
"The workspace " + outputwsName +
" already exists";
75 errorList[
"OverwriteExisting"] =
"Set OverwriteExisting to true"
76 " to overwrite the existing workspace";
96 std::string inputwsName = inputWS->getName();
104 ADS.rename(inputwsName, outputwsName);
106 const bool renameMonitors =
getProperty(
"RenameMonitors");
111 auto matInputWS = std::dynamic_pointer_cast<MatrixWorkspace>(inputWS);
114 auto monWS = matInputWS->monitorWorkspace();
116 std::string monWSName = monWS->getName();
118 if (monWSName.empty()) {
121 ADS.add(outputwsName +
"_monitors", monWS);
124 ADS.rename(monWSName, outputwsName +
"_monitors");
126 ADS.add(monWSName, monWS);
127 ADS.rename(monWSName, outputwsName +
"_monitors");
136 const std::string inputwsName = inputWS->getName();
139 if (inputwsName == outputwsName) {
140 throw std::invalid_argument(
"The input and output workspace names must be different");
151 const bool renameMembers = inputGroup->areNamesSimilar();
157 const std::vector<std::string> names = inputGroup->getNames();
160 for (
size_t i = 0; i < names.size(); ++i) {
163 std::stringstream suffix;
165 std::string wsName = outputwsName +
"_" + suffix.str();
169 alg->setPropertyValue(
"InputWorkspace", names[i]);
170 alg->setPropertyValue(
"OutputWorkspace", wsName);
172 alg->enableHistoryRecordingForChild(
false);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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.
A property class for workspaces.
std::map< std::string, std::string > validateInputs() override
Check that input params are valid.
void init() override
Initialisation method.
bool processGroups() override
Process WorkspaceGroup inputs.
void exec() override
Executes the algorithm.
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Exception for when an item is not found in a collection.
const char * what() const noexcept override
Writes out the range and limits.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
void error(const std::string &msg)
Logs at error level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
@ Input
An input workspace.
@ Output
An output workspace.