Mantid
Loading...
Searching...
No Matches
PreviewManager.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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 +
8
9namespace Mantid::API {
10
11std::vector<std::string> PreviewManagerImpl::getPreviews(const std::string &facility,
12 const std::string &technique) const {
13 std::vector<std::string> previews;
14 if (m_previews.find(facility) != m_previews.end()) {
15 for (const auto &pvs : m_previews.at(facility)) {
16 for (const auto &pv : pvs.second) {
17 if (technique.empty() || pvs.first == technique) {
18 previews.emplace_back(pv.first);
19 }
20 }
21 }
22 }
23 return previews;
24}
25
26const IPreview &PreviewManagerImpl::getPreview(const std::string &facility, const std::string &technique,
27 const std::string &preview) const {
28 if (!checkPreview(facility, technique, preview)) {
29 throw std::runtime_error("Preview with the given name is not registered "
30 "under the facility and technique.");
31 }
32 return *m_previews.at(facility).at(technique).at(preview);
33}
34
35bool PreviewManagerImpl::checkFacility(const std::string &facility) const { return m_previews.count(facility) > 0; }
36bool PreviewManagerImpl::checkTechnique(const std::string &facility, const std::string &technique) const {
37 if (checkFacility(facility)) {
38 return m_previews.at(facility).count(technique) > 0;
39 } else {
40 return false;
41 }
42}
43bool PreviewManagerImpl::checkPreview(const std::string &facility, const std::string &technique,
44 const std::string &preview) const {
45 if (checkTechnique(facility, technique)) {
46 return m_previews.at(facility).at(technique).count(preview) > 0;
47 } else {
48 return false;
49 }
50}
51
52} // namespace Mantid::API
IPreview : This is the abstract base class of the raw data previews.
Definition: IPreview.h:24
bool checkFacility(const std::string &facility) const
std::vector< std::string > getPreviews(const std::string &facility, const std::string &technique="") const
bool checkTechnique(const std::string &facility, const std::string &technique) const
const IPreview & getPreview(const std::string &facility, const std::string &technique, const std::string &preview) const
bool checkPreview(const std::string &facility, const std::string &technique, const std::string &preview) const