Commit ab222c7b authored by Zhang, Chen's avatar Zhang, Chen
Browse files

distinguish call by new name and deprecated alias

parent 5c1be9a2
......@@ -168,8 +168,11 @@ public:
/// Function to return all of the seeAlso (these are not validated) algorithms
/// related to this algorithm.A default implementation is provided.
const std::vector<std::string> seeAlso() const override { return {}; };
/// function to return any aliases to the algorithm; A default implementation is provided
/// Function to return any aliases to the algorithm; A default implementation
/// is provided
const std::string alias() const override { return ""; }
/// Flag to indicate if the algorithm is called by its alias.
bool calledByAlias = false;
/// function to return URL for algorithm documentation; A default
/// implementation is provided.
......
......@@ -10,6 +10,7 @@
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/DeprecatedAlgorithm.h"
#include "MantidAPI/DeprecatedAlias.h"
#include "MantidAPI/IWorkspaceProperty.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAPI/WorkspaceHistory.h"
......@@ -511,12 +512,21 @@ bool Algorithm::executeInternal() {
Timer timer;
bool algIsExecuted = false;
AlgorithmManager::Instance().notifyAlgorithmStarting(this->getAlgorithmID());
// runtime check for deprecation warning
{
auto *depo = dynamic_cast<DeprecatedAlgorithm *>(this);
if (depo != nullptr)
getLogger().error(depo->deprecationMsg(this));
}
// runtime check for deprecated alias warning
{
auto *da_alg = dynamic_cast<DeprecatedAlias *>(this);
if ((da_alg != nullptr) && (this->calledByAlias))
getLogger().warning(da_alg->deprecationMessage(this));
}
// Register clean up tasks that should happen regardless of the route
// out of the algorithm. These tasks will get run after this method
// finishes.
......
......@@ -35,8 +35,8 @@ AlgorithmFactoryImpl::AlgorithmFactoryImpl() : Kernel::DynamicFactory<Algorithm>
AlgorithmFactoryImpl::~AlgorithmFactoryImpl() = default;
/** Creates an instance of an algorithm
* @param name :: the name of the Algrorithm to create
* @param version :: the version of the algroithm to create
* @param name :: the name of the Algorithm to create
* @param version :: the version of the algorithm to create
* @returns a shared pointer to the created algorithm
*/
std::shared_ptr<Algorithm> AlgorithmFactoryImpl::create(const std::string &name, const int &version) const {
......@@ -58,7 +58,9 @@ std::shared_ptr<Algorithm> AlgorithmFactoryImpl::create(const std::string &name,
if (realName) {
// Try create algorithm again with real name
try {
return this->createAlgorithm(realName.get(), local_version);
auto alg = this->createAlgorithm(realName.get(), local_version);
alg->calledByAlias = true;
return alg;
} catch (Kernel::Exception::NotFoundError &) {
// Get highest registered version
const auto hVersion = highestVersion(realName.get()); // Throws if not found
......@@ -210,7 +212,7 @@ const std::vector<std::string> AlgorithmFactoryImpl::getKeys(bool includeHidden)
/**
* @param alias The name of the algorithm to look up in the alias map
* @return Real name of algroithm if found
* @return Real name of algorithm if found
*/
boost::optional<std::string> AlgorithmFactoryImpl::getRealNameFromAlias(const std::string &alias) const noexcept {
auto a_it = m_amap.find(alias);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment