30 "An input MDEventWorkspace/MDHistoWorkspace.");
32 "Name of the output MDEventWorkspace/MDHistoWorkspace.");
34 std::vector<std::string> exts(1,
".nxs");
36 "If the input workspace is file-backed, specify a file to which to save "
37 "the cloned workspace.\n"
38 "If the workspace is file-backed but this parameter is NOT specified, "
39 "then a new filename with '_clone' appended is created next to the "
41 "No effect if the input workspace is NOT file-backed.\n"
55 throw std::runtime_error(
"Error with InputWorkspace: no BoxController!");
56 if (bc->isFileBacked()) {
59 g_log.
notice() <<
"InputWorkspace's file-backend being updated. \n";
61 alg->setProperty(
"InputWorkspace", ws);
62 alg->setProperty(
"UpdateFileBackEnd",
true);
63 alg->executeAsChildAlg();
67 std::string originalFile = bc->getFilename();
69 if (outFilename.empty()) {
71 Poco::Path path = Poco::Path(originalFile).absolute();
72 std::string newName = path.getBaseName() +
"_clone." + path.getExtension();
73 path.setFileName(newName);
74 outFilename = path.toString();
80 g_log.
notice() <<
"Cloned workspace file being copied to: " << outFilename <<
'\n';
81 bc->getFileIO()->copyFileTo(outFilename);
86 alg->setPropertyValue(
"Filename", outFilename);
87 alg->setPropertyValue(
"FileBackEnd",
"1");
88 alg->setPropertyValue(
"Memory",
"0");
89 alg->executeAsChildAlg();
93 this->
setProperty(
"OutputWorkspace", std::dynamic_pointer_cast<IMDWorkspace>(outWS));
111 }
else if (inHistoWS) {
118 throw std::runtime_error(
"CloneMDWorkspace can only clone a "
119 "MDEventWorkspace or MDHistoWorkspace. Try "
#define DECLARE_ALGORITHM(classname)
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
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.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
@ OptionalSave
to specify a file to write to but an empty string is
bool fileNeedsUpdating() const
A property class for workspaces.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
std::unique_ptr< MDEventWorkspace > clone() const
Returns a clone of the workspace.
Mantid::API::BoxController_sptr getBoxController() override
Returns the BoxController used in this workspace.
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 information(const std::string &msg)
Logs at information level.
Algorithm to clone a MDEventWorkspace to a new one.
void exec() override
Run the algorithm.
void doClone(const typename DataObjects::MDEventWorkspace< MDE, nd >::sptr &ws)
Perform the cloning.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
std::shared_ptr< BoxController > BoxController_sptr
Shared ptr to BoxController.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
@ Input
An input workspace.
@ Output
An output workspace.