12#include "MantidParallel/Communicator.h"
21using namespace Kernel;
28 "Names of the Input Workspaces to Group");
30 "Add all Workspaces that match Glob expression to Group");
32 "Name of the workspace to be created as the output of grouping ");
39 const std::vector<std::string> inputWorkspaces =
getProperty(
"InputWorkspaces");
41 const std::string globExpression =
getProperty(
"GlobExpression");
46 if (!inputWorkspaces.empty())
48 if (!globExpression.empty())
51 throw std::invalid_argument(
"Glob pattern " + globExpression +
" does not match any workspace names in the ADS.");
58 std::map<std::string, std::string> results;
59 const std::vector<std::string> inputWorkspaces =
getProperty(
"InputWorkspaces");
60 std::string globExpression =
getProperty(
"GlobExpression");
61 std::string outputWorkspace =
getProperty(
"OutputWorkspace");
65 for (
const auto &ws : inputWorkspaces) {
66 if (ws == outputWorkspace) {
68 results[
"OutputWorkspace"] =
"The output workspace has the same name as "
69 "one of the input workspaces";
73 for (
auto it = globExpression.begin(); it < globExpression.end(); ++it) {
75 it = globExpression.erase(it, it + 1);
79 if (inputWorkspaces.empty() && globExpression.empty()) {
80 results[
"InputWorkspaces"] =
"No InputWorkspace names specified. Rerun with a list of workspaces "
81 "names or a glob expression";
87 if (!globExpression.empty()) {
90 if (globExpression.find_first_of(
"*?[]") == std::string::npos) {
91 results[
"GlobExpression"] =
"Expression is expected to contain one or "
92 "more of the following characters: *?[";
95 if (std::count(globExpression.cbegin(), globExpression.cend(),
'[') !=
96 std::count(globExpression.cbegin(), globExpression.cend(),
']')) {
97 results[
"GlobExpression"] =
"Expression has a mismatched number of []";
110 Poco::Glob glob(globExpression);
114 for (
const auto &
name : names) {
115 if (glob.match(
name.first)) {
128 for (
const auto &
name : names) {
139 auto localGroup = std::dynamic_pointer_cast<WorkspaceGroup>(
workspace);
148 throw std::runtime_error(
"WorkspaceGroup with mixed Parallel::Storage mode is not supported.");
154Parallel::ExecutionMode
156 static_cast<void>(storageModes);
157 const std::vector<std::string> names =
getProperty(
"InputWorkspaces");
159 return Parallel::getCorrespondingExecutionMode(ws->storageMode());
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
const Parallel::Communicator & communicator() const
Returns a const reference to the (MPI) communicator of the algorithm.
The Analysis data service stores instances of the Workspace objects and anything that derives from te...
std::map< std::string, Workspace_sptr > topLevelItems() const
Return a lookup of the top level items.
A property class for workspaces.
void init() override
Overridden Init method.
void exec() override
overridden execute method
Parallel::ExecutionMode getParallelExecutionMode(const std::map< std::string, Parallel::StorageMode > &storageModes) const override
Get correct execution mode based on input storage modes for an MPI run.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
std::map< std::string, std::string > validateInputs() override
Method checking errors on ALL the inputs, before execution.
API::WorkspaceGroup_sptr m_group
A pointer to the new group.
void addToGroup(const std::vector< std::string > &names)
Add a list of names to the new group.
Support for a property that holds an array of values.
std::shared_ptr< T > retrieve(const std::string &name) const
Get a shared pointer to a stored data object.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
AnalysisDataServiceImpl::GroupWorkspacesNotification WorkspacesGroupedNotification
@ Output
An output workspace.