Mantid
Loading...
Searching...
No Matches
UserCatalogInfo.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 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 "MantidKernel/DllConfig.h"
11#include <boost/optional.hpp>
12#include <memory>
13
14namespace Mantid {
15namespace Kernel {
16
17using OptionalPath = boost::optional<std::string>;
18
20public:
21 virtual OptionalPath preferredMountPoint() const = 0;
22 virtual ~CatalogConfigService() = default;
23};
24
25template <typename T>
27 const std::string &key = "icatDownload.mountPoint") {
28 class Adapter : public CatalogConfigService {
29 private:
30 const T &m_adaptee;
31 std::string m_key;
32
33 public:
34 Adapter(const T &adaptee, const std::string &key) : m_adaptee(adaptee), m_key(key) {}
35 OptionalPath preferredMountPoint() const override {
36 auto const mountPoint = m_adaptee.getString(m_key);
37 if (!mountPoint.empty())
38 return OptionalPath(mountPoint);
39 return OptionalPath(boost::none);
40 }
41 };
42 return new Adapter(adaptee, key);
43}
44
50class MANTID_KERNEL_DLL UserCatalogInfo : public ICatalogInfo {
51public:
52 UserCatalogInfo(const ICatalogInfo &catInfo, const CatalogConfigService &catalogConfigService);
53
54 UserCatalogInfo(const UserCatalogInfo &other);
55
56 // ICatalogInfo interface
57 const std::string catalogName() const override;
58 const std::string soapEndPoint() const override;
59 const std::string externalDownloadURL() const override;
60 const std::string catalogPrefix() const override;
61 const std::string windowsPrefix() const override;
62 const std::string macPrefix() const override;
63 const std::string linuxPrefix() const override;
64 UserCatalogInfo *clone() const override;
65
66private:
68 const std::unique_ptr<ICatalogInfo> m_catInfo;
71};
72
73} // namespace Kernel
74} // namespace Mantid
std::string m_key
virtual OptionalPath preferredMountPoint() const =0
ICatalogInfo : An abstract class that holds information about catalogs.
Definition: ICatalogInfo.h:17
UserCatalogInfo : Takes catalog info from the facility (via CatalogInfo), but provides the ability to...
const std::unique_ptr< ICatalogInfo > m_catInfo
Facility catalog info. Aggregation only solution here.
const OptionalPath m_mountPoint
Archive mount point.
CatalogConfigService * makeCatalogConfigServiceAdapter(const T &adaptee, const std::string &key="icatDownload.mountPoint")
boost::optional< std::string > OptionalPath
Helper class which provides the Collimation Length for SANS instruments.