Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
Mantid::DataHandling::ISISDataArchive Class Reference

This class is for searching the ISIS data archive. More...

#include <ISISDataArchive.h>

Inheritance diagram for Mantid::DataHandling::ISISDataArchive:
Mantid::API::IArchiveSearch

Public Member Functions

std::string getArchivePath (const std::set< std::string > &filenames, const std::vector< std::string > &exts) const override
 Returns the path to a filename given the list of extensions to try. More...
 
virtual std::string getCorrectExtension (const std::string &path, const std::vector< std::string > &exts) const
 Public and virtual for testing purposes. More...
 
std::string getPath (const std::string &fName) const
 Gets the path to the file, or most recent set of files. More...
 
- Public Member Functions inherited from Mantid::API::IArchiveSearch
virtual std::string getArchivePath (const std::set< std::string > &filenames, const std::vector< std::string > &exts) const =0
 Return the full path to a data file in an archive. More...
 
virtual ~IArchiveSearch ()=default
 Virtual destructor. More...
 

Protected Member Functions

virtual bool fileExists (const std::string &path) const
 Checks if the given file path exists or not. More...
 
virtual std::ostringstream sendRequest (const std::string &fName) const
 Queries the archive & returns the path to a single file. More...
 

Detailed Description

This class is for searching the ISIS data archive.

Author
Roman Tolchenov, Tessella plc
Date
27/07/2010

Definition at line 27 of file ISISDataArchive.h.

Member Function Documentation

◆ fileExists()

bool Mantid::DataHandling::ISISDataArchive::fileExists ( const std::string &  path) const
protectedvirtual

Checks if the given file path exists or not.

This code is in a separate function so it can be mocked out in testing.

Parameters
path:: The path to the file (including extension)
Returns
A bool. Whether or not the file exists.

Definition at line 126 of file ISISDataArchive.cpp.

References Mantid::DataHandling::exists().

Referenced by getCorrectExtension().

◆ getArchivePath()

std::string Mantid::DataHandling::ISISDataArchive::getArchivePath ( const std::set< std::string > &  filenames,
const std::vector< std::string > &  exts 
) const
overridevirtual

Returns the path to a filename given the list of extensions to try.

Query the ISIS archive for a set of filenames and vector of extensions.

The method gets a path to each of the filenames, and then loops over the extensions to find the correct file.

Parameters
filenames:: A set of filenames without extensions
exts:: A vector of file extensions to search over.
Returns
The full path to the first found

Implements Mantid::API::IArchiveSearch.

Definition at line 44 of file ISISDataArchive.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, getCorrectExtension(), getPath(), and Mantid::Kernel::Logger::is().

◆ getCorrectExtension()

std::string Mantid::DataHandling::ISISDataArchive::getCorrectExtension ( const std::string &  path,
const std::vector< std::string > &  exts 
) const
virtual

Public and virtual for testing purposes.

Given a path to a file, this searches over possible extensions to find the full path.

Only returns a full path string if the file exists.

Parameters
path:: The path to the file without an extension.
exts:: vector of possible file extensions to search over.
Returns
The full path to the file or an empty string in case of error/non-existing file.

Definition at line 110 of file ISISDataArchive.cpp.

References fileExists().

Referenced by getArchivePath().

◆ getPath()

std::string Mantid::DataHandling::ISISDataArchive::getPath ( const std::string &  fName) const

Gets the path to the file, or most recent set of files.

Parameters
fName:: The file name.
Returns
The path to the file or an empty string in case of empty filename

Definition at line 71 of file ISISDataArchive.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and sendRequest().

Referenced by getArchivePath().

◆ sendRequest()

std::ostringstream Mantid::DataHandling::ISISDataArchive::sendRequest ( const std::string &  fName) const
protectedvirtual

Queries the archive & returns the path to a single file.

Calls a web service to get a path to a file.

If the file does not exist, returns path to most recent run. The ISIS web service return a path independent of the file extension of the file provided. Thus the call to web service uses a file WITHOUT an extension.

Parameters
fName:: The file name.
Returns
ostringstream object containing path to file (without filename itself)

Definition at line 90 of file ISISDataArchive.cpp.

References Mantid::API::g_log, Mantid::Kernel::InternetHelper::sendRequest(), Mantid::Kernel::Logger::warning(), and Mantid::Kernel::Exception::InternetError::what().

Referenced by getPath().


The documentation for this class was generated from the following files: