Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "MantidAPI/FileLoaderRegistry.h"
#include "MantidKernel/Exception.h"
#include <Poco/File.h>
namespace Mantid
{
namespace API
{
//----------------------------------------------------------------------------------------------
// Public members
//----------------------------------------------------------------------------------------------
/**
* Creates an empty registry
*/
FileLoaderRegistry::FileLoaderRegistry()
{
}
/**
* @param name The string name of the entry
* @throws std::invalid_argument if an entry with this name already exists
*/
void FileLoaderRegistry::subscribe(const std::string & name)
{
auto insertionResult = m_names.insert(name);
if(!insertionResult.second)
{
throw std::invalid_argument("FileLoaderRegistry::subscribe - Cannot subscribe '"
+ name + "'. An entry with that name already exists");
}
}
/**
* Attempts to pick the best suited loader for the given file name from those in the registry
* @param filename A string that should point to an existing file
* @throws std::invalid_argument if the filename does not point to an existing file or an empty string is given
* @throws Exception::NotFoundError if a loader could not be found
*/
std::string FileLoaderRegistry::findLoader(const std::string & filename) const
{
if(filename.empty() || !Poco::File(filename).exists())
{
throw std::invalid_argument("FileLoaderRegistry::chooserLoader - Cannot open file '" + filename + "'");
}
}
//----------------------------------------------------------------------------------------------
// Private members
//----------------------------------------------------------------------------------------------
} // namespace API
} // namespace Mantid