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