Mantid
Loading...
Searching...
No Matches
DeprecatedAlias.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 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
10#include "MantidKernel/Logger.h"
11#include "MantidTypes/Core/DateAndTimeHelpers.h"
12
13namespace Mantid::API {
14
15namespace {
16Kernel::Logger g_log("DeprecatedAlias");
17} // namespace
18
20DeprecatedAlias::DeprecatedAlias() : m_deprecationDate() {}
21
24
30void DeprecatedAlias::setDeprecationDate(const std::string &date) {
32 if ((!date.empty()) && (Types::Core::DateAndTimeHelpers::stringIsISO8601(date))) {
33 m_deprecationDate = date;
34 } else {
35 throw std::invalid_argument("DeprecatedAlias::DeprecationDate(): deprecation date must follow ISO8601.");
36 }
37}
38
46 std::stringstream msg;
47
48 auto alias = algo->alias();
49
50 if (alias.empty()) {
51 throw std::logic_error("Cannot find the deprecated alias for this algorithm.");
52 } else {
53 msg << "The algorithm '" << alias << "' is deprecated on " << m_deprecationDate << "."
54 << "Please use '" << algo->name() << "' instead.";
55 }
56
57 return msg.str();
58}
59
60} // namespace Mantid::API
std::string m_deprecationDate
Deprecation date.
void setDeprecationDate(const std::string &date)
Set the deprecation date which will be used to inform the users.
std::string deprecationMessage(const IAlgorithm *)
Construct and return a full deprecation message.
virtual ~DeprecatedAlias()
Destructor to ensure the compiler is happy.
DeprecatedAlias()
Constructor to ensure the compiler is happy.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
virtual const std::string alias() const =0
function to return any aliases of the algorithm.
virtual const std::string name() const =0
function to return a name of the algorithm, must be overridden in all algorithms
Kernel::Logger g_log("ExperimentInfo")
static logger object