Mantid
Loading...
Searching...
No Matches
DeprecatedAlgorithmChecker.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
10#include <boost/python/class.hpp>
11
16
17using namespace boost::python;
18
19namespace {
32class DeprecatedAlgorithmChecker {
33public:
39 DeprecatedAlgorithmChecker(const std::string &algName, int version)
40 : m_alg(AlgorithmManager::Instance().createUnmanaged(algName, version)) {}
41
45 const std::string isDeprecated() const {
46 std::string deprecMessage;
47 auto *depr = dynamic_cast<DeprecatedAlgorithm *>(m_alg.get());
48 auto *deprecatedAliasAlg = dynamic_cast<DeprecatedAlias *>(m_alg.get());
49
50 if (depr)
51 deprecMessage = depr->deprecationMsg(m_alg.get());
52 else if (deprecatedAliasAlg)
53 deprecMessage = deprecatedAliasAlg->deprecationMessage(m_alg.get());
54
55 return deprecMessage;
56 }
57
58private:
60 DeprecatedAlgorithmChecker() = delete;
62 IAlgorithm_sptr m_alg;
63};
64} // namespace
65
67 class_<DeprecatedAlgorithmChecker>("DeprecatedAlgorithmChecker", no_init)
68 .def(init<const std::string &, int>((arg("algName"), arg("version")),
69 "Constructs a DeprecatedAlgorithmChecker for the given algorithm & "
70 "version. (-1 indicates latest version)"))
71 .def("isDeprecated", &DeprecatedAlgorithmChecker::isDeprecated,
72 "A string containing a deprecation message if the algorithm is "
73 "deprecated, empty string otherwise");
74}
void export_DeprecatedAlgorithmChecker()
Class for marking algorithms as deprecated.
DeprecatedAlias : Class for making algorithm with deprecated names (aliases).
std::string deprecationMessage(const IAlgorithm *)
Construct and return a full deprecation message.
Manage the lifetime of a class intended to be a singleton.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
Mantid::Kernel::SingletonHolder< AlgorithmManagerImpl > AlgorithmManager