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 extensions only
144 if ((ifl && ifl->loadMutipleAsOne()) || (iflNexus && iflNexus->loadMutipleAsOne())) {
145 // do nothing
146 } else {
147 loader = getFileLoader(fileNames[i]);
148
149 if (loaderName != loader->name() || firstFileLoaderVersion != loader->version())
150 throw std::runtime_error("Cannot load multiple files when more "
151 "than one Loader is needed.");
152 }
153 }
154 }
155
156 assert(loader); // (getFileLoader should throw if no loader is found.)
158 }
159 }
160}
161
162//--------------------------------------------------------------------------
163// Private methods
164//--------------------------------------------------------------------------
165
172API::IAlgorithm_sptr Load::getFileLoader(const std::string &filePath) {
173 API::IAlgorithm_sptr winningLoader;
174 try {
175 winningLoader = API::FileLoaderRegistry::Instance().chooseLoader(filePath);
176 } catch (Exception::NotFoundError &) {
177 // Clear what may have been here previously
178 setPropertyValue("LoaderName", "");
179 setProperty("LoaderVersion", -1);
180 throw std::runtime_error("Cannot find an algorithm that is able to load \"" + filePath +
181 "\".\n"
182 "Check that the file is a supported type.");
183 }
184 winningLoader->initialize();
185 setUpLoader(winningLoader, 0, 1);
186
187 findFilenameProperty(winningLoader);
188
189 setPropertyValue("LoaderName", winningLoader->name());
190 setProperty("LoaderVersion", winningLoader->version());
191 return winningLoader;
192}
193
195 // Use the first file property as the main Filename
196 m_filenamePropName.clear();
197 const auto &props = loader->getProperties();
198 for (auto const &prop : props) {
199 auto const *multiprop = dynamic_cast<API::MultipleFileProperty *>(prop);
200 auto const *singleprop = dynamic_cast<API::FileProperty *>(prop);
201 if (multiprop) {
202 m_filenamePropName = multiprop->name();
203 break;
204 }
205 if (singleprop) {
206 m_filenamePropName = singleprop->name();
207 break;
208 }
209 }
210
211 // throw an exception if somehting nothing was found
212 if (m_filenamePropName.empty()) {
213 // unset member variables
214 setPropertyValue("LoaderName", "");
215 setProperty("LoaderVersion", -1);
216
217 std::stringstream msg;
218 msg << "Cannot find FileProperty on \"" << loader->name() << "\" v" << loader->version() << " algorithm.";
219 throw std::runtime_error(msg.str());
220 }
221}
222
228 // If we have switch loaders then the concrete loader will have different
229 // properties
230 // so take care of ensuring Load has the correct ones
231 // THIS IS A COPY as the properties are mutated as we move through them
232 const std::vector<Property *> existingProps = this->getProperties();
233 for (auto existingProp : existingProps) {
234 const std::string &propName = existingProp->name();
235 // Wipe all properties except the Load native ones
236 if (m_baseProps.find(propName) == m_baseProps.end()) {
237 this->removeProperty(propName);
238 }
239 }
240
241 const std::vector<Property *> &loaderProps = loader->getProperties();
242 size_t numProps(loaderProps.size());
243 for (size_t i = 0; i < numProps; ++i) {
244 Property const *loadProp = loaderProps[i];
245 if (loadProp->name() == m_filenamePropName)
246 continue;
247 try {
248 auto propClone = std::unique_ptr<Property>(loadProp->clone());
249 propClone->clearSettings(); // Get rid of special settings because it
250 // does not work in custom GUI.
251 declareProperty(std::move(propClone), loadProp->documentation());
252 } catch (Exception::ExistsError &) {
253 // Already exists as a static property
254 continue;
255 }
256 }
257}
258
261 // Take extensions first from Facility object
262 const FacilityInfo &defaultFacility = Mantid::Kernel::ConfigService::Instance().getFacility();
263 std::vector<std::string> exts = defaultFacility.extensions();
264 // Add in some other known extensions
265 exts.emplace_back(".xml");
266 exts.emplace_back(".dat");
267 exts.emplace_back(".txt");
268 exts.emplace_back(".csv");
269 exts.emplace_back(".spe");
270 exts.emplace_back(".grp");
271 exts.emplace_back(".nxspe");
272 exts.emplace_back(".h5");
273 exts.emplace_back(".hd5");
274 exts.emplace_back(".sqw");
275 exts.emplace_back(".fits");
276 exts.emplace_back(".bin");
277 exts.emplace_back(".edb");
278
279 declareProperty(std::make_unique<MultipleFileProperty>("Filename", exts),
280 "The name of the file(s) to read, including the full or relative "
281 "path. (N.B. case sensitive if running on Linux). Multiple runs "
282 "can be loaded and added together, e.g. INST10,11+12,13.ext");
283 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>("OutputWorkspace", "", Direction::Output),
284 "The name of the workspace that will be created, filled with the "
285 "read-in data and stored in the Analysis Data Service. Some algorithms "
286 "can created additional OutputWorkspace properties on the fly, e.g. "
287 "multi-period data.");
288
289 declareProperty("LoaderName", std::string(""),
290 "When an algorithm has been found that will load the given "
291 "file, its name is set here.",
293 declareProperty("LoaderVersion", -1,
294 "When an algorithm has been found that "
295 "will load the given file, its version "
296 "is set here.",
298 // Save for later what the base Load properties are
299 const std::vector<Property *> &props = this->getProperties();
300 for (size_t i = 0; i < this->propertyCount(); ++i) {
301 m_baseProps.insert(props[i]->name());
302 }
303}
304
309 std::vector<std::vector<std::string>> fileNames = getProperty("Filename");
310
311 // Test for loading as a single file
312 if (!m_loader)
313 m_loader = getFileLoader(fileNames[0][0]);
314 auto ifl = std::dynamic_pointer_cast<IFileLoader<Kernel::FileDescriptor>>(m_loader);
315 auto iflNexus = std::dynamic_pointer_cast<IFileLoader<Nexus::NexusDescriptor>>(m_loader);
316
317 if (isSingleFile(fileNames) || (ifl && ifl->loadMutipleAsOne()) || (iflNexus && iflNexus->loadMutipleAsOne())) {
318 // This is essentially just the same code that was called before multiple
319 // files were supported.
321 } else {
322 // Code that supports multiple file loading.
324 }
325
326 // Set the remaining properties of the loader
328
335 if (m_loader) {
336 setPropertyValue("LoaderName", m_loader->name());
337 setProperty("LoaderVersion", m_loader->version());
338 }
339}
340
342 if (!m_loader) {
344 }
345
346 g_log.information() << "Using " << m_loader->name() << " version " << m_loader->version() << ".\n";
348 const std::vector<Kernel::Property *> &loader_props = m_loader->getProperties();
349
350 // Loop through and set the properties on the Child Algorithm
351 std::vector<Kernel::Property *>::const_iterator itr;
352 for (itr = loader_props.begin(); itr != loader_props.end(); ++itr) {
353 const std::string propName = (*itr)->name();
354 if (this->existsProperty(propName)) {
355 m_loader->setPropertyValue(propName, getPropertyValue(propName));
356 } else if (propName == m_filenamePropName) {
357 m_loader->setPropertyValue(propName, getPropertyValue("Filename"));
358 }
359 }
360
361 // Execute the concrete loader
362 m_loader->execute();
363
364 // Set the output Workspace
365 Workspace_sptr wks = getOutputWorkspace("OutputWorkspace", m_loader);
366 setProperty("OutputWorkspace", wks);
367}
368
370 // allFilenames contains "rows" of filenames. If the row has more than 1 file
371 // in it
372 // then that row is to be summed across each file in the row
373 const std::vector<std::vector<std::string>> allFilenames = getProperty("Filename");
374 std::string outputWsName = getProperty("OutputWorkspace");
375
376 std::vector<std::string> wsNames(allFilenames.size());
377 std::transform(allFilenames.begin(), allFilenames.end(), wsNames.begin(), generateWsNameFromFileNames);
378
379 auto wsName = wsNames.cbegin();
380 assert(allFilenames.size() == wsNames.size());
381
382 std::vector<API::Workspace_sptr> loadedWsList;
383 loadedWsList.reserve(allFilenames.size());
384
385 Workspace_sptr tempWs;
386
387 // Cycle through the filenames and wsNames.
388 for (auto filenames = allFilenames.cbegin(); filenames != allFilenames.cend(); ++filenames, ++wsName) {
389 auto filename = filenames->cbegin();
390 Workspace_sptr sumWS = loadFileToWs(*filename, *wsName);
391
392 ++filename;
393 for (; filename != filenames->cend(); ++filename) {
394 tempWs = loadFileToWs(*filename, "__@loadsum_temp@");
395 sumWS = plusWs(sumWS, tempWs);
396 }
397
398 API::WorkspaceGroup_sptr group = std::dynamic_pointer_cast<WorkspaceGroup>(sumWS);
399 if (group) {
400 std::vector<std::string> childWsNames = group->getNames();
401 auto childWsName = childWsNames.begin();
402 size_t count = 1;
403 for (; childWsName != childWsNames.end(); ++childWsName, ++count) {
404 Workspace_sptr childWs = group->getItem(*childWsName);
405 const std::string childName = group->getName() + "_" + std::to_string(count);
406 API::AnalysisDataService::Instance().addOrReplace(childName, childWs);
407 // childWs->setName(group->getName() + "_" +
408 // boost::lexical_cast<std::string>(count));
409 }
410 }
411 // Add the sum to the list of loaded workspace names.
412 loadedWsList.emplace_back(sumWS);
413 }
414
415 // If we only have one loaded ws, set it as the output.
416 if (loadedWsList.size() == 1) {
417 setProperty("OutputWorkspace", loadedWsList[0]);
418 AnalysisDataService::Instance().rename(loadedWsList[0]->getName(), outputWsName);
419 }
420 // Else we have multiple loaded workspaces - group them and set the group as
421 // output.
422 else {
424 setProperty("OutputWorkspace", group);
425
426 std::vector<std::string> childWsNames = group->getNames();
427 size_t count = 1;
428 for (auto &childWsName : childWsNames) {
429 if (childWsName == outputWsName) {
430 Mantid::API::Workspace_sptr child = group->getItem(childWsName);
431 // child->setName(child->getName() + "_" +
432 // boost::lexical_cast<std::string>(count));
433 const std::string childName = child->getName() + "_" + std::to_string(count);
434 API::AnalysisDataService::Instance().addOrReplace(childName, child);
435 count++;
436 }
437 }
438
439 childWsNames = group->getNames();
440 count = 1;
441 for (auto &childWsName : childWsNames) {
442 Workspace_sptr childWs = group->getItem(childWsName);
443 std::string outWsPropName = "OutputWorkspace_" + std::to_string(count);
444 ++count;
445 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>(outWsPropName, childWsName, Direction::Output));
446 setProperty(outWsPropName, childWs);
447 }
448 }
449
450 // Clean up.
451 if (tempWs) {
452 Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("DeleteWorkspace");
453 alg->initialize();
454 alg->setChild(true);
455 alg->setProperty("Workspace", tempWs);
456 alg->execute();
457 }
458}
459
468API::IAlgorithm_sptr Load::createLoader(const double startProgress, const double endProgress,
469 const bool logging) const {
470 std::string loaderName = getPropertyValue("LoaderName");
471 int loaderVersion = getProperty("LoaderVersion");
472 auto loader = API::AlgorithmManager::Instance().createUnmanaged(loaderName, loaderVersion);
473 loader->initialize();
474 if (!loader) {
475 throw std::runtime_error("Cannot create loader for \"" + getPropertyValue("Filename") + "\"");
476 }
477 setUpLoader(loader, startProgress, endProgress, logging);
478 return loader;
479}
480
488void Load::setUpLoader(const API::IAlgorithm_sptr &loader, const double startProgress, const double endProgress,
489 const bool logging) const {
490 // Set as a child so that we are in control of output storage
491 loader->setChild(true);
492 loader->setLogging(logging);
493 // If output workspaces are nameless, give them a temporary name to satisfy
494 // validator
495 const std::vector<Property *> &props = loader->getProperties();
496 for (auto prop : props) {
497 auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
498
499 if (wsProp && !wsProp->isOptional() && prop->direction() == Direction::Output) {
500 if (prop->value().empty())
501 prop->setValue("LoadChildWorkspace");
502 }
503 }
504 if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) {
505 loader->addObserver(this->progressObserver());
506 setChildStartProgress(startProgress);
507 setChildEndProgress(endProgress);
508 }
509}
510
516 // Set output properties by looping the loaders properties and taking them until we have none left
517 while (loader->propertyCount() > 0) {
518 auto prop = loader->takeProperty(0);
519 if (prop && prop->direction() == Direction::Output) {
520 // We skip OutputWorkspace as this is set already from loadSingleFile and loadMultipleFiles
521 if (prop->name() != "OutputWorkspace")
522 declareOrReplaceProperty(std::move(prop));
523 }
524 }
525}
526
535API::Workspace_sptr Load::getOutputWorkspace(const std::string &propName, const API::IAlgorithm_sptr &loader) const {
536 // @todo Need to try and find a better way using the getValue methods
537 try {
538 return loader->getProperty(propName);
539 } catch (std::runtime_error &) {
540 }
541
542 // Try a MatrixWorkspace
543 try {
544 MatrixWorkspace_sptr childWS = loader->getProperty(propName);
545 return childWS;
546 } catch (std::runtime_error &) {
547 }
548
549 // EventWorkspace
550 try {
551 IEventWorkspace_sptr childWS = loader->getProperty(propName);
552 return childWS;
553 } catch (std::runtime_error &) {
554 }
555
556 // IMDEventWorkspace
557 try {
558 IMDEventWorkspace_sptr childWS = loader->getProperty(propName);
559 return childWS;
560 } catch (std::runtime_error &) {
561 }
562
563 // General IMDWorkspace
564 try {
565 IMDWorkspace_sptr childWS = loader->getProperty(propName);
566 return childWS;
567 } catch (std::runtime_error &) {
568 }
569
570 // ITableWorkspace?
571 try {
572 ITableWorkspace_sptr childWS = loader->getProperty(propName);
573 return childWS;
574 } catch (std::runtime_error &) {
575 }
576
577 // WorkspaceGroup?
578 try {
579 WorkspaceGroup_sptr childWS = loader->getProperty(propName);
580 return childWS;
581 } catch (std::runtime_error &) {
582 }
583
584 // Just workspace?
585 try {
586 Workspace_sptr childWS = loader->getProperty(propName);
587 return childWS;
588 } catch (std::runtime_error &) {
589 }
590
591 g_log.debug() << "Workspace property " << propName
592 << " did not return to MatrixWorkspace, EventWorkspace, "
593 "IMDEventWorkspace, IMDWorkspace\n";
594 return Workspace_sptr();
595}
596
597/*
598 * Overrides the default cancel() method. Calls cancel() on the actual loader.
599 */
601 if (m_loader) {
602 m_loader->cancel();
603 }
604}
605
614API::Workspace_sptr Load::loadFileToWs(const std::string &fileName, const std::string &wsName) {
615 auto loadAlg = createChildAlgorithm("Load", 1);
616
617 // Get the list properties for the concrete loader load algorithm
618 const std::vector<Kernel::Property *> &props = getProperties();
619
620 // Loop through and set the properties on the Child Algorithm
621 for (auto prop : props) {
622 const std::string &propName = prop->name();
623
624 if (this->existsProperty(propName)) {
625 if (propName == "Filename") {
626 loadAlg->setPropertyValue("Filename", fileName);
627 } else if (propName == "OutputWorkspace") {
628 loadAlg->setPropertyValue("OutputWorkspace", wsName);
629 } else {
630 loadAlg->setPropertyValue(propName, getPropertyValue(propName));
631 }
632 }
633 }
634
635 loadAlg->executeAsChildAlg();
636
637 Workspace_sptr ws = loadAlg->getProperty("OutputWorkspace");
638 // ws->setName(wsName);
639 AnalysisDataService::Instance().addOrReplace(wsName, ws);
640 m_loader = loadAlg;
641 return ws;
642}
643
653 WorkspaceGroup_sptr group1 = std::dynamic_pointer_cast<WorkspaceGroup>(ws1);
654 WorkspaceGroup_sptr group2 = std::dynamic_pointer_cast<WorkspaceGroup>(ws2);
655
656 if (group1 && group2) {
657 // If we're dealing with groups, then the child workspaces must be added
658 // separately - setProperty
659 // wont work otherwise.
660 std::vector<std::string> group1ChildWsNames = group1->getNames();
661 std::vector<std::string> group2ChildWsNames = group2->getNames();
662
663 if (group1ChildWsNames.size() != group2ChildWsNames.size())
664 throw std::runtime_error("Unable to add group workspaces with different "
665 "number of child workspaces.");
666
667 auto group1ChildWsName = group1ChildWsNames.begin();
668 auto group2ChildWsName = group2ChildWsNames.begin();
669
670 for (; group1ChildWsName != group1ChildWsNames.end(); ++group1ChildWsName, ++group2ChildWsName) {
671 Workspace_sptr group1ChildWs = group1->getItem(*group1ChildWsName);
672 Workspace_sptr group2ChildWs = group2->getItem(*group2ChildWsName);
673
674 auto plusAlg = createChildAlgorithm("Plus", 1);
675 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", group1ChildWs);
676 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", group2ChildWs);
677 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", group1ChildWs);
678 plusAlg->executeAsChildAlg();
679 }
680 } else if (!group1 && !group2) {
681 auto plusAlg = createChildAlgorithm("Plus", 1);
682 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", ws1);
683 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", ws2);
684 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", ws1);
685 plusAlg->executeAsChildAlg();
686 } else {
687 throw std::runtime_error("Unable to add a group workspace to a non-group workspace");
688 }
689
690 return ws1;
691}
692
700API::WorkspaceGroup_sptr Load::groupWsList(const std::vector<API::Workspace_sptr> &wsList) {
701 auto group = std::make_shared<WorkspaceGroup>();
702
703 for (const auto &ws : wsList) {
704 WorkspaceGroup_sptr isGroup = std::dynamic_pointer_cast<WorkspaceGroup>(ws);
705 // If the ws to add is already a group, then add its children individually.
706 if (isGroup) {
707 std::vector<std::string> childrenNames = isGroup->getNames();
708 size_t count = 1;
709 for (auto childName = childrenNames.begin(); childName != childrenNames.end(); ++childName, ++count) {
710 Workspace_sptr childWs = isGroup->getItem(*childName);
711 isGroup->remove(*childName);
712 // childWs->setName(isGroup->getName() + "_" +
713 // boost::lexical_cast<std::string>(count));
714 group->addWorkspace(childWs);
715 }
716
717 // Remove the old group from the ADS
718 AnalysisDataService::Instance().remove(isGroup->getName());
719 } else {
720 group->addWorkspace(ws);
721 }
722 }
723
724 return group;
725}
726} // namespace Mantid::DataHandling
std::string name
Definition Run.cpp:60
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:547
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:257
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:426
void setChildStartProgress(const double startProgress) const override
setting the child start progress
Definition Algorithm.h:255
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:700
API::Workspace_sptr plusWs(API::Workspace_sptr ws1, const API::Workspace_sptr &ws2)
Plus two workspaces together, "in place".
Definition Load.cpp:652
void cancel() override
Overrides the cancel() method to call m_loader->cancel()
Definition Load.cpp:600
void setOutputProperties(const API::IAlgorithm_sptr &loader)
Set the output properties.
Definition Load.cpp:515
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:535
void exec() override
Execute.
Definition Load.cpp:308
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:468
void init() override
Initialize the static base properties.
Definition Load.cpp:260
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:341
void findFilenameProperty(const API::IAlgorithm_sptr &loader)
Definition Load.cpp:194
void loadMultipleFiles()
Called when there are multiple files to load.
Definition Load.cpp:369
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:172
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:488
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:614
void declareLoaderProperties(const API::IAlgorithm_sptr &loader)
Declare any additional input properties from the concrete loader.
Definition Load.cpp:227
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:95
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:55