Skip to content
Snippets Groups Projects
Commit ef70476c authored by mantid-builder's avatar mantid-builder Committed by Peterson, Peter
Browse files

clang-format PR28432 7b226ee8

parent 7b226ee8
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,8 @@ private: ...@@ -103,7 +103,8 @@ private:
} }
break; break;
case NexusHDF5: case NexusHDF5:
if (!std::is_base_of<IFileLoader<Kernel::NexusHDF5Descriptor>, T>::value) { if (!std::is_base_of<IFileLoader<Kernel::NexusHDF5Descriptor>,
T>::value) {
throw std::runtime_error( throw std::runtime_error(
std::string("FileLoaderRegistryImpl::subscribe - Class '") + std::string("FileLoaderRegistryImpl::subscribe - Class '") +
typeid(T).name() + typeid(T).name() +
......
...@@ -118,17 +118,18 @@ FileLoaderRegistryImpl::chooseLoader(const std::string &filename) const { ...@@ -118,17 +118,18 @@ FileLoaderRegistryImpl::chooseLoader(const std::string &filename) const {
try { try {
bestLoader = searchForLoader<NexusHDF5Descriptor, bestLoader = searchForLoader<NexusHDF5Descriptor,
IFileLoader<NexusHDF5Descriptor>>( IFileLoader<NexusHDF5Descriptor>>(
filename, m_names[NexusHDF5], m_log); filename, m_names[NexusHDF5], m_log);
} catch (const std::invalid_argument &e) { } catch (const std::invalid_argument &e) {
m_log.debug() << "Error in looking for HDF5 based NeXus files: " << e.what() << '\n'; m_log.debug() << "Error in looking for HDF5 based NeXus files: "
<< e.what() << '\n';
} }
} }
// try generic nexus loaders // try generic nexus loaders
if (!bestLoader) { if (!bestLoader) {
bestLoader = bestLoader =
searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>( searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(
filename, m_names[Nexus], m_log); filename, m_names[Nexus], m_log);
} }
} else { } else {
m_log.debug() << "Checking registered non-HDF loaders\n"; m_log.debug() << "Checking registered non-HDF loaders\n";
...@@ -158,9 +159,12 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName, ...@@ -158,9 +159,12 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName,
using Kernel::NexusHDF5Descriptor; using Kernel::NexusHDF5Descriptor;
// Check if it is in one of our lists // Check if it is in one of our lists
const bool nexus = (m_names[Nexus].find(algorithmName) != m_names[Nexus].end()); const bool nexus =
const bool nexusHDF5 = (m_names[NexusHDF5].find(algorithmName) != m_names[NexusHDF5].end()); (m_names[Nexus].find(algorithmName) != m_names[Nexus].end());
const bool nonHDF = (m_names[Generic].find(algorithmName) != m_names[Generic].end()); const bool nexusHDF5 =
(m_names[NexusHDF5].find(algorithmName) != m_names[NexusHDF5].end());
const bool nonHDF =
(m_names[Generic].find(algorithmName) != m_names[Generic].end());
if (!(nexus || nexusHDF5 || nonHDF)) if (!(nexus || nexusHDF5 || nonHDF))
throw std::invalid_argument( throw std::invalid_argument(
...@@ -172,21 +176,22 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName, ...@@ -172,21 +176,22 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName,
if (nexus) { if (nexus) {
if (NexusDescriptor::isReadable(filename)) { if (NexusDescriptor::isReadable(filename)) {
loader = searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>( loader = searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(
filename, names, m_log); filename, names, m_log);
} }
} else if (nexusHDF5) { } else if (nexusHDF5) {
if (NexusHDF5Descriptor::isReadable(filename)) { if (NexusHDF5Descriptor::isReadable(filename)) {
try { try {
loader = searchForLoader<NexusHDF5Descriptor, loader = searchForLoader<NexusHDF5Descriptor,
IFileLoader<NexusHDF5Descriptor>>( IFileLoader<NexusHDF5Descriptor>>(
filename, names, m_log); filename, names, m_log);
} catch (const std::invalid_argument &e) { } catch (const std::invalid_argument &e) {
m_log.debug() << "Error in looking for HDF5 based NeXus files: " << e.what() << '\n'; m_log.debug() << "Error in looking for HDF5 based NeXus files: "
<< e.what() << '\n';
} }
} }
} else if (nonHDF) { } else if (nonHDF) {
loader = searchForLoader<FileDescriptor, IFileLoader<FileDescriptor>>( loader = searchForLoader<FileDescriptor, IFileLoader<FileDescriptor>>(
filename, names, m_log); filename, names, m_log);
} }
return static_cast<bool>(loader); return static_cast<bool>(loader);
} }
...@@ -200,7 +205,7 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName, ...@@ -200,7 +205,7 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName,
* m_names is initialized in the header * m_names is initialized in the header
*/ */
FileLoaderRegistryImpl::FileLoaderRegistryImpl() FileLoaderRegistryImpl::FileLoaderRegistryImpl()
: m_totalSize(0), m_log("FileLoaderRegistry") {} : m_totalSize(0), m_log("FileLoaderRegistry") {}
FileLoaderRegistryImpl::~FileLoaderRegistryImpl() = default; FileLoaderRegistryImpl::~FileLoaderRegistryImpl() = default;
......
...@@ -97,7 +97,7 @@ bool isHDFHandle(FILE *fileHandle, NexusDescriptor::Version version) { ...@@ -97,7 +97,7 @@ bool isHDFHandle(FILE *fileHandle, NexusDescriptor::Version version) {
* @return True if the file is considered hierarchical, false otherwise * @return True if the file is considered hierarchical, false otherwise
*/ */
bool NexusDescriptor::isReadable(const std::string &filename, bool NexusDescriptor::isReadable(const std::string &filename,
const Version version) { const Version version) {
FILE *fd = fopen(filename.c_str(), "rb"); FILE *fd = fopen(filename.c_str(), "rb");
if (!fd) { if (!fd) {
throw std::invalid_argument( throw std::invalid_argument(
......
...@@ -177,10 +177,10 @@ void getGroup(hid_t groupID, ...@@ -177,10 +177,10 @@ void getGroup(hid_t groupID,
} // namespace } // namespace
bool NexusHDF5Descriptor::isReadable(const std::string &filename) { bool NexusHDF5Descriptor::isReadable(const std::string &filename) {
// use existing function to do the work // use existing function to do the work
return NexusDescriptor::isReadable(filename, NexusDescriptor::Version::Version5); return NexusDescriptor::isReadable(filename,
NexusDescriptor::Version::Version5);
} }
NexusHDF5Descriptor::NexusHDF5Descriptor(const std::string &filename) NexusHDF5Descriptor::NexusHDF5Descriptor(const std::string &filename)
...@@ -203,8 +203,8 @@ NexusHDF5Descriptor::initAllEntries() { ...@@ -203,8 +203,8 @@ NexusHDF5Descriptor::initAllEntries() {
hid_t fileID = H5Fopen(m_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); hid_t fileID = H5Fopen(m_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (fileID < 0) { if (fileID < 0) {
throw std::invalid_argument( throw std::invalid_argument(
"ERROR: Kernel::NexusHDF5Descriptor couldn't open hdf5 file " + m_filename + "ERROR: Kernel::NexusHDF5Descriptor couldn't open hdf5 file " +
"\n"); m_filename + "\n");
} }
hid_t groupID = H5Gopen2(fileID, "/", H5P_DEFAULT); hid_t groupID = H5Gopen2(fileID, "/", H5P_DEFAULT);
......
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