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 <algorithm>
22#include <cctype>
23#include <cstdio>
24#include <filesystem>
25#include <functional>
26#include <numeric>
27#include <set>
28
29namespace {
39bool isSingleFile(const std::vector<std::vector<std::string>> &fileNames) {
40 return fileNames.size() == 1 && fileNames[0u].size() == 1;
41}
42
52std::string generateWsNameFromFileNames(const std::vector<std::string> &filenames) {
53 std::string wsName;
54
55 for (auto &filename : filenames) {
56 if (!wsName.empty())
57 wsName += "_";
58
59 std::filesystem::path path(filename);
60 wsName += path.stem().string();
61 }
62
63 return wsName;
64}
65
70std::vector<std::string> flattenVecOfVec(std::vector<std::vector<std::string>> vecOfVec) {
71 std::vector<std::string> flattenedVec;
72
73 std::vector<std::vector<std::string>>::const_iterator it = vecOfVec.begin();
74
75 for (; it != vecOfVec.end(); ++it) {
76 flattenedVec.insert(flattenedVec.end(), it->begin(), it->end());
77 }
78
79 return flattenedVec;
80}
81} // namespace
82
83namespace Mantid::DataHandling {
84// Register the algorithm into the algorithm factory
86
87// The mutex
88std::recursive_mutex Load::m_mutex;
89
90using namespace Kernel;
91using namespace API;
92
93//--------------------------------------------------------------------------
94// Public methods
95//--------------------------------------------------------------------------
96
104void Load::setPropertyValue(const std::string &name, const std::string &value) {
105 // Call base class method in all cases.
106 // For a filename property is deals with resolving the full path.
108
109 std::string NAME(name);
110 std::transform(name.begin(), name.end(), NAME.begin(), toupper);
111 if (NAME == "FILENAME") {
112 // Get back full path before passing to getFileLoader method, and also
113 // find out whether this is a multi file load.
114 std::vector<std::string> fileNames = flattenVecOfVec(getProperty("Filename"));
115 // If it's a single file load, then it's fine to change loader.
116 if (fileNames.size() == 1) {
117 auto loader = getFileLoader(getPropertyValue(name));
118 assert(loader); // (getFileLoader should throw if no loader is found.)
120 m_loader = std::move(loader);
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 firstFileLoaderVersion = 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<Nexus::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() || firstFileLoaderVersion != 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 const &prop : props) {
212 auto const *multiprop = dynamic_cast<API::MultipleFileProperty *>(prop);
213 auto const *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 &propName = existingProp->name();
249 // Wipe all properties except the Load native ones
250 if (m_baseProps.find(propName) == m_baseProps.end()) {
251 this->removeProperty(propName);
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 const *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 if (!m_loader)
327 m_loader = getFileLoader(fileNames[0][0]);
328 auto ifl = std::dynamic_pointer_cast<IFileLoader<Kernel::FileDescriptor>>(m_loader);
329 auto iflNexus = std::dynamic_pointer_cast<IFileLoader<Nexus::NexusDescriptor>>(m_loader);
330
331 if (isSingleFile(fileNames) || (ifl && ifl->loadMutipleAsOne()) || (iflNexus && iflNexus->loadMutipleAsOne())) {
332 // This is essentially just the same code that was called before multiple
333 // files were supported.
335 } else {
336 // Code that supports multiple file loading.
338 }
339
340 // Set the remaining properties of the loader
342
349 if (m_loader) {
350 setPropertyValue("LoaderName", m_loader->name());
351 setProperty("LoaderVersion", m_loader->version());
352 }
353}
354
356 if (!m_loader) {
358 }
359
360 g_log.information() << "Using " << m_loader->name() << " version " << m_loader->version() << ".\n";
362 const std::vector<Kernel::Property *> &loader_props = m_loader->getProperties();
363
364 // Loop through and set the properties on the Child Algorithm
365 std::vector<Kernel::Property *>::const_iterator itr;
366 for (itr = loader_props.begin(); itr != loader_props.end(); ++itr) {
367 const std::string propName = (*itr)->name();
368 if (this->existsProperty(propName)) {
369 m_loader->setPropertyValue(propName, getPropertyValue(propName));
370 } else if (propName == m_filenamePropName) {
371 m_loader->setPropertyValue(propName, getPropertyValue("Filename"));
372 }
373 }
374
375 // Execute the concrete loader
376 m_loader->execute();
377
378 // Set the output Workspace
379 Workspace_sptr wks = getOutputWorkspace("OutputWorkspace", m_loader);
380 setProperty("OutputWorkspace", wks);
381}
382
384 // allFilenames contains "rows" of filenames. If the row has more than 1 file
385 // in it
386 // then that row is to be summed across each file in the row
387 const std::vector<std::vector<std::string>> allFilenames = getProperty("Filename");
388 std::string outputWsName = getProperty("OutputWorkspace");
389
390 std::vector<std::string> wsNames(allFilenames.size());
391 std::transform(allFilenames.begin(), allFilenames.end(), wsNames.begin(), generateWsNameFromFileNames);
392
393 auto wsName = wsNames.cbegin();
394 assert(allFilenames.size() == wsNames.size());
395
396 std::vector<API::Workspace_sptr> loadedWsList;
397 loadedWsList.reserve(allFilenames.size());
398
399 Workspace_sptr tempWs;
400
401 // Cycle through the filenames and wsNames.
402 for (auto filenames = allFilenames.cbegin(); filenames != allFilenames.cend(); ++filenames, ++wsName) {
403 auto filename = filenames->cbegin();
404 Workspace_sptr sumWS = loadFileToWs(*filename, *wsName);
405
406 ++filename;
407 for (; filename != filenames->cend(); ++filename) {
408 tempWs = loadFileToWs(*filename, "__@loadsum_temp@");
409 sumWS = plusWs(sumWS, tempWs);
410 }
411
412 API::WorkspaceGroup_sptr group = std::dynamic_pointer_cast<WorkspaceGroup>(sumWS);
413 if (group) {
414 std::vector<std::string> childWsNames = group->getNames();
415 auto childWsName = childWsNames.begin();
416 size_t count = 1;
417 for (; childWsName != childWsNames.end(); ++childWsName, ++count) {
418 Workspace_sptr childWs = group->getItem(*childWsName);
419 const std::string childName = group->getName() + "_" + std::to_string(count);
420 API::AnalysisDataService::Instance().addOrReplace(childName, childWs);
421 // childWs->setName(group->getName() + "_" +
422 // boost::lexical_cast<std::string>(count));
423 }
424 }
425 // Add the sum to the list of loaded workspace names.
426 loadedWsList.emplace_back(sumWS);
427 }
428
429 // If we only have one loaded ws, set it as the output.
430 if (loadedWsList.size() == 1) {
431 setProperty("OutputWorkspace", loadedWsList[0]);
432 AnalysisDataService::Instance().rename(loadedWsList[0]->getName(), outputWsName);
433 }
434 // Else we have multiple loaded workspaces - group them and set the group as
435 // output.
436 else {
438 setProperty("OutputWorkspace", group);
439
440 std::vector<std::string> childWsNames = group->getNames();
441 size_t count = 1;
442 for (auto &childWsName : childWsNames) {
443 if (childWsName == outputWsName) {
444 Mantid::API::Workspace_sptr child = group->getItem(childWsName);
445 // child->setName(child->getName() + "_" +
446 // boost::lexical_cast<std::string>(count));
447 const std::string childName = child->getName() + "_" + std::to_string(count);
448 API::AnalysisDataService::Instance().addOrReplace(childName, child);
449 count++;
450 }
451 }
452
453 childWsNames = group->getNames();
454 count = 1;
455 for (auto &childWsName : childWsNames) {
456 Workspace_sptr childWs = group->getItem(childWsName);
457 std::string outWsPropName = "OutputWorkspace_" + std::to_string(count);
458 ++count;
459 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>(outWsPropName, childWsName, Direction::Output));
460 setProperty(outWsPropName, childWs);
461 }
462 }
463
464 // Clean up.
465 if (tempWs) {
466 Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("DeleteWorkspace");
467 alg->initialize();
468 alg->setChild(true);
469 alg->setProperty("Workspace", tempWs);
470 alg->execute();
471 }
472}
473
482API::IAlgorithm_sptr Load::createLoader(const double startProgress, const double endProgress,
483 const bool logging) const {
484 std::string loaderName = getPropertyValue("LoaderName");
485 int loaderVersion = getProperty("LoaderVersion");
486 auto loader = API::AlgorithmManager::Instance().createUnmanaged(loaderName, loaderVersion);
487 loader->initialize();
488 if (!loader) {
489 throw std::runtime_error("Cannot create loader for \"" + getPropertyValue("Filename") + "\"");
490 }
491 setUpLoader(loader, startProgress, endProgress, logging);
492 return loader;
493}
494
502void Load::setUpLoader(const API::IAlgorithm_sptr &loader, const double startProgress, const double endProgress,
503 const bool logging) const {
504 // Set as a child so that we are in control of output storage
505 loader->setChild(true);
506 loader->setLogging(logging);
507 // If output workspaces are nameless, give them a temporary name to satisfy
508 // validator
509 const std::vector<Property *> &props = loader->getProperties();
510 for (auto prop : props) {
511 auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
512
513 if (wsProp && !wsProp->isOptional() && prop->direction() == Direction::Output) {
514 if (prop->value().empty())
515 prop->setValue("LoadChildWorkspace");
516 }
517 }
518 if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) {
519 loader->addObserver(this->progressObserver());
520 setChildStartProgress(startProgress);
521 setChildEndProgress(endProgress);
522 }
523}
524
530 // Set output properties by looping the loaders properties and taking them until we have none left
531 while (loader->propertyCount() > 0) {
532 auto prop = loader->takeProperty(0);
533 if (prop && prop->direction() == Direction::Output) {
534 // We skip OutputWorkspace as this is set already from loadSingleFile and loadMultipleFiles
535 if (prop->name() != "OutputWorkspace")
536 declareOrReplaceProperty(std::move(prop));
537 }
538 }
539}
540
549API::Workspace_sptr Load::getOutputWorkspace(const std::string &propName, const API::IAlgorithm_sptr &loader) const {
550 // @todo Need to try and find a better way using the getValue methods
551 try {
552 return loader->getProperty(propName);
553 } catch (std::runtime_error &) {
554 }
555
556 // Try a MatrixWorkspace
557 try {
558 MatrixWorkspace_sptr childWS = loader->getProperty(propName);
559 return childWS;
560 } catch (std::runtime_error &) {
561 }
562
563 // EventWorkspace
564 try {
565 IEventWorkspace_sptr childWS = loader->getProperty(propName);
566 return childWS;
567 } catch (std::runtime_error &) {
568 }
569
570 // IMDEventWorkspace
571 try {
572 IMDEventWorkspace_sptr childWS = loader->getProperty(propName);
573 return childWS;
574 } catch (std::runtime_error &) {
575 }
576
577 // General IMDWorkspace
578 try {
579 IMDWorkspace_sptr childWS = loader->getProperty(propName);
580 return childWS;
581 } catch (std::runtime_error &) {
582 }
583
584 // ITableWorkspace?
585 try {
586 ITableWorkspace_sptr childWS = loader->getProperty(propName);
587 return childWS;
588 } catch (std::runtime_error &) {
589 }
590
591 // WorkspaceGroup?
592 try {
593 WorkspaceGroup_sptr childWS = loader->getProperty(propName);
594 return childWS;
595 } catch (std::runtime_error &) {
596 }
597
598 // Just workspace?
599 try {
600 Workspace_sptr childWS = loader->getProperty(propName);
601 return childWS;
602 } catch (std::runtime_error &) {
603 }
604
605 g_log.debug() << "Workspace property " << propName
606 << " did not return to MatrixWorkspace, EventWorkspace, "
607 "IMDEventWorkspace, IMDWorkspace\n";
608 return Workspace_sptr();
609}
610
611/*
612 * Overrides the default cancel() method. Calls cancel() on the actual loader.
613 */
615 if (m_loader) {
616 m_loader->cancel();
617 }
618}
619
628API::Workspace_sptr Load::loadFileToWs(const std::string &fileName, const std::string &wsName) {
629 auto loadAlg = createChildAlgorithm("Load", 1);
630
631 // Get the list properties for the concrete loader load algorithm
632 const std::vector<Kernel::Property *> &props = getProperties();
633
634 // Loop through and set the properties on the Child Algorithm
635 for (auto prop : props) {
636 const std::string &propName = prop->name();
637
638 if (this->existsProperty(propName)) {
639 if (propName == "Filename") {
640 loadAlg->setPropertyValue("Filename", fileName);
641 } else if (propName == "OutputWorkspace") {
642 loadAlg->setPropertyValue("OutputWorkspace", wsName);
643 } else {
644 loadAlg->setPropertyValue(propName, getPropertyValue(propName));
645 }
646 }
647 }
648
649 loadAlg->executeAsChildAlg();
650
651 Workspace_sptr ws = loadAlg->getProperty("OutputWorkspace");
652 // ws->setName(wsName);
653 AnalysisDataService::Instance().addOrReplace(wsName, ws);
654 m_loader = loadAlg;
655 return ws;
656}
657
667 WorkspaceGroup_sptr group1 = std::dynamic_pointer_cast<WorkspaceGroup>(ws1);
668 WorkspaceGroup_sptr group2 = std::dynamic_pointer_cast<WorkspaceGroup>(ws2);
669
670 if (group1 && group2) {
671 // If we're dealing with groups, then the child workspaces must be added
672 // separately - setProperty
673 // wont work otherwise.
674 std::vector<std::string> group1ChildWsNames = group1->getNames();
675 std::vector<std::string> group2ChildWsNames = group2->getNames();
676
677 if (group1ChildWsNames.size() != group2ChildWsNames.size())
678 throw std::runtime_error("Unable to add group workspaces with different "
679 "number of child workspaces.");
680
681 auto group1ChildWsName = group1ChildWsNames.begin();
682 auto group2ChildWsName = group2ChildWsNames.begin();
683
684 for (; group1ChildWsName != group1ChildWsNames.end(); ++group1ChildWsName, ++group2ChildWsName) {
685 Workspace_sptr group1ChildWs = group1->getItem(*group1ChildWsName);
686 Workspace_sptr group2ChildWs = group2->getItem(*group2ChildWsName);
687
688 auto plusAlg = createChildAlgorithm("Plus", 1);
689 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", group1ChildWs);
690 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", group2ChildWs);
691 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", group1ChildWs);
692 plusAlg->executeAsChildAlg();
693 }
694 } else if (!group1 && !group2) {
695 auto plusAlg = createChildAlgorithm("Plus", 1);
696 plusAlg->setProperty<Workspace_sptr>("LHSWorkspace", ws1);
697 plusAlg->setProperty<Workspace_sptr>("RHSWorkspace", ws2);
698 plusAlg->setProperty<Workspace_sptr>("OutputWorkspace", ws1);
699 plusAlg->executeAsChildAlg();
700 } else {
701 throw std::runtime_error("Unable to add a group workspace to a non-group workspace");
702 }
703
704 return ws1;
705}
706
714API::WorkspaceGroup_sptr Load::groupWsList(const std::vector<API::Workspace_sptr> &wsList) {
715 auto group = std::make_shared<WorkspaceGroup>();
716
717 for (const auto &ws : wsList) {
718 WorkspaceGroup_sptr isGroup = std::dynamic_pointer_cast<WorkspaceGroup>(ws);
719 // If the ws to add is already a group, then add its children individually.
720 if (isGroup) {
721 std::vector<std::string> childrenNames = isGroup->getNames();
722 size_t count = 1;
723 for (auto childName = childrenNames.begin(); childName != childrenNames.end(); ++childName, ++count) {
724 Workspace_sptr childWs = isGroup->getItem(*childName);
725 isGroup->remove(*childName);
726 // childWs->setName(isGroup->getName() + "_" +
727 // boost::lexical_cast<std::string>(count));
728 group->addWorkspace(childWs);
729 }
730
731 // Remove the old group from the ADS
732 AnalysisDataService::Instance().remove(isGroup->getName());
733 } else {
734 group->addWorkspace(ws);
735 }
736 }
737
738 return group;
739}
740} // 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:714
API::Workspace_sptr plusWs(API::Workspace_sptr ws1, const API::Workspace_sptr &ws2)
Plus two workspaces together, "in place".
Definition Load.cpp:666
void cancel() override
Overrides the cancel() method to call m_loader->cancel()
Definition Load.cpp:614
void setOutputProperties(const API::IAlgorithm_sptr &loader)
Set the output properties.
Definition Load.cpp:529
void setPropertyValue(const std::string &name, const std::string &value) override
Override setPropertyValue.
Definition Load.cpp:104
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:549
void exec() override
Execute.
Definition Load.cpp:322
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:482
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:88
void loadSingleFile()
Called when there is only one file to load.
Definition Load.cpp:355
void findFilenameProperty(const API::IAlgorithm_sptr &loader)
Definition Load.cpp:203
void loadMultipleFiles()
Called when there are multiple files to load.
Definition Load.cpp:383
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:502
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:628
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.
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:76
virtual Property * clone() const =0
'Virtual copy constructor'
const std::string & name() const
Get the property's name.
Definition Property.cpp:61
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