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
95304fff
Commit
95304fff
authored
Sep 14, 2021
by
Zhang, Chen
Browse files
add new DepreceatedAlias class for c++ algs
parent
a72ca2b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/API/CMakeLists.txt
View file @
95304fff
...
...
@@ -30,6 +30,7 @@ set(SRC_FILES
src/CostFunctionFactory.cpp
src/DataProcessorAlgorithm.cpp
src/DeprecatedAlgorithm.cpp
src/DeprecatedAlias.cpp
src/DetectorSearcher.cpp
src/DistributedAlgorithm.cpp
src/DomainCreatorFactory.cpp
...
...
@@ -202,6 +203,7 @@ set(INC_FILES
inc/MantidAPI/DataProcessorAlgorithm.h
inc/MantidAPI/DeclareUserAlg.h
inc/MantidAPI/DeprecatedAlgorithm.h
inc/MantidAPI/DeprecatedAlias.h
inc/MantidAPI/DetectorSearcher.h
inc/MantidAPI/DistributedAlgorithm.h
inc/MantidAPI/DomainCreatorFactory.h
...
...
Framework/API/inc/MantidAPI/DeprecatedAlias.h
0 → 100644
View file @
95304fff
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include
"MantidAPI/Algorithm.h"
#include
"MantidAPI/DllConfig.h"
#include
"MantidAPI/IAlgorithm.h"
#include
<string>
namespace
Mantid
{
namespace
API
{
/** DeprecatedAlias :
* Class for making algorithm with deprecated names (aliases).
*
* This class will ensure that if an algorithm is invoke with a deprecated name,
* - a warning will be throw to inform the users that
* - the algorithm name is deprecated
* - the deprecation date
* - the new algorithm name the user is recommended to use instead
*
* All algorithms with deprecated alias need to inherit from this class.
*
* The recommended algorithm naming pattern should be
* [Technique][Facility/Instrument]ActionTarget
* For example: the calibration routine of panel detector for single crystal diffraction
* beamline can be named as SCDCalibratePanels
*/
class
MANTID_API_DLL
DeprecatedAlias
{
public:
DeprecatedAlias
();
virtual
~
DeprecatedAlias
();
std
::
string
deprecationMessage
(
const
IAlgorithm
*
);
void
setDeprecationDate
(
const
std
::
string
&
date
);
private:
/// Replacement version, -1 indicate latest
int
m_replacementVersion
;
/// Deprecation date
std
::
string
m_deprecationDate
;
};
}
// namespace API
}
// namespace Mantid
Framework/API/src/DeprecatedAlias.cpp
0 → 100644
View file @
95304fff
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include
"MantidAPI/DeprecatedAlias.h"
#include
"MantidAPI/AlgorithmFactory.h"
#include
"MantidKernel/Logger.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
namespace
Mantid
{
namespace
API
{
namespace
{
Kernel
::
Logger
g_log
(
"DeprecatedAlias"
);
}
// namespace
/// Constructor to ensure the compiler is happy
DeprecatedAlias
::
DeprecatedAlias
()
:
m_replacementVersion
(
-
1
),
m_deprecationDate
()
{}
/// Destructor to ensure the compiler is happy
DeprecatedAlias
::~
DeprecatedAlias
()
=
default
;
/**
* @brief Set the deprecation date which will be used to inform the users
*
* @param date : deprecation date in ISO8601 format
*/
void
DeprecatedAlias
::
setDeprecationDate
(
const
std
::
string
&
date
)
{
m_deprecationDate
=
""
;
if
((
!
date
.
empty
())
&&
(
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
date
)))
{
m_deprecationDate
=
date
;
}
else
{
throw
std
::
invalid_argument
(
"DeprecatedAlias::DeprecationDate(): deprecation date must follow ISO8601."
);
}
}
/**
* @brief Construct and return a full deprecation message
*
* @param algo
* @return std::string
*/
std
::
string
DeprecatedAlias
::
deprecationMessage
(
const
IAlgorithm
*
algo
)
{
std
::
stringstream
msg
;
// TODO: proper deprecation message
msg
<<
"The algorithm '"
<<
algo
->
name
()
<<
"' has been deprecated. "
;
return
msg
.
str
();
}
}
// namespace API
}
// namespace Mantid
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