-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow overwriting members of a WorkspaceGroup when setting output properties to the same workspace name #828
Changes from 4 commits
7a15689
05ddb2d
3f4cd7b
3d5d408
0af002c
84a900d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,20 @@ namespace API { | |
namespace { | ||
/// Separator for workspace types in workspaceMethodOnTypes member | ||
const std::string WORKSPACE_TYPES_SEPARATOR = ";"; | ||
|
||
class WorkspacePropertyValueIs { | ||
public: | ||
WorkspacePropertyValueIs(std::string value) : m_value(value){}; | ||
bool operator()(IWorkspaceProperty *property) { | ||
Property *prop = dynamic_cast<Property *>(property); | ||
if (!prop) | ||
return false; | ||
return prop->value() == m_value; | ||
} | ||
|
||
private: | ||
std::string m_value; | ||
}; | ||
} | ||
|
||
// Doxygen can't handle member specialization at the moment: | ||
|
@@ -1324,8 +1338,22 @@ bool Algorithm::processGroups() { | |
dynamic_cast<Property *>(m_pureOutputWorkspaceProps[owp])) { | ||
// Default name = "in1_in2_out" | ||
std::string outName = outputBaseName + "_" + prop->value(); | ||
|
||
WorkspacePropertyValueIs comp(prop->value()); | ||
auto inputProp = std::find_if(m_inputWorkspaceProps.begin(), | ||
m_inputWorkspaceProps.end(), comp); | ||
|
||
// Overwrite workspaces in any input property if they have the same | ||
// name as an output (i.e. copy name button in algorithm dialog used) | ||
// (only need to do this for a single input, multiple will be handled | ||
// by ADS) | ||
if (inputProp != m_inputWorkspaceProps.end() && | ||
dynamic_cast<Property *>(*inputProp)->value() == prop->value()) | ||
outName = m_groups[inputProp - m_inputWorkspaceProps.begin()][entry] | ||
->name(); | ||
|
||
// Except if all inputs had similar names, then the name is "out_1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to create inputProp variable and do the second if? It looks to me that the second if's condition is always true when the first if is true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mantid-roman It protects against the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant inputProperty. It is only used to repeat the checks done in WorkspacePropertyValueIs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you were meaning now, I could remove the first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I have no idea what I was previously thinking. |
||
if (m_groupsHaveSimilarNames) | ||
else if (m_groupsHaveSimilarNames) | ||
outName = prop->value() + "_" + Strings::toString(entry + 1); | ||
|
||
// Set in the output | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't see it earlier but
value
should be passed by const reference.