Mantid
Loading...
Searching...
No Matches
Load.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
19
20#include <algorithm>
21#include <cctype>
22#include <cstdio>
23#include <filesystem>
24#include <functional>
25#include <numeric>
26#include <set>
27
28namespace {
38bool isSingleFile(const std::vector<std::vector<std::string>> &fileNames) {
39 return fileNames.size() == 1 && fileNames[0u].size() == 1;
40}
41
51std::string generateWsNameFromFileNames(const std::vector<std::string> &filenames) {
52 std::string wsName;
53
54 for (auto &filename : filenames) {
55 if (!wsName.empty())
56 wsName += "_";
57
58 std::filesystem::path path(filename);
59 wsName += path.stem().string();
60 }
61
62 return wsName;
63}
64
69std::vector<std::string> flattenVecOfVec(std::vector<std::vector<std::string>> vecOfVec) {
70 std::vector<std::string> flattenedVec;
71
72 std::vector<std::vector<std::string>>::const_iterator it = vecOfVec.begin();
73
74 for (; it != vecOfVec.end(); ++it) {
75 flattenedVec.insert(flattenedVec.end(), it->begin(), it->end());
76 }
77
78 return flattenedVec;
79}
80} // namespace
81
82namespace Mantid::DataHandling {
83// Register the algorithm into the algorithm factory
85
86// The mutex
87std::recursive_mutex Load::m_mutex;
88
89using namespace Kernel;
90using namespace API;
91
92//--------------------------------------------------------------------------
93// Public methods
94//--------------------------------------------------------------------------
95
103void Load::setPropertyValue(const std::string &name, const std::string &value) {
104 // Call base class method in all cases.
105 // For a filename property is deals with resolving the full path.
107
108 std::string NAME(name);
109 std::transform(name.begin(), name.end(), NAME.begin(), toupper);
110 if (NAME == "FILENAME") {
111 // Get back full path before passing to getFileLoader method, and also
112 // find out whether this is a multi file load.
113 std::vector<std::string> fileNames = flattenVecOfVec(getProperty("Filename"));
114 // If it's a single file load, then it's fine to change loader.
115 if (fileNames.size() == 1) {
116 auto loader = getFileLoader(getPropertyValue(name));
117 assert(loader); // (getFileLoader should throw if no loader is found.)
119 m_loader = std::move(loader);
120 }
121 // Else we've got multiple files, and must enforce the rule that only one
122 // type of loader is allowed.
123 // Allowing more than one would mean that "extra" properties defined by the
124 // class user (for example
125 // "LoadLogFiles") are potentially ambiguous.
126 else if (fileNames.size() > 1) {
127 auto loader = getFileLoader(fileNames[0]);
128
129 // If the first file has a loader ...
130 if (loader) {
131 // ... store its name and version and check that all other files have
132 // loaders with the same name and version.
133 const std::string loaderName = loader->name();
134 int firstFileLoaderVersion = loader->version();
135
136 // std::string ext =
137 // fileNames[0].substr(fileNames[0].find_last_of("."));
138
139 auto ifl = std::dynamic_pointer_cast<IFileLoader<Kernel::FileDescriptor>>(loader);
140 auto iflNexus = std::dynamic_pointer_cast<IFileLoader<Nexus::NexusDescriptor>>(loader);
141
142 for (size_t i = 1; i < fileNames.size(); ++i) {
143 // If it's loading into a single file, perform a cursory check on file
144 // extensions only.
145 if ((ifl && ifl->loadMutipleAsOne()) || (iflNexus && iflNexus->loadMutipleAsOne())) {
146 // Currently disabled for ticket
147 // http://trac.mantidproject.org/mantid/ticket/10397 : should be put
148 // back in when completing 10231
149 /* if( fileNames[i].substr(fileNames[i].find_last_of(".")) != ext)
150 {
151 throw std::runtime_error("Cannot load multiple files when more
152 than one Loader is needed.");
153 }*/
154 } else {
155 loader = getFileLoader(fileNames[i]);
156
157 if (loaderName != loader->name() || firstFileLoaderVersion != loader->version())
158 throw std::runtime_error("Cannot load multiple files when more "
159 "than one Loader is needed.");
160 }
161 }
162 }
163
164 assert(loader); // (getFileLoader should throw if no loader is found.)
166 }
167 }
168}
169
170//--------------------------------------------------------------------------
171// Private methods
172//--------------------------------------------------------------------------
173
180API::IAlgorithm_sptr Load::getFileLoader(const std::string &filePath) {
181 API::IAlgorithm_sptr winningLoader;
182 try {
183 winningLoader = API::FileLoaderRegistry::Instance().chooseLoader(filePath);
184 } catch (Exception::NotFoundError &) {
185 // Clear what may have been here previously
186 setPropertyValue("LoaderName", "");
187 setProperty("LoaderVersion", -1);
188 throw std::runtime_error("Cannot find an algorithm that is able to load \"" + filePath +
189 "\".\n"
190 "Check that the file is a supported type.");
191 }
192 winningLoader->initialize();
193 setUpLoader(winningLoader, 0, 1);
194
195 findFilenameProperty(winningLoader);
196
197 setPropertyValue("LoaderName", winningLoader->name());
198 setProperty("LoaderVersion", winningLoader->version());
199 return winningLoader;
200}
201
203 // Use the first file property as the main Filename
204 m_filenamePropName.clear();
205 const auto &props = loader->getProperties();
206 for (auto const &prop : props) {
207 auto const *multiprop = dynamic_cast<API::MultipleFileProperty *>(prop);
208 auto const *singleprop = dynamic_cast<API::FileProperty *>(prop);
209 if (multiprop) {
210 m_filenamePropName = multiprop->name();
211 break;
212 }
213 if (singleprop) {
214 m_filenamePropName = singleprop->name();
215 break;
216 }
217 }
218
219 // throw an exception if somehting nothing was found
220 if (m_filenamePropName.empty()) {
221 // unset member variables
222 setPropertyValue("LoaderName", "");
223 setProperty("LoaderVersion", -1);
224
225 std::stringstream msg;
226 msg << "Cannot find FileProperty on \"" << loader->name() << "\" v" << loader->version() << " algorithm.";
227 throw std::runtime_error(msg.str());
228 }
229}
230
236 // If we have switch loaders then the concrete loader will have different
237 // properties
238 // so take care of ensuring Load has the correct ones
239 // THIS IS A COPY as the properties are mutated as we move through them
240 const std::vector<Property *> existingProps = this->getProperties();
241 for (auto existingProp : existingProps) {
242 const std::string &propName = existingProp->name();
243 // Wipe all properties except the Load native ones
244 if (m_baseProps.find(propName) == m_baseProps.end()) {
245 this->removeProperty(propName);
246 }
247 }
248
249 const std::vector<Property *> &loaderProps = loader->getProperties();
250 size_t numProps(loaderProps.size());
251 for (size_t i = 0; i < numProps; ++i) {
252 Property const *loadProp = loaderProps[i];
253 if (loadProp->name() == m_filenamePropName)
254 continue;
255 try {
256 auto propClone = std::unique_ptr<Property>(loadProp->clone());
257 propClone->clearSettings(); // Get rid of special settings because it
258 // does not work in custom GUI.
259 declareProperty(std::move(propClone), loadProp->documentation());
260 } catch (Exception::ExistsError &) {
261 // Already exists as a static property
262 continue;
263 }
264 }
265}
266
269 // Take extensions first from Facility object
270 const FacilityInfo &defaultFacility = Mantid::Kernel::ConfigService::Instance().getFacility();
271 std::vector<std::string> exts = defaultFacility.extensions();
272 // Add in some other known extensions
273 exts.emplace_back(".xml");
274 exts.emplace_back(".dat");
275 exts.emplace_back(".txt");
276 exts.emplace_back(".csv");
277 exts.emplace_back(".spe");
278 exts.emplace_back(".grp");
279 exts.emplace_back(".nxspe");
280 exts.emplace_back(".h5");
281 exts.emplace_back(".hd5");
282 exts.emplace_back(".sqw");
283 exts.emplace_back(".fits");
284 exts.emplace_back(".bin");
285 exts.emplace_back(".edb");
286
287 declareProperty(std::make_unique<MultipleFileProperty>("Filename", exts),
288 "The name of the file(s) to read, including the full or relative "
289 "path. (N.B. case sensitive if running on Linux). Multiple runs "
290 "can be loaded and added together, e.g. INST10,11+12,13.ext");
291 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>("OutputWorkspace", "", Direction::Output),
292 "The name of the workspace that will be created, filled with the "
293 "read-in data and stored in the Analysis Data Service. Some algorithms "
294 "can created additional OutputWorkspace properties on the fly, e.g. "
295 "multi-period data.");
296
297 declareProperty("LoaderName", std::string(""),
298 "When an algorithm has been found that will load the given "
299 "file, its name is set here.",
301 declareProperty("LoaderVersion", -1,
302 "When an algorithm has been found that "
303 "will load the given file, its version "
304 "is set here.",
306 // Save for later what the base Load properties are
307 const std::vector<Property *> &props = this->getProperties();
308 for (size_t i = 0; i < this->propertyCount(); ++i) {
309 m_baseProps.insert(props[i]->name());
310 }
311}
312
317 std::vector<std::vector<std::string>> fileNames = getProperty("Filename");
318
319 // Test for loading as a single file
320 if (!m_loader)
321 m_loader = getFileLoader(fileNames[0][0]);
322 auto ifl = std::dynamic_pointer_cast<IFileLoader<Kernel::FileDescriptor>>(m_loader);
323 auto iflNexus = std::dynamic_pointer_cast<IFileLoader<Nexus::NexusDescriptor>>(m_loader);
324
325 if (isSingleFile(fileNames) || (ifl && ifl->loadMutipleAsOne()) || (iflNexus && iflNexus->loadMutipleAsOne())) {
326 // This is essentially just the same code that was called before multiple
327 // files were supported.
329 } else {
330 // Code that supports multiple file loading.
332 }
333
334 // Set the remaining properties of the loader
336
343 if (m_loader) {
344 setPropertyValue("LoaderName", m_loader->name());
345 setProperty("LoaderVersion", m_loader->version());
346 }
347}
348
350 if (!m_loader) {
352 }
353
354 g_log.information() << "Using " << m_loader->name() << " version " << m_loader->version() << ".\n";
356 const std::vector<Kernel::Property *> &loader_props = m_loader->getProperties();
357
358 // Loop through and set the properties on the Child Algorithm
359 std::vector<Kernel::Property *>::const_iterator itr;
360 for (itr = loader_props.begin(); itr != loader_props.end(); ++itr) {
361 const std::string propName = (*itr)->name();
362 if (this->existsProperty(propName)) {
363 m_loader->setPropertyValue(propName, getPropertyValue(propName));
364 } else if (propName == m_filenamePropName) {
365 m_loader->setPropertyValue(propName, getPropertyValue("Filename"));
366 }
367 }
368
369 // Execute the concrete loader
370 m_loader->execute();
371
372 // Set the output Workspace
373 Workspace_sptr wks = getOutputWorkspace("OutputWorkspace", m_loader);
374 setProperty("OutputWorkspace", wks);
375}
376
378 // allFilenames contains "rows" of filenames. If the row has more than 1 file
379 // in it
380 // then that row is to be summed across each file in the row
381 const std::vector<std::vector<std::string>> allFilenames = getProperty("Filename");
382 std::string outputWsName = getProperty("OutputWorkspace");
383
384 std::vector<std::string> wsNames(allFilenames.size());
385 std::transform(allFilenames.begin(), allFilenames.end(), wsNames.begin(), generateWsNameFromFileNames);
386
387 auto wsName = wsNames.cbegin();
388 assert(allFilenames.size() == wsNames.size());
389
390 std::vector<API::Workspace_sptr> loadedWsList;
391 loadedWsList.reserve(allFilenames.size());
392
393 Workspace_sptr tempWs;
394
395 // Cycle through the filenames and wsNames.
396 for (auto filenames = allFilenames.cbegin(); filenames != allFilenames.cend(); ++filenames, ++wsName) {
397 auto filename = filenames->cbegin();
398 Workspace_sptr sumWS = loadFileToWs(*filename, *wsName);
399
400 ++filename;
401 for (; filename != filenames->cend(); ++filename) {
402 tempWs = loadFileToWs(*filename, "__@loadsum_temp@");
403 sumWS = plusWs(sumWS, tempWs);
404 }
405
406 API::WorkspaceGroup_sptr group = std::dynamic_pointer_cast<WorkspaceGroup>(sumWS);
407 if (group) {
408 std::vector<std::string> childWsNames = group->getNames();
409 auto childWsName = childWsNames.begin();
410 size_t count = 1;
411 for (; childWsName != childWsNames.end(); ++childWsName, ++count) {
412 Workspace_sptr childWs = group->getItem(*childWsName);
413 const std::string childName = group->getName() + "_" + std::to_string(count);
414 API::AnalysisDataService::Instance().addOrReplace(childName, childWs);
415 // childWs->setName(group->getName() + "_" +
416 // boost::lexical_cast<std::string>(count));
417 }
418 }
419 // Add the sum to the list of loaded workspace names.
420 loadedWsList.emplace_back(sumWS);
421 }
422
423 // If we only have one loaded ws, set it as the output.
424 if (loadedWsList.size() == 1) {
425 setProperty("OutputWorkspace", loadedWsList[0]);
426 AnalysisDataService::Instance().rename(loadedWsList[0]->getName(), outputWsName);
427 }
428 // Else we have multiple loaded workspaces - group them and set the group as
429 // output.
430 else {
432 setProperty("OutputWorkspace", group);
433
434 std::vector<std::string> childWsNames = group->getNames();
435 size_t count = 1;
436 for (auto &childWsName : childWsNames) {
437 if (childWsName == outputWsName) {
438 Mantid::API::Workspace_sptr child = group->getItem(childWsName);
439 // child->setName(child->getName() + "_" +
440 // boost::lexical_cast<std::string>(count));
441 const std::string childName = child->getName() + "_" + std::to_string(count);
442 API::AnalysisDataService::Instance().addOrReplace(childName, child);
443 count++;
444 }
445 }
446
447 childWsNames = group->getNames();
448 count = 1;
449 for (auto &childWsName : childWsNames) {
450 Workspace_sptr childWs = group->getItem(childWsName);
451 std::string outWsPropName = "OutputWorkspace_" + std::to_string(count);
452 ++count;
453 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>(outWsPropName, childWsName, Direction::Output));
454 setProperty(outWsPropName, childWs);
455 }
456 }
457
458 // Clean up.
459 if (tempWs) {
460 Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("DeleteWorkspace");
461 alg->initialize();
462 alg->setChild(true);
463 alg->setProperty("Workspace", tempWs);
464 alg->execute();
465 }
466}
467
476API::IAlgorithm_sptr Load::createLoader(const double startProgress, const double endProgress,
477 const bool logging) const {
478 std::string loaderName = getPropertyValue("LoaderName");
479 int loaderVersion = getProperty("LoaderVersion");
480 auto loader = API::AlgorithmManager::Instance().createUnmanaged(loaderName, loaderVersion);
481 loader->initialize();
482 if (!loader) {
483 throw std::runtime_error("Cannot create loader for \"" + getPropertyValue("Filename") + "\"");
484 }
485 setUpLoader(loader, startProgress, endProgress, logging);
486 return loader;
487}
488
496void Load::setUpLoader(const API::IAlgorithm_sptr &loader, const double startProgress, const double endProgress,
497 const bool logging) const {
498 // Set as a child so that we are in control of output storage
499 loader->setChild(true);
500 loader->setLogging(logging);
501 // If output workspaces are nameless, give them a temporary name to satisfy
502 // validator
503 const std::vector<Property *> &props = loader->getProperties();
504 for (auto prop : props) {
505 auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
506
507 if (wsProp && !wsProp->isOptional() && prop->direction() == Direction::Output) {
508 if (prop->value().empty())
509 prop->setValue("LoadChildWorkspace");
510 }
511 }
512 if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) {
513 loader->addObserver(this->progressObserver());
514 setChildStartProgress(startProgress);
515 setChildEndProgress(endProgress);
516 }
517}
518
524 // Set output properties by looping the loaders properties and taking them until we have none left
525 while (loader->propertyCount() > 0) {
526 auto prop = loader->takeProperty(0);
527 if (prop && prop->direction() == Direction::Output) {
528 // We skip OutputWorkspace as this is set already from loadSingleFile and loadMultipleFiles
529 if (prop->name() != "OutputWorkspace")
530 declareOrReplaceProperty(std::move(prop));
531 }
532 }
533}
534
543API::Workspace_sptr Load::getOutputWorkspace(const std::string &propName, const API::IAlgorithm_sptr &loader) const {
544 // @todo Need to try and find a better way using the getValue methods
545 try {
546 return loader->getProperty(propName);
547 } catch (std::runtime_error &) {
548 }
549
550 // Try a MatrixWorkspace
551 try {
552 MatrixWorkspace_sptr childWS = loader->getProperty(propName);
553 return childWS;
554 } catch (std::runtime_error &) {
555 }
556
557 // EventWorkspace
558 try {
559 IEventWorkspace_sptr childWS = loader->getProperty(propName);
560 return childWS;
561 } catch (std::runtime_error &) {
562 }
563
564 // IMDEventWorkspace
565 try {
566 IMDEventWorkspace_sptr childWS = loader->getProperty(propName);
567 return childWS;
568 } catch (std::runtime_error &) {
569 }
570
571 // General IMDWorkspace
572 try {
573 IMDWorkspace_sptr childWS = loader->getProperty(propName);
574 return childWS;
575 } catch (std::runtime_error &) {
576 }
577
578 // ITableWorkspace?
579 try {
580 ITableWorkspace_sptr childWS = loader->getProperty(propName);
581 return childWS;
582 } catch (std::runtime_error &) {
583 }
584
585 // WorkspaceGroup?
586 try {
587 WorkspaceGroup_sptr childWS = loader->getProperty(propName);
588 return childWS;
589 } catch (std::runtime_error &) {
590 }
591
592 // Just workspace?
593 try {
594 Workspace_sptr childWS = loader->getProperty(propName);
595 return childWS;
596 } catch (std::runtime_error &) {
597 }
598
599 g_log.debug() << "Workspace property " << propName
600 << " did not return to MatrixWorkspace, EventWorkspace, "
601 "IMDEventWorkspace, IMDWorkspace\n";
602 return Workspace_sptr();
603}
604
605/*
606 * Overrides the default cancel() method. Calls cancel() on the actual loader.
607 */
609 if (m_loader) {
610 m_loader->cancel();
611 }
612}
613
622API::Workspace_sptr Load::loadFileToWs(const std::string &fileName, const std::string &wsName) {
623 auto loadAlg = createChildAlgorithm("Load", 1);
624
625 // Get the list properties for the concrete loader load algorithm
626 const std::vector<Kernel::Property *> &props = getProperties();
627
628 // Loop through and set the properties on the Child Algorithm
629 for (auto prop : props) {
630 const std::string &propName = prop->name();
631
632 if (this->existsProperty(propName)) {
633 if (propName == "Filename") {
634 loadAlg->setPropertyValue("Filename", fileName);
635 } else if (propName == "OutputWorkspace") {
636 loadAlg->setPropertyValue("OutputWorkspace", wsName);
637 } else {
638 loadAlg->setPropertyValue(propName, getPropertyValue(propName));
639 }
640 }
641 }
642
643 loadAlg->executeAsChildAlg();
644
645 Workspace_sptr ws = loadAlg->getProperty("OutputWorkspace");
646 // ws->setName(wsName);
647 AnalysisDataService::Instance().addOrReplace(wsName, ws);
648 m_loader = loadAlg;
649 return ws;
650}
651
661 WorkspaceGroup_sptr group1 = std::dynamic_pointer_cast<WorkspaceGroup>(ws1);
662 WorkspaceGroup_sptr group2 = std::dynamic_pointer_cast<WorkspaceGroup>(ws2);
663
664 if (group1 && group2) {
665 // If we're dealing with groups, then the child workspaces must be added
666 // separately - setProperty
667 // wont work otherwise.
668 std::vector<std::string> group1ChildWsNames = group1->getNames();
669 std::vector<std::string> group2ChildWsNames = group2->getNames();
670
671 if (group1ChildWsNames.size() != group2ChildWsNames.size())
672 throw std::runtime_error("Unable to add group workspaces with different "
673 "number of child workspaces.");
674
675 auto group1ChildWsName = group1ChildWsNames.begin();
676 auto group2ChildWsName = group2ChildWsNames.begin();
677
678 for (; group1ChildWsName != group1ChildWsNames.end(); ++group1ChildWsName, ++group2ChildWsName) {
679 Workspace_sptr group1ChildWs = group1->getItem(*group1ChildWsName);
680 Workspace_sptr group2ChildWs = group2->getItem(*group2ChildWsName);
681
682 auto plusAlg = createChildAlgorithm("Plus", 1);
683 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", group1ChildWs);
684 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", group2ChildWs);
685 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", group1ChildWs);
686 plusAlg->executeAsChildAlg();
687 }
688 } else if (!group1 && !group2) {
689 auto plusAlg = createChildAlgorithm("Plus", 1);
690 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", ws1);
691 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", ws2);
692 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", ws1);
693 plusAlg->executeAsChildAlg();
694 } else {
695 throw std::runtime_error("Unable to add a group workspace to a non-group workspace");
696 }
697
698 return ws1;
699}
700
708API::WorkspaceGroup_sptr Load::groupWsList(const std::vector<API::Workspace_sptr> &wsList) {
709 auto group = std::make_shared<WorkspaceGroup>();
710
711 for (const auto &ws : wsList) {
712 WorkspaceGroup_sptr isGroup = std::dynamic_pointer_cast<WorkspaceGroup>(ws);
713 // If the ws to add is already a group, then add its children individually.
714 if (isGroup) {
715 std::vector<std::string> childrenNames = isGroup->getNames();
716 size_t count = 1;
717 for (auto childName = childrenNames.begin(); childName != childrenNames.end(); ++childName, ++count) {
718 Workspace_sptr childWs = isGroup->getItem(*childName);
719 isGroup->remove(*childName);
720 // childWs->setName(isGroup->getName() + "_" +
721 // boost::lexical_cast<std::string>(count));
722 group->addWorkspace(childWs);
723 }
724
725 // Remove the old group from the ADS
726 AnalysisDataService::Instance().remove(isGroup->getName());
727 } else {
728 group->addWorkspace(ws);
729 }
730 }
731
732 return group;
733}
734} // namespace Mantid::DataHandling
std::string name
Definition Run.cpp:60
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
double value
The value of the point.
Definition FitMW.cpp:51
int count
counter
Definition Matrix.cpp:37
std::string getName(const IMDDimension &self)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
void setChildEndProgress(const double endProgress) const override
setting the child end progress
Definition Algorithm.h:256
bool existsProperty(const std::string &name) const override
Checks whether the named property is already in the list of managed property.
void removeProperty(const std::string &name, const bool delproperty=true) override
Removes the property from management.
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.
size_t propertyCount() const override
Count the number of properties under management.
Kernel::Logger & g_log
Definition Algorithm.h:422
void setChildStartProgress(const double startProgress) const override
setting the child start progress
Definition Algorithm.h:254
void declareOrReplaceProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add or replace property in the list of managed properties.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
const std::vector< Kernel::Property * > & getProperties() const override
Get the list of managed properties.
const Poco::AbstractObserver & progressObserver() const
Return a reference to the algorithm's object that is reporting progress.
A specialized class for dealing with file properties.
An interface that is implemented by WorkspaceProperty.
A property to allow a user to specify multiple files to load.
A property class for workspaces.
API::WorkspaceGroup_sptr groupWsList(const std::vector< API::Workspace_sptr > &wsList)
Manually group workspaces.
Definition Load.cpp:708
API::Workspace_sptr plusWs(API::Workspace_sptr ws1, const API::Workspace_sptr &ws2)
Plus two workspaces together, "in place".
Definition Load.cpp:660
void cancel() override
Overrides the cancel() method to call m_loader->cancel()
Definition Load.cpp:608
void setOutputProperties(const API::IAlgorithm_sptr &loader)
Set the output properties.
Definition Load.cpp:523
void setPropertyValue(const std::string &name, const std::string &value) override
Override setPropertyValue.
Definition Load.cpp:103
API::Workspace_sptr getOutputWorkspace(const std::string &propName, const API::IAlgorithm_sptr &loader) const
Retrieve a pointer to the output workspace from the Child Algorithm.
Definition Load.cpp:543
void exec() override
Execute.
Definition Load.cpp:316
API::IAlgorithm_sptr m_loader
The actual loader.
Definition Load.h:85
static std::recursive_mutex m_mutex
Mutex for temporary fix for #5963.
Definition Load.h:90
API::IAlgorithm_sptr createLoader(const double startProgress=-1.0, const double endProgress=-1.0, const bool logging=true) const
Create the concrete instance use for the actual loading.
Definition Load.cpp:476
void init() override
Initialize the static base properties.
Definition Load.cpp:268
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition Load.h:26
std::string m_filenamePropName
The name of the property that will be passed the property from our Filename.
Definition Load.h:88
void loadSingleFile()
Called when there is only one file to load.
Definition Load.cpp:349
void findFilenameProperty(const API::IAlgorithm_sptr &loader)
Definition Load.cpp:202
void loadMultipleFiles()
Called when there are multiple files to load.
Definition Load.cpp:377
API::IAlgorithm_sptr getFileLoader(const std::string &filePath)
This method returns shared pointer to a load algorithm which got the highest preference after file ch...
Definition Load.cpp:180
void setUpLoader(const API::IAlgorithm_sptr &loader, const double startProgress=-1.0, const double endProgress=-1.0, const bool logging=true) const
Set the loader option for use as a Child Algorithm.
Definition Load.cpp:496
std::unordered_set< std::string > m_baseProps
The base properties.
Definition Load.h:83
API::Workspace_sptr loadFileToWs(const std::string &fileName, const std::string &wsName)
Load a file to a given workspace name.
Definition Load.cpp:622
void declareLoaderProperties(const API::IAlgorithm_sptr &loader)
Declare any additional input properties from the concrete loader.
Definition Load.cpp:235
Exception for when an item is already in a collection.
Definition Exception.h:164
Exception for when an item is not found in a collection.
Definition Exception.h:145
A class that holds information about a facility.
const std::vector< std::string > & extensions() const
Returns a list of file extensions.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
Base class for properties.
Definition Property.h:94
const std::string & documentation() const
Get the property's documentation string.
Definition Property.cpp:78
virtual Property * clone() const =0
'Virtual copy constructor'
const std::string & name() const
Get the property's name.
Definition Property.cpp:63
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
std::shared_ptr< IEventWorkspace > IEventWorkspace_sptr
shared pointer to Mantid::API::IEventWorkspace
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition Algorithm.h:52
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Output
An output workspace.
Definition Property.h:54