Mantid
Loading...
Searching...
No Matches
NexusFileLoader.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
6// SPDX - License - Identifier: GPL - 3.0 +
8
9namespace Mantid::API {
11 // make sure the descriptor is initialized
12 if (!m_fileInfo) {
13 const std::string filename = this->getPropertyValue(this->getFilenamePropertyName());
14 m_fileInfo = std::make_shared<Mantid::Kernel::NexusHDF5Descriptor>(filename);
15 }
16
17 // execute the algorithm as normal
18 execLoader();
19}
20std::shared_ptr<Mantid::API::Algorithm>
21NexusFileLoader::createChildAlgorithm(const std::string &name, const double startProgress, const double endProgress,
22 const bool enableLogging, const int &version) {
23 auto child = IFileLoader::createChildAlgorithm(name, startProgress, endProgress, enableLogging, version);
24
25 // set the NexusHDF5Descriptor on the child algorithm
26 auto nfl = std::dynamic_pointer_cast<NexusFileLoader>(child);
27 if (nfl) {
28 nfl->setFileInfo(m_fileInfo);
29 }
30 return child;
31}
32void NexusFileLoader::setFileInfo(std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor> fileInfo) {
33 m_fileInfo = std::move(fileInfo);
34}
35
36const std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor> NexusFileLoader::getFileInfo() const noexcept {
37 return m_fileInfo;
38}
39
40std::string NexusFileLoader::getFilenamePropertyName() const { return "Filename"; }
41
42} // namespace Mantid::API
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
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
int version() const override=0
function to return a version of the algorithm, must be overridden in all algorithms
const std::string name() const override=0
function to return a name of the algorithm, must be overridden in all algorithms
void exec() override final
Virtual method - must be overridden by concrete algorithm.
virtual void setFileInfo(std::shared_ptr< Mantid::Kernel::NexusHDF5Descriptor > fileInfo)
virtual std::string getFilenamePropertyName() const
std::shared_ptr< Mantid::Kernel::NexusHDF5Descriptor > m_fileInfo
virtual const std::shared_ptr< Mantid::Kernel::NexusHDF5Descriptor > getFileInfo() const noexcept
Required to pass m_fileInfo to static functions Keeping it shared_ptr to match setFileInfo signature ...
virtual void execLoader()=0
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) override
Create a Child Algorithm.