Mantid
Loading...
Searching...
No Matches
AlgorithmManager.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidAPI/DllConfig.h"
15#include <Poco/NotificationCenter.h>
16
17#include <deque>
18#include <mutex>
19#include <string>
20#include <utility>
21
22namespace Mantid {
23namespace API {
24
25//----------------------------------------------------------------------------
27class AlgorithmStartingNotification : public Poco::Notification {
28public:
29 AlgorithmStartingNotification(IAlgorithm_sptr alg) : Poco::Notification(), m_alg(std::move(alg)) {}
32
33private:
35};
36
37//----------------------------------------------------------------------------
41class MANTID_API_DLL AlgorithmManagerImpl {
42public:
44 IAlgorithm_sptr create(const std::string &algName, const int &version = -1);
46 std::shared_ptr<Algorithm> createUnmanaged(const std::string &algName, const int &version = -1) const;
47
48 std::size_t size() const;
49
50 IAlgorithm_sptr getAlgorithm(AlgorithmID id) const;
51 void removeById(AlgorithmID id);
52
53 std::vector<IAlgorithm_const_sptr> runningInstances() const;
54 std::vector<IAlgorithm_const_sptr> runningInstancesOf(const std::string &algorithmName) const;
55
59 Poco::NotificationCenter notificationCenter;
60 void notifyAlgorithmStarting(AlgorithmID id);
61
62 void clear();
63 void cancelAll();
64 void shutdown();
65
66private:
68
71
76
78 size_t removeFinishedAlgorithms();
79
81 std::deque<IAlgorithm_sptr> m_managed_algs;
83 mutable std::recursive_mutex m_managedMutex;
84};
85
87
88} // namespace API
89} // Namespace Mantid
90
91namespace Mantid {
92namespace Kernel {
93EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::AlgorithmManagerImpl>;
94}
95} // namespace Mantid
The AlgorithmManagerImpl class is responsible for controlling algorithm instances.
Poco::NotificationCenter notificationCenter
Sends notifications to observers.
std::recursive_mutex m_managedMutex
Mutex for modifying/accessing the m_managed_algs member.
AlgorithmManagerImpl & operator=(const AlgorithmManagerImpl &)
Unimplemented assignment operator.
~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.
AlgorithmManagerImpl(const AlgorithmManagerImpl &)
Unimplemented copy constructor.
Class for when an algorithm is starting asynchronously.
IAlgorithm_sptr getAlgorithm() const
Returns the algorithm that is starting.
Manage the lifetime of a class intended to be a singleton.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
void * AlgorithmID
As we have multiple interfaces to the same logical algorithm we need a way of uniquely identifying ma...
Definition IAlgorithm.h:28
Mantid::Kernel::SingletonHolder< AlgorithmManagerImpl > AlgorithmManager
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
Policy class controlling creation of the singleton Implementation classes should mark their default c...