18Kernel::Logger
g_log(
"AlgorithmManager");
68 }
catch (std::runtime_error &ex) {
69 g_log.
error() <<
"AlgorithmManager:: Unable to create algorithm " << algName <<
' ' << ex.what() <<
'\n';
70 throw std::runtime_error(
"AlgorithmManager:: Unable to create algorithm " + algName +
' ' + ex.what());
81 if (!(*itAlg)->isRunning()) {
99 [
id](
const auto &algorithm) { return algorithm->getAlgorithmID() == id; });
115 if ((**it).getAlgorithmID() ==
id) {
116 if (!(*it)->isRunning()) {
117 g_log.
debug() <<
"Removing algorithm " << (*it)->name() <<
'\n';
120 g_log.
debug() <<
"Unable to remove algorithm " << (*it)->name() <<
". The algorithm is running.\n";
142 std::vector<IAlgorithm_const_sptr> theRunningInstances;
146 [&algorithmName](
const auto &algorithm) { return algorithm->name() == algorithmName && algorithm->isRunning(); });
147 return theRunningInstances;
153 std::vector<IAlgorithm_const_sptr> theRunningInstances;
156 [](
const auto &algorithm) { return algorithm->isRunning(); });
157 return theRunningInstances;
164 if (managed_alg->isRunning())
165 managed_alg->cancel();
173 std::vector<IAlgorithm_const_sptr> theCompletedInstances;
175 [](
const auto &algorithm) { return (algorithm->isReadyForGarbageCollection()); });
176 for (
auto completedAlg : theCompletedInstances) {
179 if ((**it).getAlgorithmID() == completedAlg->getAlgorithmID()) {
185 return theCompletedInstances.size();
std::shared_ptr< Algorithm > createUnmanaged(const std::string &algName, const int &version=-1) const
Creates an unmanaged algorithm with the option of choosing a version.
Poco::NotificationCenter notificationCenter
Sends notifications to observers.
void notifyAlgorithmStarting(AlgorithmID id)
Called by an algorithm that is executing asynchronously This sends out the notification.
IAlgorithm_sptr getAlgorithm(AlgorithmID id) const
Returns a shared pointer by algorithm id.
void removeById(AlgorithmID id)
Removes the given algorithm from the managed list.
IAlgorithm_sptr create(const std::string &algName, const int &version=-1)
Creates a managed algorithm with the option of choosing a version.
std::mutex m_managedMutex
Mutex for modifying/accessing the m_managed_algs member.
AlgorithmManagerImpl()
Private Constructor for singleton class.
std::vector< IAlgorithm_const_sptr > runningInstances() const
Returns all running (& managed) occurances of any algorithm, oldest first.
std::vector< IAlgorithm_const_sptr > runningInstancesOf(const std::string &algorithmName) const
Returns all running (& managed) occurances of the named algorithm, oldest first.
~AlgorithmManagerImpl()
Private destructor Prevents client from calling 'delete' on the pointer handed out by Instance.
std::deque< IAlgorithm_sptr > m_managed_algs
The list of managed algorithms.
void cancelAll()
Requests cancellation of all running algorithms.
size_t removeFinishedAlgorithms()
Removes any finished algorithms from the list of managed algorithms.
void clear()
Clears all managed algorithm objects that are not currently running.
Class for when an algorithm is starting asynchronously.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
Kernel::Logger g_log("ExperimentInfo")
static logger object
void * AlgorithmID
As we have multiple interfaces to the same logical algorithm we need a way of uniquely identifying ma...
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.