Mantid
Loading...
Searching...
No Matches
AlgorithmHintStrategy.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2014 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#pragma once
8
9#include <utility>
10
14
15namespace MantidQt {
16namespace MantidWidgets {
20public:
21 AlgorithmHintStrategy(Mantid::API::IAlgorithm_sptr algorithm, std::vector<std::string> blacklist)
22 : m_algorithm(std::move(algorithm)), m_blacklist(std::move(blacklist)) {}
23
24 AlgorithmHintStrategy(std::string const &algorithmName, std::vector<std::string> blacklist)
25 : m_algorithm(Mantid::API::AlgorithmManager::Instance().create(algorithmName)),
26 m_blacklist(std::move(blacklist)) {}
27
28 bool isBlacklisted(std::string const &propertyName) {
29 return std::find(m_blacklist.cbegin(), m_blacklist.cend(), propertyName) != m_blacklist.cend();
30 }
31
32 std::vector<Hint> createHints() override {
33 std::vector<Hint> hints;
34 auto properties = m_algorithm->getProperties();
35 properties.erase(
36 std::remove_if(properties.begin(), properties.end(),
37 [this](Mantid::Kernel::Property *property) -> bool { return isBlacklisted(property->name()); }),
38 properties.end());
39 hints.reserve(properties.size());
40 std::transform(
41 properties.cbegin(), properties.cend(), std::back_inserter(hints),
42 [](Mantid::Kernel::Property *property) -> Hint { return Hint(property->name(), property->documentation()); });
43
44 return hints;
45 }
46
47private:
49 std::vector<std::string> m_blacklist;
50};
51} // namespace MantidWidgets
52} // namespace MantidQt
AlgorithmHintStrategy : Produces hints using a given algorithm's properties.
AlgorithmHintStrategy(std::string const &algorithmName, std::vector< std::string > blacklist)
AlgorithmHintStrategy(Mantid::API::IAlgorithm_sptr algorithm, std::vector< std::string > blacklist)
bool isBlacklisted(std::string const &propertyName)
std::vector< Hint > createHints() override
Create a list of hints for auto completion.
HintStrategy : Provides an interface for generating hints to be used by a HintingLineEdit.
Definition: HintStrategy.h:19
Base class for properties.
Definition: Property.h:94
Manage the lifetime of a class intended to be a singleton.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.