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
590336bc
Commit
590336bc
authored
Mar 31, 2021
by
Peterson, Peter
Browse files
clang-format the repository ... again
parent
55311b02
Changes
1000
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 1000+
files are displayed.
Plain diff
Email patch
Framework/API/inc/MantidAPI/ADSValidator.h
View file @
590336bc
...
...
@@ -18,12 +18,10 @@ namespace API {
/** ADSValidator : a validator that requires the value of a property to be
present in the ADS. The type must be std::string
*/
class
MANTID_API_DLL
ADSValidator
:
public
Kernel
::
TypedValidator
<
std
::
vector
<
std
::
string
>>
{
class
MANTID_API_DLL
ADSValidator
:
public
Kernel
::
TypedValidator
<
std
::
vector
<
std
::
string
>>
{
public:
/// Default constructor. Sets up an empty list of valid values.
ADSValidator
(
const
bool
allowMultiSelection
=
true
,
const
bool
isOptional
=
false
);
ADSValidator
(
const
bool
allowMultiSelection
=
true
,
const
bool
isOptional
=
false
);
/// Clone the validator
Kernel
::
IValidator_sptr
clone
()
const
override
;
...
...
@@ -45,8 +43,7 @@ protected:
* @return "" if the value is on the list, or "The workspace is not in the
* workspace list"
*/
std
::
string
checkValidity
(
const
std
::
vector
<
std
::
string
>
&
value
)
const
override
;
std
::
string
checkValidity
(
const
std
::
vector
<
std
::
string
>
&
value
)
const
override
;
private:
/// if the validator should allow multiple selection
...
...
Framework/API/inc/MantidAPI/AlgoTimeRegister.h
View file @
590336bc
...
...
@@ -30,8 +30,7 @@ public:
timespec
m_begin
;
timespec
m_end
;
Info
(
const
std
::
string
&
nm
,
const
std
::
thread
::
id
&
id
,
const
timespec
&
be
,
const
timespec
&
en
)
Info
(
const
std
::
string
&
nm
,
const
std
::
thread
::
id
&
id
,
const
timespec
&
be
,
const
timespec
&
en
)
:
m_name
(
nm
),
m_threadId
(
id
),
m_begin
(
be
),
m_end
(
en
)
{}
};
...
...
Framework/API/inc/MantidAPI/Algorithm.h
View file @
590336bc
...
...
@@ -75,8 +75,7 @@ Gaudi user guide).
http://proj-gaudi.web.cern.ch/proj-gaudi/)
@date 12/09/2007
*/
class
MANTID_API_DLL
Algorithm
:
public
IAlgorithm
,
public
Kernel
::
PropertyManagerOwner
{
class
MANTID_API_DLL
Algorithm
:
public
IAlgorithm
,
public
Kernel
::
PropertyManagerOwner
{
public:
/// Base class for algorithm notifications
class
MANTID_API_DLL
AlgorithmNotification
:
public
Poco
::
Notification
{
...
...
@@ -109,8 +108,7 @@ public:
class
MANTID_API_DLL
ProgressNotification
:
public
AlgorithmNotification
{
public:
/// Constructor
ProgressNotification
(
const
Algorithm
*
const
alg
,
double
p
,
const
std
::
string
&
msg
,
double
estimatedTime
,
ProgressNotification
(
const
Algorithm
*
const
alg
,
double
p
,
const
std
::
string
&
msg
,
double
estimatedTime
,
int
progressPrecision
);
std
::
string
name
()
const
override
;
double
progress
;
///< Current progress. Value must be between 0 and 1.
...
...
@@ -179,30 +177,21 @@ public:
/// Override if the algorithm is not part of the Mantid distribution.
const
std
::
string
helpURL
()
const
override
{
return
""
;
}
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
std
::
tuple
<
std
::
shared_ptr
<
T
>
,
Indexing
::
SpectrumIndexSet
>
getWorkspaceAndIndices
(
const
std
::
string
&
name
)
const
;
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
std
::
tuple
<
std
::
shared_ptr
<
T
>
,
Indexing
::
SpectrumIndexSet
>
getWorkspaceAndIndices
(
const
std
::
string
&
name
)
const
;
template
<
typename
T1
,
typename
T2
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int64_t
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
std
::
shared_ptr
<
T1
>
&
wksp
,
IndexType
type
,
const
T2
&
list
);
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int64_t
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
std
::
shared_ptr
<
T1
>
&
wksp
,
IndexType
type
,
const
T2
&
list
);
template
<
typename
T1
,
typename
T2
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int64_t
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
std
::
string
&
wsName
,
IndexType
type
,
const
T2
&
list
);
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int64_t
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
std
::
string
&
wsName
,
IndexType
type
,
const
T2
&
list
);
const
std
::
string
workspaceMethodName
()
const
override
;
const
std
::
vector
<
std
::
string
>
workspaceMethodOn
()
const
override
;
...
...
@@ -261,13 +250,9 @@ public:
bool
getAlgStartupLogging
()
const
override
;
/// setting the child start progress
void
setChildStartProgress
(
const
double
startProgress
)
const
override
{
m_startChildProgress
=
startProgress
;
}
void
setChildStartProgress
(
const
double
startProgress
)
const
override
{
m_startChildProgress
=
startProgress
;
}
/// setting the child end progress
void
setChildEndProgress
(
const
double
endProgress
)
const
override
{
m_endChildProgress
=
endProgress
;
}
void
setChildEndProgress
(
const
double
endProgress
)
const
override
{
m_endChildProgress
=
endProgress
;
}
/** @name Serialization functions */
//@{
...
...
@@ -283,14 +268,11 @@ public:
static
IAlgorithm_sptr
fromHistory
(
const
AlgorithmHistory
&
history
);
//@}
virtual
std
::
shared_ptr
<
Algorithm
>
createChildAlgorithm
(
const
std
::
string
&
name
,
const
double
startProgress
=
-
1.
,
const
double
endProgress
=
-
1.
,
const
bool
enableLogging
=
true
,
const
int
&
version
=
-
1
);
void
setupAsChildAlgorithm
(
const
std
::
shared_ptr
<
Algorithm
>
&
algorithm
,
const
double
startProgress
=
-
1.
,
const
double
endProgress
=
-
1.
,
const
bool
enableLogging
=
true
);
virtual
std
::
shared_ptr
<
Algorithm
>
createChildAlgorithm
(
const
std
::
string
&
name
,
const
double
startProgress
=
-
1.
,
const
double
endProgress
=
-
1.
,
const
bool
enableLogging
=
true
,
const
int
&
version
=
-
1
);
void
setupAsChildAlgorithm
(
const
std
::
shared_ptr
<
Algorithm
>
&
algorithm
,
const
double
startProgress
=
-
1.
,
const
double
endProgress
=
-
1.
,
const
bool
enableLogging
=
true
);
/// set whether we wish to track the child algorithm's history and pass it the
/// parent object to fill.
...
...
@@ -298,8 +280,7 @@ public:
using
WorkspaceVector
=
std
::
vector
<
std
::
shared_ptr
<
Workspace
>>
;
void
findWorkspaces
(
WorkspaceVector
&
workspaces
,
unsigned
int
direction
,
bool
checkADS
=
false
)
const
;
void
findWorkspaces
(
WorkspaceVector
&
workspaces
,
unsigned
int
direction
,
bool
checkADS
=
false
)
const
;
// ------------------ For WorkspaceGroups ------------------------------------
virtual
bool
checkGroups
();
...
...
@@ -321,8 +302,8 @@ protected:
virtual
void
execDistributed
();
virtual
void
execMasterOnly
();
virtual
Parallel
::
ExecutionMode
getParallelExecutionMode
(
const
std
::
map
<
std
::
string
,
Parallel
::
StorageMode
>
&
storageModes
)
const
;
virtual
Parallel
::
ExecutionMode
getParallelExecutionMode
(
const
std
::
map
<
std
::
string
,
Parallel
::
StorageMode
>
&
storageModes
)
const
;
/// Returns a semi-colon separated list of workspace types to attach this
/// algorithm
...
...
@@ -331,17 +312,14 @@ protected:
void
cacheWorkspaceProperties
();
void
cacheInputWorkspaceHistories
();
void
setExecutionState
(
const
ExecutionState
state
);
///< Sets the current execution state
void
setResultState
(
const
ResultState
state
);
///< Sets the result execution state
void
setExecutionState
(
const
ExecutionState
state
);
///< Sets the current execution state
void
setResultState
(
const
ResultState
state
);
///< Sets the result execution state
void
store
();
/** @name Progress Reporting functions */
friend
class
Progress
;
void
progress
(
double
p
,
const
std
::
string
&
msg
=
""
,
double
estimatedTime
=
0.0
,
int
progressPrecision
=
0
);
void
progress
(
double
p
,
const
std
::
string
&
msg
=
""
,
double
estimatedTime
=
0.0
,
int
progressPrecision
=
0
);
void
interruption_point
();
/// Return a reference to the algorithm's notification dispatcher
...
...
@@ -349,8 +327,7 @@ protected:
/// Observation slot for child algorithm progress notification messages, these
/// are scaled and then signalled for this algorithm.
void
handleChildProgressNotification
(
const
Poco
::
AutoPtr
<
ProgressNotification
>
&
pNf
);
void
handleChildProgressNotification
(
const
Poco
::
AutoPtr
<
ProgressNotification
>
&
pNf
);
/// Return a reference to the algorithm's object that is reporting progress
const
Poco
::
AbstractObserver
&
progressObserver
()
const
;
...
...
@@ -374,12 +351,9 @@ protected:
friend
class
WorkspaceHistory
;
// Allow workspace history loading to adjust
// g_execCount
static
size_t
g_execCount
;
///< Counter to keep track of algorithm execution order
static
size_t
g_execCount
;
///< Counter to keep track of algorithm execution order
virtual
void
setOtherProperties
(
IAlgorithm
*
alg
,
const
std
::
string
&
propertyName
,
const
std
::
string
&
propertyValue
,
virtual
void
setOtherProperties
(
IAlgorithm
*
alg
,
const
std
::
string
&
propertyName
,
const
std
::
string
&
propertyValue
,
int
periodNum
);
/// All the WorkspaceProperties that are Input or InOut. Set in execute()
...
...
@@ -403,18 +377,14 @@ protected:
/// versions
bool
m_usingBaseProcessGroups
=
false
;
template
<
typename
T
,
const
int
AllowedIndexTypes
=
IndexType
::
WorkspaceIndex
,
typename
...
WSPropArgs
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
void
declareWorkspaceInputProperties
(
const
std
::
string
&
propertyName
,
const
std
::
string
&
doc
,
WSPropArgs
&&
...
wsPropArgs
);
template
<
typename
T
,
const
int
AllowedIndexTypes
=
IndexType
::
WorkspaceIndex
,
typename
...
WSPropArgs
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
void
declareWorkspaceInputProperties
(
const
std
::
string
&
propertyName
,
const
std
::
string
&
doc
,
WSPropArgs
&&
...
wsPropArgs
);
private:
template
<
typename
T1
,
typename
T2
,
typename
WsType
>
void
doSetInputProperties
(
const
std
::
string
&
name
,
const
T1
&
wksp
,
IndexType
type
,
const
T2
&
list
);
void
doSetInputProperties
(
const
std
::
string
&
name
,
const
T1
&
wksp
,
IndexType
type
,
const
T2
&
list
);
void
lockWorkspaces
();
void
unlockWorkspaces
();
...
...
@@ -434,48 +404,43 @@ private:
void
fillHistory
(
const
std
::
vector
<
Workspace_sptr
>
&
outputWorkspaces
);
// Report that the algorithm has completed.
void
reportCompleted
(
const
double
&
duration
,
const
bool
groupProcessing
=
false
);
void
reportCompleted
(
const
double
&
duration
,
const
bool
groupProcessing
=
false
);
void
registerFeatureUsage
()
const
;
Parallel
::
ExecutionMode
getExecutionMode
()
const
;
std
::
map
<
std
::
string
,
Parallel
::
StorageMode
>
getInputWorkspaceStorageModes
()
const
;
std
::
map
<
std
::
string
,
Parallel
::
StorageMode
>
getInputWorkspaceStorageModes
()
const
;
void
setupSkipValidationMasterOnly
();
bool
isCompoundProperty
(
const
std
::
string
&
name
)
const
;
// --------------------- Private Members -----------------------------------
/// Poco::ActiveMethod used to implement asynchronous execution.
std
::
unique_ptr
<
Poco
::
ActiveMethod
<
bool
,
Poco
::
Void
,
Algorithm
,
Poco
::
ActiveStarter
<
Algorithm
>>>
m_executeAsync
;
std
::
unique_ptr
<
Poco
::
ActiveMethod
<
bool
,
Poco
::
Void
,
Algorithm
,
Poco
::
ActiveStarter
<
Algorithm
>>>
m_executeAsync
;
/// Sends notifications to observers. Observers can subscribe to
/// notificationCenter
/// using Poco::NotificationCenter::addObserver(...);
mutable
std
::
unique_ptr
<
Poco
::
NotificationCenter
>
m_notificationCenter
;
/// Child algorithm progress observer
mutable
std
::
unique_ptr
<
Poco
::
NObserver
<
Algorithm
,
ProgressNotification
>>
m_progressObserver
;
std
::
atomic
<
ExecutionState
>
m_executionState
;
///< the current execution state
std
::
atomic
<
ResultState
>
m_resultState
;
///< the current result State
bool
m_isChildAlgorithm
;
///< Algorithm is a child algorithm
bool
m_recordHistoryForChild
;
///< Flag to indicate whether history should be
/// recorded. Applicable to child algs only
bool
m_alwaysStoreInADS
;
///< Always store in the ADS, even for child algos
bool
m_runningAsync
;
///< Algorithm is running asynchronously
bool
m_rethrow
;
///< Algorithm should rethrow exceptions while executing
bool
m_isAlgStartupLoggingEnabled
;
/// Whether to log alg startup and
/// closedown messages from the base class
/// (default = true)
mutable
double
m_startChildProgress
;
///< Keeps value for algorithm's progress
/// at start of an Child Algorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress
/// at Child Algorithm's finish
AlgorithmID
m_algorithmID
;
///< Algorithm ID for managed algorithms
mutable
std
::
unique_ptr
<
Poco
::
NObserver
<
Algorithm
,
ProgressNotification
>>
m_progressObserver
;
std
::
atomic
<
ExecutionState
>
m_executionState
;
///< the current execution state
std
::
atomic
<
ResultState
>
m_resultState
;
///< the current result State
bool
m_isChildAlgorithm
;
///< Algorithm is a child algorithm
bool
m_recordHistoryForChild
;
///< Flag to indicate whether history should be
/// recorded. Applicable to child algs only
bool
m_alwaysStoreInADS
;
///< Always store in the ADS, even for child algos
bool
m_runningAsync
;
///< Algorithm is running asynchronously
bool
m_rethrow
;
///< Algorithm should rethrow exceptions while executing
bool
m_isAlgStartupLoggingEnabled
;
/// Whether to log alg startup and
/// closedown messages from the base class
/// (default = true)
mutable
double
m_startChildProgress
;
///< Keeps value for algorithm's progress
/// at start of an Child Algorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress
/// at Child Algorithm's finish
AlgorithmID
m_algorithmID
;
///< Algorithm ID for managed algorithms
std
::
vector
<
std
::
weak_ptr
<
IAlgorithm
>>
m_ChildAlgorithms
;
///< A list of
/// weak pointers
/// to any child
...
...
@@ -523,8 +488,8 @@ using Algorithm_sptr = std::shared_ptr<Algorithm>;
* is used in the call to its constructor to effect a call to the factory's
* subscribe method.
*/
#define DECLARE_ALGORITHM(classname) \
namespace { \
Mantid::Kernel::RegistrationHelper
register_alg_##classname((
\
(Mantid::API::AlgorithmFactory::Instance().subscribe<classname>()), 0)); \
#define DECLARE_ALGORITHM(classname)
\
namespace {
\
Mantid::Kernel::RegistrationHelper
\
register_alg_##classname((
(Mantid::API::AlgorithmFactory::Instance().subscribe<classname>()), 0));
\
}
Framework/API/inc/MantidAPI/Algorithm.tcc
View file @
590336bc
...
...
@@ -16,14 +16,12 @@
namespace {
template <typename T1, typename T2>
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp,
const T2 &wksp, const std::true_type &) {
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp, const T2 &wksp, const std::true_type &) {
*wsProp = wksp;
}
template <typename T1, typename T2>
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp,
const T2 &wksp, const std::false_type &) {
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp, const T2 &wksp, const std::false_type &) {
wsProp->setValue(wksp);
}
} // namespace
...
...
@@ -40,30 +38,23 @@ IndexType::WorkspaceIndex
Can contain PropertyMode, LockMode, and validators.
@param doc Property documentation string.
*/
template <typename T, const int AllowedIndexTypes, typename... WSPropArgs,
typename>
void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName,
const std::string &doc,
WSPropArgs &&... wsPropArgs) {
auto wsProp = std::make_unique<WorkspaceProperty<T>>(
propertyName, "", Kernel::Direction::Input,
std::forward<WSPropArgs>(wsPropArgs)...);
template <typename T, const int AllowedIndexTypes, typename... WSPropArgs, typename>
void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName, const std::string &doc,
WSPropArgs &&...wsPropArgs) {
auto wsProp = std::make_unique<WorkspaceProperty<T>>(propertyName, "", Kernel::Direction::Input,
std::forward<WSPropArgs>(wsPropArgs)...);
const auto &wsPropRef = *wsProp;
declareProperty(std::move(wsProp), doc);
auto indexTypePropName =
IndexTypeProperty::generatePropertyName(propertyName);
auto indexTypeProp =
std::make_unique<IndexTypeProperty>(indexTypePropName, AllowedIndexTypes);
auto indexTypePropName = IndexTypeProperty::generatePropertyName(propertyName);
auto indexTypeProp = std::make_unique<IndexTypeProperty>(indexTypePropName, AllowedIndexTypes);
const auto &indexTypePropRef = *indexTypeProp;
declareProperty(std::move(indexTypeProp),
"The type of indices in the optional index set; For optimal "
"performance WorkspaceIndex should be preferred;");
declareProperty(std::move(indexTypeProp), "The type of indices in the optional index set; For optimal "
"performance WorkspaceIndex should be preferred;");
auto indexPropName = IndexProperty::generatePropertyName(propertyName);
declareProperty(std::make_unique<IndexProperty>(indexPropName, wsPropRef,
indexTypePropRef),
declareProperty(std::make_unique<IndexProperty>(indexPropName, wsPropRef, indexTypePropRef),
"An optional set of spectra that will be processed by the "
"algorithm; If not set, all spectra will be processed; The "
"indices in this list can be workspace indices or possibly "
...
...
@@ -77,23 +68,18 @@ void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName,
}
template <typename T1, typename T2, typename WsType>
void Algorithm::doSetInputProperties(const std::string &name, const T1 &wksp,
IndexType type, const T2 &list) {
void Algorithm::doSetInputProperties(const std::string &name, const T1 &wksp, IndexType type, const T2 &list) {
if (!isCompoundProperty(name))
throw std::runtime_error(
"Algorithm::setWorkspaceInputProperties can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
throw std::runtime_error("Algorithm::setWorkspaceInputProperties can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
auto *wsProp =
dynamic_cast<WorkspaceProperty<WsType> *>(getPointerToProperty(name));
auto *indexTypeProp = dynamic_cast<IndexTypeProperty *>(
getPointerToProperty(IndexTypeProperty::generatePropertyName(name)));
auto *indexProp = dynamic_cast<IndexProperty *>(
getPointerToProperty(IndexProperty::generatePropertyName(name)));
auto *wsProp = dynamic_cast<WorkspaceProperty<WsType> *>(getPointerToProperty(name));
auto *indexTypeProp =
dynamic_cast<IndexTypeProperty *>(getPointerToProperty(IndexTypeProperty::generatePropertyName(name)));
auto *indexProp = dynamic_cast<IndexProperty *>(getPointerToProperty(IndexProperty::generatePropertyName(name)));
setWorkspaceProperty<WsType, T1>(
wsProp, wksp, std::is_convertible<T1, std::shared_ptr<WsType>>());
setWorkspaceProperty<WsType, T1>(wsProp, wksp, std::is_convertible<T1, std::shared_ptr<WsType>>());
*indexTypeProp = type;
...
...
@@ -110,9 +96,8 @@ void Algorithm::doSetInputProperties(const std::string &name, const T1 &wksp,
@param list List of indices to be used.
*/
template <typename T1, typename T2, typename, typename>
void Algorithm::setWorkspaceInputProperties(const std::string &name,
const std::shared_ptr<T1> &wksp,
IndexType type, const T2 &list) {
void Algorithm::setWorkspaceInputProperties(const std::string &name, const std::shared_ptr<T1> &wksp, IndexType type,
const T2 &list) {
doSetInputProperties<std::shared_ptr<T1>, T2, T1>(name, wksp, type, list);
}
...
...
@@ -126,9 +111,8 @@ void Algorithm::setWorkspaceInputProperties(const std::string &name,
@param list List of indices to be used.
*/
template <typename T1, typename T2, typename, typename>
void Algorithm::setWorkspaceInputProperties(const std::string &name,
const std::string &wsName,
IndexType type, const T2 &list) {
void Algorithm::setWorkspaceInputProperties(const std::string &name, const std::string &wsName, IndexType type,
const T2 &list) {
doSetInputProperties<std::string, T2, T1>(name, wsName, type, list);
}
...
...
@@ -142,10 +126,9 @@ template <typename T, typename>
std::tuple<std::shared_ptr<T>, Indexing::SpectrumIndexSet>
Algorithm::getWorkspaceAndIndices(const std::string &name) const {
if (!isCompoundProperty(name))
throw std::runtime_error(
"Algorithm::getWorkspacesAndIndices can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
throw std::runtime_error("Algorithm::getWorkspacesAndIndices can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
std::shared_ptr<T> ws = getProperty(name);
...
...
@@ -156,8 +139,7 @@ Algorithm::getWorkspaceAndIndices(const std::string &name) const {
// problems related to the property mechanism in the future:
// https://github.com/mantidproject/mantid/issues/20092
auto indexProp = dynamic_cast<IndexProperty *>(
getPointerToProperty(IndexProperty::generatePropertyName(name)));
auto indexProp = dynamic_cast<IndexProperty *>(getPointerToProperty(IndexProperty::generatePropertyName(name)));
Indexing::SpectrumIndexSet indexSet = *indexProp;
return std::make_tuple(ws, indexSet);
...
...
Framework/API/inc/MantidAPI/AlgorithmFactory.h
View file @
590336bc
...
...
@@ -45,8 +45,7 @@ class Algorithm;
@author Russell Taylor, Tessella Support Services plc
@date 21/09/2007
*/
class
MANTID_API_DLL
AlgorithmFactoryImpl
final
:
public
Kernel
::
DynamicFactory
<
Algorithm
>
{
class
MANTID_API_DLL
AlgorithmFactoryImpl
final
:
public
Kernel
::
DynamicFactory
<
Algorithm
>
{
public:
AlgorithmFactoryImpl
(
const
AlgorithmFactoryImpl
&
)
=
delete
;
AlgorithmFactoryImpl
&
operator
=
(
const
AlgorithmFactoryImpl
&
)
=
delete
;
...
...
@@ -72,9 +71,8 @@ public:
* @returns The classname that was registered
*/
template
<
class
T
>
std
::
pair
<
std
::
string
,
int
>
subscribe
(
std
::
unique_ptr
<
Kernel
::
AbstractInstantiator
<
T
>>
instantiator
,
const
SubscribeAction
replaceExisting
=
ErrorIfExists
)
{
std
::
pair
<
std
::
string
,
int
>
subscribe
(
std
::
unique_ptr
<
Kernel
::
AbstractInstantiator
<
T
>>
instantiator
,
const
SubscribeAction
replaceExisting
=
ErrorIfExists
)
{
const
auto
tempAlg
=
instantiator
->
createInstance
();
const
int
version
=
extractAlgVersion
(
tempAlg
);
const
std
::
string
className
=
extractAlgName
(
tempAlg
);
...
...
@@ -87,16 +85,14 @@ public:
}
else
{
if
(
version
==
it
->
second
&&
replaceExisting
==
ErrorIfExists
)
{
std
::
ostringstream
os
;
os
<<
"Cannot register algorithm "
<<
className
<<
" twice with the same version
\n
"
;
os
<<
"Cannot register algorithm "
<<
className
<<
" twice with the same version
\n
"
;
throw
std
::
runtime_error
(
os
.
str
());
}
if
(
version
>
it
->
second
)
{
m_vmap
[
className
]
=
version
;
}
}
Kernel
::
DynamicFactory
<
Algorithm
>::
subscribe
(
key
,
std
::
move
(
instantiator
),
replaceExisting
);
Kernel
::
DynamicFactory
<
Algorithm
>::
subscribe
(
key
,
std
::
move
(
instantiator
),
replaceExisting
);
}
else
{
throw
std
::
invalid_argument
(
"Cannot register empty algorithm name"
);
}
...
...
@@ -116,22 +112,19 @@ public:
const
std
::
vector
<
std
::
string
>
getKeys
(
bool
includeHidden
)
const
;
/// Get an algorithms name from the alias map
boost
::
optional
<
std
::
string
>
getRealNameFromAlias
(
const
std
::
string
&
alias
)
const
noexcept
;
boost
::
optional
<
std
::
string
>
getRealNameFromAlias
(
const
std
::
string
&
alias
)
const
noexcept
;
/// Returns the highest version of the algorithm currently registered
int
highestVersion
(
const
std
::
string
&
algorithmName
)
const
;
/// Get the algorithm categories
const
std
::
unordered_set
<
std
::
string
>
getCategories
(
bool
includeHidden
=
false
)
const
;
const
std
::
unordered_set
<
std
::
string
>
getCategories
(
bool
includeHidden
=
false
)
const
;
/// Get the algorithm categories
const
std
::
map
<
std
::
string
,
bool
>
getCategoriesWithState
()
const
;
/// Returns algorithm descriptors.
std
::
vector
<
AlgorithmDescriptor
>
getDescriptors
(
bool
includeHidden
=
false
,
bool
includeAliases
=
false
)
const
;
std
::
vector
<
AlgorithmDescriptor
>
getDescriptors
(
bool
includeHidden
=
false
,
bool
includeAliases
=
false
)
const
;
/// unmangles the names used as keys into the name and version
std
::
pair
<
std
::
string
,
int
>
decodeName
(
const
std
::
string
&
mangledName
)
const
;
...
...
@@ -140,17 +133,14 @@ private:
friend
struct
Mantid
::
Kernel
::
CreateUsingNew
<
AlgorithmFactoryImpl
>
;
/// Extract the name of an algorithm
const
std
::
string
extractAlgName
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
alg
)
const
;
const
std
::
string
extractAlgName
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
alg
)
const
;
/// Extract the version of an algorithm
int
extractAlgVersion
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
alg
)
const
;
/// Extract the alias of an algorithm
const
std
::
string
extractAlgAlias
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
alg
)
const
;
const
std
::
string
extractAlgAlias
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
alg
)
const
;
/// Create an algorithm object with the specified name
std
::
shared_ptr
<
Algorithm
>
createAlgorithm
(
const
std
::
string
&
name
,
const
int
version
)
const
;
std
::
shared_ptr
<
Algorithm
>
createAlgorithm
(
const
std
::
string
&
name
,
const
int
version
)
const
;
/// Private Constructor for singleton class
AlgorithmFactoryImpl
();
...
...
@@ -174,17 +164,15 @@ private:
using
AlgorithmFactory
=
Mantid
::
Kernel
::
SingletonHolder
<
AlgorithmFactoryImpl
>
;
/// Convenient typedef for an UpdateNotification
using
AlgorithmFactoryUpdateNotification
=
Mantid
::
Kernel
::
DynamicFactory
<
Algorithm
>::
UpdateNotification
;
using
AlgorithmFactoryUpdateNotification_ptr
=
const
Poco
::
AutoPtr
<
Mantid
::
Kernel
::
DynamicFactory
<
Algorithm
>::
UpdateNotification
>
&
;
using
AlgorithmFactoryUpdateNotification
=
Mantid
::
Kernel
::
DynamicFactory
<
Algorithm
>::
UpdateNotification
;
using
AlgorithmFactoryUpdateNotification_ptr
=
const
Poco
::
AutoPtr
<
Mantid
::
Kernel
::
DynamicFactory
<
Algorithm
>::
UpdateNotification
>
&
;
}
// namespace API
}
// namespace Mantid
namespace
Mantid
{
namespace
Kernel
{
EXTERN_MANTID_API
template
class
MANTID_API_DLL
Mantid
::
Kernel
::
SingletonHolder
<
Mantid
::
API
::
AlgorithmFactoryImpl
>;
EXTERN_MANTID_API
template
class
MANTID_API_DLL
Mantid
::
Kernel
::
SingletonHolder
<
Mantid
::
API
::
AlgorithmFactoryImpl
>;
}
}
// namespace Mantid
Framework/API/inc/MantidAPI/AlgorithmFactoryObserver.h
View file @
590336bc
...
...
@@ -45,8 +45,7 @@ private:
void
_updateHandle
(
AlgorithmFactoryUpdateNotification_ptr
pNf
);
/// Poco::NObserver for SubscribeNotification.
Poco
::
NObserver
<
AlgorithmFactoryObserver
,
AlgorithmFactoryUpdateNotification
>
m_updateObserver
;
Poco
::
NObserver
<
AlgorithmFactoryObserver
,
AlgorithmFactoryUpdateNotification
>
m_updateObserver
;
};
}
// namespace API
...
...
Framework/API/inc/MantidAPI/AlgorithmHasProperty.h
View file @
590336bc
...
...
@@ -21,16 +21,14 @@ class IAlgorithm;
@author Martyn Gigg, Tessella plc
@date 30/03/2011
*/
class
MANTID_API_DLL
AlgorithmHasProperty
:
public
Kernel
::
TypedValidator
<
std
::
shared_ptr
<
IAlgorithm
>>
{
class
MANTID_API_DLL
AlgorithmHasProperty
:
public
Kernel
::
TypedValidator
<
std
::
shared_ptr
<
IAlgorithm
>>
{
public:
AlgorithmHasProperty
(
const
std
::
string
&
propName
);
std
::
string
getType
()
const
;
Kernel
::
IValidator_sptr
clone
()
const
override
;
protected:
std
::
string
checkValidity
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
value
)
const
override
;
std
::
string
checkValidity
(
const
std
::
shared_ptr
<
IAlgorithm
>
&
value
)
const
override
;
private:
/// Store the property name
...
...
Framework/API/inc/MantidAPI/AlgorithmHistory.h
View file @
590336bc
...
...
@@ -46,21 +46,17 @@ public:
/// The date-and-time will be stored as the Mantid::Types::Core::DateAndTime
/// type
explicit
AlgorithmHistory
(
const
Algorithm
*
const
alg
,
const
Types
::
Core
::
DateAndTime
&
start
=
Types
::
Core
::
DateAndTime
::
getCurrentTime
(),
const
double
&
duration
=
-
1.0
,
std
::
size_t
uexeccount
=
0
);
const
Types
::
Core
::
DateAndTime
&
start
=
Types
::
Core
::
DateAndTime
::
getCurrentTime
(),
const
double
&
duration
=
-
1.0
,
std
::
size_t
uexeccount
=
0
);
~
AlgorithmHistory
();
AlgorithmHistory
&
operator
=
(
const
AlgorithmHistory
&
);
AlgorithmHistory
(
const
AlgorithmHistory
&
);
AlgorithmHistory
(
const
std
::
string
&
name
,
int
vers
,
std
::
string
uuid
,
const
Types
::
Core
::
DateAndTime
&
start
=
Types
::
Core
::
DateAndTime
::
getCurrentTime
(),
const
Types
::
Core
::
DateAndTime
&
start
=
Types
::
Core
::
DateAndTime
::
getCurrentTime
(),