Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
ab222c7b
Commit
ab222c7b
authored
Sep 14, 2021
by
Zhang, Chen
Browse files
distinguish call by new name and deprecated alias
parent
5c1be9a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/API/inc/MantidAPI/Algorithm.h
View file @
ab222c7b
...
...
@@ -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.
...
...
Framework/API/src/Algorithm.cpp
View file @
ab222c7b
...
...
@@ -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.
...
...
Framework/API/src/AlgorithmFactory.cpp
View file @
ab222c7b
...
...
@@ -35,8 +35,8 @@ AlgorithmFactoryImpl::AlgorithmFactoryImpl() : Kernel::DynamicFactory<Algorithm>
AlgorithmFactoryImpl
::~
AlgorithmFactoryImpl
()
=
default
;
/** Creates an instance of an algorithm
* @param name :: the name of the Alg
r
orithm to create
* @param version :: the version of the alg
r
oithm to create
* @param name :: the name of the Algorithm to create
* @param version :: the version of the algo
r
ithm 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 alg
r
oithm if found
* @return Real name of algo
r
ithm if found
*/
boost
::
optional
<
std
::
string
>
AlgorithmFactoryImpl
::
getRealNameFromAlias
(
const
std
::
string
&
alias
)
const
noexcept
{
auto
a_it
=
m_amap
.
find
(
alias
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment