Skip to content

Commit beb759b

Browse files
Rename NexusDescriptor to LegacyNexusDescriptor
1 parent 288d29e commit beb759b

File tree

12 files changed

+48
-44
lines changed

12 files changed

+48
-44
lines changed

Framework/API/inc/MantidAPI/FileLoaderRegistry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "MantidAPI/AlgorithmFactory.h"
1010
#include "MantidAPI/IFileLoader.h"
1111
#include "MantidKernel/FileDescriptor.h"
12-
#include "MantidKernel/NexusDescriptor.h"
12+
#include "MantidKernel/LegacyNexusDescriptor.h"
1313
#include "MantidKernel/NexusHDF5Descriptor.h"
1414
#include "MantidKernel/SingletonHolder.h"
1515

@@ -90,7 +90,7 @@ class MANTID_API_DLL FileLoaderRegistryImpl {
9090
static void check(LoaderFormat format) {
9191
switch (format) {
9292
case Nexus:
93-
if (!std::is_base_of<IFileLoader<Kernel::NexusDescriptor>, T>::value) {
93+
if (!std::is_base_of<IFileLoader<Kernel::LegacyNexusDescriptor>, T>::value) {
9494
throw std::runtime_error(std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
9595
"' registered as Nexus loader but it does not "
9696
"inherit from "

Framework/API/src/FileLoaderRegistry.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void FileLoaderRegistryImpl::unsubscribe(const std::string &name, const int vers
113113
*/
114114
const std::shared_ptr<IAlgorithm> FileLoaderRegistryImpl::chooseLoader(const std::string &filename) const {
115115
using Kernel::FileDescriptor;
116-
using Kernel::NexusDescriptor;
116+
using Kernel::LegacyNexusDescriptor;
117117
using Kernel::NexusHDF5Descriptor;
118118
m_log.debug() << "Trying to find loader for '" << filename << "'\n";
119119

@@ -125,7 +125,7 @@ const std::shared_ptr<IAlgorithm> FileLoaderRegistryImpl::chooseLoader(const std
125125

126126
// must also try NexusDescriptor algorithms because LoadMuonNexus can load both HDF4 and HDF5 files
127127
std::pair<IAlgorithm_sptr, int> HDF4result =
128-
searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(filename, m_names[Nexus], m_log);
128+
searchForLoader<LegacyNexusDescriptor, IFileLoader<LegacyNexusDescriptor>>(filename, m_names[Nexus], m_log);
129129

130130
if (HDF5result.second > HDF4result.second)
131131
bestLoader = HDF5result.first;
@@ -134,7 +134,8 @@ const std::shared_ptr<IAlgorithm> FileLoaderRegistryImpl::chooseLoader(const std
134134
} else {
135135
try {
136136
bestLoader =
137-
searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(filename, m_names[Nexus], m_log).first;
137+
searchForLoader<LegacyNexusDescriptor, IFileLoader<LegacyNexusDescriptor>>(filename, m_names[Nexus], m_log)
138+
.first;
138139
} catch (std::exception const &e) {
139140
m_log.debug() << "Error in looking for NeXus files: " << e.what() << '\n';
140141
}
@@ -159,7 +160,7 @@ const std::shared_ptr<IAlgorithm> FileLoaderRegistryImpl::chooseLoader(const std
159160
*/
160161
bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName, const std::string &filename) const {
161162
using Kernel::FileDescriptor;
162-
using Kernel::NexusDescriptor;
163+
using Kernel::LegacyNexusDescriptor;
163164
using Kernel::NexusHDF5Descriptor;
164165

165166
// Check if it is in one of our lists
@@ -175,7 +176,7 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName, const std
175176
IAlgorithm_sptr loader;
176177
if (nexus) {
177178
try {
178-
loader = searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(filename, names, m_log).first;
179+
loader = searchForLoader<LegacyNexusDescriptor, IFileLoader<LegacyNexusDescriptor>>(filename, names, m_log).first;
179180
} catch (std::exception const &e) {
180181
m_log.debug() << "Error in looking for NeXus files: " << e.what() << '\n';
181182
}

Framework/Kernel/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ set(SRC_FILES
7474
src/MultiFileValidator.cpp
7575
src/NDRandomNumberGenerator.cpp
7676
src/NeutronAtom.cpp
77-
src/NexusDescriptor.cpp
77+
src/LegacyNexusDescriptor.cpp
7878
src/NexusHDF5Descriptor.cpp
7979
src/NullValidator.cpp
8080
src/OptionalBool.cpp
@@ -232,7 +232,7 @@ set(INC_FILES
232232
inc/MantidKernel/NearestNeighbours.h
233233
inc/MantidKernel/NetworkProxy.h
234234
inc/MantidKernel/NeutronAtom.h
235-
inc/MantidKernel/NexusDescriptor.h
235+
inc/MantidKernel/LegacyNexusDescriptor.h
236236
inc/MantidKernel/NexusHDF5Descriptor.h
237237
inc/MantidKernel/NullValidator.h
238238
inc/MantidKernel/OptionalBool.h
@@ -388,7 +388,7 @@ set(TEST_FILES
388388
NDRandomNumberGeneratorTest.h
389389
NearestNeighboursTest.h
390390
NeutronAtomTest.h
391-
NexusDescriptorTest.h
391+
LegacyNexusDescriptorTest.h
392392
NexusHDF5DescriptorTest.h
393393
NullValidatorTest.h
394394
OptionalBoolTest.h

Framework/Kernel/inc/MantidKernel/NexusDescriptor.h renamed to Framework/Kernel/inc/MantidKernel/LegacyNexusDescriptor.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ namespace Kernel {
2929
On construction the simple details about the layout of the file are cached
3030
for faster querying later.
3131
*/
32-
class MANTID_KERNEL_DLL NexusDescriptor {
32+
class MANTID_KERNEL_DLL LegacyNexusDescriptor {
3333

3434
public:
3535
/// Constructor accepting a filename
36-
NexusDescriptor(const std::string &filename);
36+
LegacyNexusDescriptor(const std::string &filename);
3737
/// Destructor
38-
~NexusDescriptor();
38+
~LegacyNexusDescriptor();
3939

4040
/// Disable default constructor
41-
NexusDescriptor() = delete;
41+
LegacyNexusDescriptor() = delete;
4242

4343
/// Disable copy operator
44-
NexusDescriptor(const NexusDescriptor &) = delete;
44+
LegacyNexusDescriptor(const LegacyNexusDescriptor &) = delete;
4545

4646
/// Disable assignment operator
47-
NexusDescriptor &operator=(const NexusDescriptor &) = delete;
47+
LegacyNexusDescriptor &operator=(const LegacyNexusDescriptor &) = delete;
4848

4949
/**
5050
* Access the filename

Framework/Kernel/src/NexusDescriptor.cpp renamed to Framework/Kernel/src/LegacyNexusDescriptor.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// NScD Oak Ridge National Laboratory, European Spallation Source,
55
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
66
// SPDX - License - Identifier: GPL - 3.0 +
7-
#include "MantidKernel/NexusDescriptor.h"
7+
#include "MantidKernel/LegacyNexusDescriptor.h"
88
#include "MantidLegacyNexus/NeXusException.hpp"
99
#include "MantidLegacyNexus/NeXusFile.hpp"
1010

@@ -26,7 +26,7 @@ namespace Mantid::Kernel {
2626
* involves simply checking for the signature if a HDF file at the start of the
2727
* file
2828
*/
29-
NexusDescriptor::NexusDescriptor(const std::string &filename)
29+
LegacyNexusDescriptor::LegacyNexusDescriptor(const std::string &filename)
3030
: m_filename(), m_extension(), m_firstEntryNameType(), m_rootAttrs(), m_pathsToTypes(), m_file(nullptr) {
3131
if (filename.empty()) {
3232
throw std::invalid_argument("NexusDescriptor() - Empty filename '" + filename + "'");
@@ -43,17 +43,19 @@ NexusDescriptor::NexusDescriptor(const std::string &filename)
4343
}
4444
}
4545

46-
NexusDescriptor::~NexusDescriptor() = default;
46+
LegacyNexusDescriptor::~LegacyNexusDescriptor() = default;
4747

4848
/// Returns the name & type of the first entry in the file
49-
const std::pair<std::string, std::string> &NexusDescriptor::firstEntryNameType() const { return m_firstEntryNameType; }
49+
const std::pair<std::string, std::string> &LegacyNexusDescriptor::firstEntryNameType() const {
50+
return m_firstEntryNameType;
51+
}
5052

5153
/**
5254
* @param path A string giving a path using UNIX-style path separators (/), e.g.
5355
* /raw_data_1, /entry/bank1
5456
* @return True if the path exists in the file, false otherwise
5557
*/
56-
bool NexusDescriptor::pathExists(const std::string &path) const {
58+
bool LegacyNexusDescriptor::pathExists(const std::string &path) const {
5759
return (m_pathsToTypes.find(path) != m_pathsToTypes.end());
5860
}
5961

@@ -64,7 +66,7 @@ bool NexusDescriptor::pathExists(const std::string &path) const {
6466
/**
6567
* Creates the internal cached structure of the file as a tree of nodes
6668
*/
67-
void NexusDescriptor::initialize(const std::string &filename) {
69+
void LegacyNexusDescriptor::initialize(const std::string &filename) {
6870
m_filename = filename;
6971
m_extension = std::filesystem::path(filename).extension().string();
7072

@@ -84,8 +86,9 @@ void NexusDescriptor::initialize(const std::string &filename) {
8486
* @param pmap [Out] An output map filled with mappings of path->type
8587
* @param level An integer defining the current level in the file
8688
*/
87-
void NexusDescriptor::walkFile(Mantid::LegacyNexus::File &file, const std::string &rootPath,
88-
const std::string &className, std::map<std::string, std::string> &pmap, int level) {
89+
void LegacyNexusDescriptor::walkFile(Mantid::LegacyNexus::File &file, const std::string &rootPath,
90+
const std::string &className, std::map<std::string, std::string> &pmap,
91+
int level) {
8992
if (!rootPath.empty()) {
9093
pmap.emplace(rootPath, className);
9194
}

Framework/Kernel/test/NexusDescriptorTest.h renamed to Framework/Kernel/test/LegacyNexusDescriptorTest.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include "MantidKernel/ConfigService.h"
10-
#include "MantidKernel/NexusDescriptor.h"
10+
#include "MantidKernel/LegacyNexusDescriptor.h"
1111
#include "MantidNexusCpp/NeXusFile.hpp"
1212
#include <cxxtest/TestSuite.h>
1313

@@ -16,16 +16,16 @@
1616

1717
#include <cstdio>
1818

19-
using Mantid::Kernel::NexusDescriptor;
19+
using Mantid::Kernel::LegacyNexusDescriptor;
2020

21-
class NexusDescriptorTest : public CxxTest::TestSuite {
21+
class LegacyNexusDescriptorTest : public CxxTest::TestSuite {
2222
public:
2323
// This pair of boilerplate methods prevent the suite being created statically
2424
// This means the constructor isn't called when running other tests
25-
static NexusDescriptorTest *createSuite() { return new NexusDescriptorTest(); }
26-
static void destroySuite(NexusDescriptorTest *suite) { delete suite; }
25+
static LegacyNexusDescriptorTest *createSuite() { return new LegacyNexusDescriptorTest(); }
26+
static void destroySuite(LegacyNexusDescriptorTest *suite) { delete suite; }
2727

28-
NexusDescriptorTest() {
28+
LegacyNexusDescriptorTest() {
2929
using Mantid::Kernel::ConfigService;
3030
auto dataPaths = ConfigService::Instance().getDataSearchDirs();
3131
for (auto &dataPath : dataPaths) {
@@ -45,10 +45,10 @@ class NexusDescriptorTest : public CxxTest::TestSuite {
4545
"The AutoTestData directory needs to be in the search path");
4646
}
4747

48-
m_testHDF5 = std::make_shared<NexusDescriptor>(m_testHDF5Path);
48+
m_testHDF5 = std::make_shared<LegacyNexusDescriptor>(m_testHDF5Path);
4949
}
5050

51-
//=================================== NexusDescriptor methods
51+
//=================================== LegacyNexusDescriptor methods
5252
//==================================
5353

5454
void test_Constructor_Initializes_Object_Correctly_Given_HDF_File() {
@@ -57,15 +57,15 @@ class NexusDescriptorTest : public CxxTest::TestSuite {
5757
}
5858

5959
void test_Constructor_Throws_With_Empty_filename() {
60-
TS_ASSERT_THROWS(NexusDescriptor(""), const std::invalid_argument &);
60+
TS_ASSERT_THROWS(LegacyNexusDescriptor(""), const std::invalid_argument &);
6161
}
6262

6363
void test_Constructor_Throws_With_NonExistant_filename() {
64-
TS_ASSERT_THROWS(NexusDescriptor("__ThisShouldBeANonExistantFile.txt"), const std::invalid_argument &);
64+
TS_ASSERT_THROWS(LegacyNexusDescriptor("__ThisShouldBeANonExistantFile.txt"), const std::invalid_argument &);
6565
}
6666

6767
void test_Constructor_Throws_When_Given_File_Not_Identified_As_HDF() {
68-
TS_ASSERT_THROWS(NexusDescriptor fd(m_testNonHDFPath), const std::invalid_argument &);
68+
TS_ASSERT_THROWS(LegacyNexusDescriptor fd(m_testNonHDFPath), const std::invalid_argument &);
6969
}
7070

7171
void test_File_Handle_Returned_By_Data_Is_Valid() {
@@ -95,5 +95,5 @@ class NexusDescriptorTest : public CxxTest::TestSuite {
9595
private:
9696
std::string m_testHDF5Path;
9797
std::string m_testNonHDFPath;
98-
std::shared_ptr<NexusDescriptor> m_testHDF5;
98+
std::shared_ptr<LegacyNexusDescriptor> m_testHDF5;
9999
};

Framework/Muon/inc/MantidMuon/LoadMuonNexus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "MantidAPI/IFileLoader.h"
1313
#include "MantidDataObjects/Workspace2D_fwd.h"
1414
#include "MantidGeometry/IDTypes.h"
15-
#include "MantidKernel/NexusDescriptor.h"
15+
#include "MantidKernel/LegacyNexusDescriptor.h"
1616
#include "MantidMuon/DllConfig.h"
1717

1818
//----------------------------------------------------------------------
@@ -48,7 +48,7 @@ multiperiod file)
4848
together based on the groupings in the NeXus file. </LI>
4949
</UL>
5050
*/
51-
class MANTID_MUON_DLL LoadMuonNexus : public API::IFileLoader<Kernel::NexusDescriptor> {
51+
class MANTID_MUON_DLL LoadMuonNexus : public API::IFileLoader<Kernel::LegacyNexusDescriptor> {
5252
public:
5353
/// Default constructor
5454
LoadMuonNexus();
@@ -68,7 +68,7 @@ class MANTID_MUON_DLL LoadMuonNexus : public API::IFileLoader<Kernel::NexusDescr
6868
const std::string category() const override { return "DataHandling\\Nexus;Muon\\DataHandling"; }
6969

7070
/// Returns a confidence value that this algorithm can load a file
71-
int confidence(Kernel::NexusDescriptor &descriptor) const override;
71+
int confidence(Kernel::LegacyNexusDescriptor &descriptor) const override;
7272

7373
protected:
7474
virtual void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr) {}

Framework/Muon/inc/MantidMuon/LoadMuonNexus1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class MANTID_MUON_DLL LoadMuonNexus1 : public LoadMuonNexus {
5757
LoadMuonNexus1();
5858

5959
/// Returns a confidence value that this algorithm can load a file
60-
int confidence(Kernel::NexusDescriptor &descriptor) const override;
60+
int confidence(Kernel::LegacyNexusDescriptor &descriptor) const override;
6161

6262
protected:
6363
/// Overwrites Algorithm method

Framework/Muon/inc/MantidMuon/LoadMuonNexus2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MANTID_MUON_DLL LoadMuonNexus2 : public LoadMuonNexus {
6060
const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
6161

6262
/// Returns a confidence value that this algorithm can load a file
63-
int confidence(Kernel::NexusDescriptor &descriptor) const override;
63+
int confidence(Kernel::LegacyNexusDescriptor &descriptor) const override;
6464

6565
private:
6666
void exec() override;

Framework/Muon/src/LoadMuonNexus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void LoadMuonNexus::runLoadInstrument(const DataObjects::Workspace2D_sptr &local
178178
* @returns An integer specifying the confidence level. 0 indicates it will not
179179
* be used
180180
*/
181-
int LoadMuonNexus::confidence(Kernel::NexusDescriptor &descriptor) const {
181+
int LoadMuonNexus::confidence(Kernel::LegacyNexusDescriptor &descriptor) const {
182182
UNUSED_ARG(descriptor);
183183
return 0; // Not to be used but LoadMuonNexus2, which inherits from this will
184184
}

0 commit comments

Comments
 (0)