Mantid
Loading...
Searching...
No Matches
SampleEnvironmentFactory.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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#include "MantidDataHandling/DllConfig.h"
11
12namespace Mantid {
13namespace DataHandling {
14
19class MANTID_DATAHANDLING_DLL ISampleEnvironmentSpecFinder {
20public:
21 virtual ~ISampleEnvironmentSpecFinder() = default;
22 virtual SampleEnvironmentSpec_uptr find(const std::string &facility, const std::string &instrument,
23 const std::string &name) const = 0;
24 virtual SampleEnvironmentSpec_uptr parseSpec(const std::string &name, const std::string &filename) const = 0;
25};
26// Typedef for a unique_ptr
27using ISampleEnvironmentSpecFinder_uptr = std::unique_ptr<ISampleEnvironmentSpecFinder>;
28
36class MANTID_DATAHANDLING_DLL SampleEnvironmentFactory {
37public:
40
41 Geometry::SampleEnvironment_uptr create(const std::string &facility, const std::string &instrument,
42 const std::string &specName, const std::string &canName);
43
44 size_t cacheSize() const;
45 void clearCache();
46 SampleEnvironmentSpec_uptr parseSpec(const std::string &filename, const std::string &filepath) const;
47
48private:
50};
51
52//------------------------------------------------------------------------------
53// SampleEnvironmentSpecFileFinder
54//------------------------------------------------------------------------------
58class MANTID_DATAHANDLING_DLL SampleEnvironmentSpecFileFinder final : public ISampleEnvironmentSpecFinder {
59public:
60 SampleEnvironmentSpecFileFinder(std::vector<std::string> directories);
61
62 SampleEnvironmentSpec_uptr find(const std::string &facility, const std::string &instrument,
63 const std::string &name) const override;
64 SampleEnvironmentSpec_uptr parseSpec(const std::string &name, const std::string &filename) const override;
65
66private:
67 const std::string m_fileext = ".xml";
68 const std::vector<std::string> m_rootDirs;
69};
70
71} // namespace DataHandling
72} // namespace Mantid
Interface for a class responsible for finding a specification based on a name.
virtual SampleEnvironmentSpec_uptr find(const std::string &facility, const std::string &instrument, const std::string &name) const =0
virtual SampleEnvironmentSpec_uptr parseSpec(const std::string &name, const std::string &filename) const =0
Create a single instance of a SampleEnvironment.
Class responsible for finding a specifications on disk.
std::unique_ptr< SampleEnvironmentSpec > SampleEnvironmentSpec_uptr
unique_ptr to a SampleEnvironmentSpec
std::unique_ptr< ISampleEnvironmentSpecFinder > ISampleEnvironmentSpecFinder_uptr
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::unique_ptr< SampleEnvironment > SampleEnvironment_uptr
Helper class which provides the Collimation Length for SANS instruments.