Skip to content
Snippets Groups Projects
Commit b78e23e7 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Set the descriptor on the chosen loader

parent 55eed720
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 + // SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/FileLoaderRegistry.h" #include "MantidAPI/FileLoaderRegistry.h"
#include "MantidAPI/IFileLoader.h" #include "MantidAPI/IFileLoader.h"
#include "MantidAPI/NexusFileLoader.h"
#include <Poco/File.h> #include <Poco/File.h>
...@@ -26,6 +27,20 @@ template <> struct DescriptorCallback<Kernel::FileDescriptor> { ...@@ -26,6 +27,20 @@ template <> struct DescriptorCallback<Kernel::FileDescriptor> {
}; };
/// @endcond /// @endcond
/// @cond
template <typename T> struct DescriptorSetter {
// general one does nothing
void apply(boost::shared_ptr<NexusFileLoader> & /*unused*/,
std::shared_ptr<T> & /*unused*/) {}
};
template <> struct DescriptorSetter<Kernel::NexusHDF5Descriptor> {
void apply(boost::shared_ptr<NexusFileLoader> &loader,
std::shared_ptr<Kernel::NexusHDF5Descriptor> &descriptor) {
loader->setFileInfo(descriptor);
}
};
/// @endcond
/** /**
* @param filename A string giving a filename * @param filename A string giving a filename
* @param names The collection of names to search through * @param names The collection of names to search through
...@@ -42,9 +57,10 @@ searchForLoader(const std::string &filename, ...@@ -42,9 +57,10 @@ searchForLoader(const std::string &filename,
const auto &factory = AlgorithmFactory::Instance(); const auto &factory = AlgorithmFactory::Instance();
IAlgorithm_sptr bestLoader; IAlgorithm_sptr bestLoader;
int maxConfidence(0); int maxConfidence(0);
//Mantid::Kernel::NexusHDF5Descriptor>(filename); // Mantid::Kernel::NexusHDF5Descriptor>(filename);
auto descriptor = std::make_shared<DescriptorType>(filename); auto descriptor = std::make_shared<DescriptorType>(filename);
DescriptorCallback<DescriptorType> callback; DescriptorCallback<DescriptorType> callback;
DescriptorSetter<DescriptorType> setdescriptor;
auto iend = names.end(); auto iend = names.end();
for (auto it = names.begin(); it != iend; ++it) { for (auto it = names.begin(); it != iend; ++it) {
...@@ -72,6 +88,10 @@ searchForLoader(const std::string &filename, ...@@ -72,6 +88,10 @@ searchForLoader(const std::string &filename,
callback.apply(descriptor); callback.apply(descriptor);
} }
auto nxsLoader = boost::dynamic_pointer_cast<NexusFileLoader>(bestLoader);
if (nxsLoader)
setdescriptor.apply(nxsLoader, descriptor);
return bestLoader; return bestLoader;
} }
} // namespace } // namespace
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment