Mantid
Loading...
Searching...
No Matches
FileFinder.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
15
16#include <filesystem>
17#include <set>
18#include <vector>
19
20namespace Mantid {
21//---------------------------------------------------------------------------
22// Forward declarations
23//---------------------------------------------------------------------------
24namespace Kernel {
25class InstrumentInfo;
26class FacilityInfo;
27} // namespace Kernel
28namespace API {
29
37class MANTID_API_DLL FileFinderImpl {
38public:
39 std::filesystem::path getFullPath(const std::string &filename, const bool ignoreDirs = false) const;
40 std::string extractAllowedSuffix(std::string &userString) const;
41 const API::Result<std::filesystem::path> getPath(const std::vector<IArchiveSearch_sptr> &archs,
42 const std::set<std::string> &hintstrs,
43 const std::vector<std::string> &exts) const;
45 std::string makeFileName(const std::string &hintstr, const Kernel::InstrumentInfo &instrument) const;
46 void setCaseSensitive(const bool cs);
47 bool getCaseSensitive() const;
48 static std::vector<IArchiveSearch_sptr> getArchiveSearch(const Kernel::FacilityInfo &facility);
49 const API::Result<std::filesystem::path> findRun(const std::string &hintstr,
50 const std::vector<std::string> &exts = {},
51 const bool useExtsOnly = false,
52 const std::string &defaultInstrument = "") const;
53 const API::Result<std::filesystem::path> findRun(const std::string &hintstr, const Kernel::InstrumentInfo &instrument,
54 const std::vector<std::string> &exts = {},
55 const bool useExtsOnly = false) const;
56 std::vector<std::filesystem::path> findRuns(const std::string &hintstr, const std::vector<std::string> &exts = {},
57 const bool useExtsOnly = false) const;
59 const Kernel::InstrumentInfo getInstrument(const std::string &hintstr, const bool returnDefaultIfNotFound = true,
60 const std::string &defaultInstrument = "") const;
62 std::string getExtension(const std::string &filename, const std::vector<std::string> &exts) const;
63 void getUniqueExtensions(const std::vector<std::string> &extensionsToAdd, std::vector<std::string> &uniqueExts) const;
64 std::pair<std::string, std::string> toInstrumentAndNumber(const std::string &hintstr,
65 const std::string &defaultInstrument = "") const;
66 std::pair<std::string, std::string> toInstrumentAndNumber(const std::string &hintstr,
67 const Kernel::InstrumentInfo &instrument) const;
68
69private:
71
73 static const std::string ALLOWED_SUFFIX;
81 std::string validateRuns(const std::string &searchText) const;
82 const API::Result<std::filesystem::path> getISISInstrumentDataCachePath(const std::string &cachePathToSearch,
83 const std::set<std::string> &hintstrs,
84 const std::vector<std::string> &exts) const;
85 const API::Result<std::filesystem::path> getArchivePath(const std::vector<IArchiveSearch_sptr> &archs,
86 const std::set<std::string> &hintstrs,
87 const std::vector<std::string> &exts) const;
88 std::string toUpper(const std::string &src) const;
91};
92
94} // namespace API
95} // namespace Mantid
96
97namespace Mantid {
98namespace Kernel {
99EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::FileFinderImpl>;
100}
101} // namespace Mantid
This class finds data files given an instrument name (optionally) and a run number.
Definition FileFinder.h:37
FileFinderImpl(const FileFinderImpl &)
Copy constructor.
int m_globOption
glob option - set to case sensitive or insensitive
Definition FileFinder.h:90
FileFinderImpl & operator=(const FileFinderImpl &)
Assignment operator.
static const std::string ALLOWED_SUFFIX
a string that is allowed at the end of any run number
Definition FileFinder.h:73
A class that holds information about a facility.
A class that holds information about an instrument.
Manage the lifetime of a class intended to be a singleton.
Mantid::Kernel::SingletonHolder< FileFinderImpl > FileFinder
Definition FileFinder.h:93
Helper class which provides the Collimation Length for SANS instruments.
Policy class controlling creation of the singleton Implementation classes should mark their default c...