Mantid
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::API::AlgorithmManagerImpl Class Reference

The AlgorithmManagerImpl class is responsible for controlling algorithm instances. More...

#include <AlgorithmManager.h>

Public Member Functions

void cancelAll ()
 Requests cancellation of all running algorithms. More...
 
void clear ()
 Clears all managed algorithm objects that are not currently running. More...
 
IAlgorithm_sptr create (const std::string &algName, const int &version=-1)
 Creates a managed algorithm with the option of choosing a version. More...
 
std::shared_ptr< AlgorithmcreateUnmanaged (const std::string &algName, const int &version=-1) const
 Creates an unmanaged algorithm with the option of choosing a version. More...
 
IAlgorithm_sptr getAlgorithm (AlgorithmID id) const
 Returns a shared pointer by algorithm id. More...
 
void notifyAlgorithmStarting (AlgorithmID id)
 Called by an algorithm that is executing asynchronously This sends out the notification. More...
 
void removeById (AlgorithmID id)
 Removes the given algorithm from the managed list. More...
 
std::vector< IAlgorithm_const_sptrrunningInstances () const
 Returns all running (& managed) occurances of any algorithm, oldest first. More...
 
std::vector< IAlgorithm_const_sptrrunningInstancesOf (const std::string &algorithmName) const
 Returns all running (& managed) occurances of the named algorithm, oldest first. More...
 
void shutdown ()
 
std::size_t size () const
 

Public Attributes

Poco::NotificationCenter notificationCenter
 Sends notifications to observers. More...
 

Private Member Functions

 AlgorithmManagerImpl ()
 Private Constructor for singleton class. More...
 
 AlgorithmManagerImpl (const AlgorithmManagerImpl &)
 Unimplemented copy constructor. More...
 
AlgorithmManagerImploperator= (const AlgorithmManagerImpl &)
 Unimplemented assignment operator. More...
 
size_t removeFinishedAlgorithms ()
 Removes any finished algorithms from the list of managed algorithms. More...
 
 ~AlgorithmManagerImpl ()
 Private destructor Prevents client from calling 'delete' on the pointer handed out by Instance. More...
 

Private Attributes

std::deque< IAlgorithm_sptrm_managed_algs
 The list of managed algorithms. More...
 
std::mutex m_managedMutex
 Mutex for modifying/accessing the m_managed_algs member. More...
 

Friends

struct Mantid::Kernel::CreateUsingNew< AlgorithmManagerImpl >
 

Detailed Description

The AlgorithmManagerImpl class is responsible for controlling algorithm instances.

It incorporates the algorithm factory and initializes algorithms.

Definition at line 41 of file AlgorithmManager.h.

Constructor & Destructor Documentation

◆ AlgorithmManagerImpl() [1/2]

Mantid::API::AlgorithmManagerImpl::AlgorithmManagerImpl ( )
private

Private Constructor for singleton class.

Definition at line 22 of file AlgorithmManager.cpp.

References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.

◆ ~AlgorithmManagerImpl()

Mantid::API::AlgorithmManagerImpl::~AlgorithmManagerImpl ( )
privatedefault

Private destructor Prevents client from calling 'delete' on the pointer handed out by Instance.

◆ AlgorithmManagerImpl() [2/2]

Mantid::API::AlgorithmManagerImpl::AlgorithmManagerImpl ( const AlgorithmManagerImpl )
private

Unimplemented copy constructor.

Member Function Documentation

◆ cancelAll()

void Mantid::API::AlgorithmManagerImpl::cancelAll ( )

Requests cancellation of all running algorithms.

Definition at line 161 of file AlgorithmManager.cpp.

References m_managed_algs, and m_managedMutex.

◆ clear()

void Mantid::API::AlgorithmManagerImpl::clear ( )

Clears all managed algorithm objects that are not currently running.

Definition at line 78 of file AlgorithmManager.cpp.

References m_managed_algs, and m_managedMutex.

Referenced by shutdown().

◆ create()

IAlgorithm_sptr Mantid::API::AlgorithmManagerImpl::create ( const std::string &  algName,
const int &  version = -1 
)

Creates a managed algorithm with the option of choosing a version.

Creates and initialises an instance of an algorithm.

The algorithm gets tracked in the list of "managed" algorithms, which is shown in GUI for cancelling, etc.

Parameters
algName:: The name of the algorithm required
version:: The version of the algorithm required, if not defined most recent version is used -> version =-1
Returns
A pointer to the created algorithm
Exceptions
NotFoundErrorThrown if algorithm requested is not registered
std::runtime_errorThrown if properties string is ill-formed

Definition at line 55 of file AlgorithmManager.cpp.

References count, Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::API::g_log, Mantid::Kernel::SingletonHolder< T >::Instance(), m_managed_algs, m_managedMutex, and removeFinishedAlgorithms().

◆ createUnmanaged()

Algorithm_sptr Mantid::API::AlgorithmManagerImpl::createUnmanaged ( const std::string &  algName,
const int &  version = -1 
) const

Creates an unmanaged algorithm with the option of choosing a version.

Creates an instance of an algorithm, but does not own that instance.

Parameters
algNameThe name of the algorithm required
versionThe version of the algorithm required, if not defined most recent version is used -> version =-1
Returns
A pointer to the created algorithm
Exceptions
NotFoundErrorThrown if algorithm requested is not registered

Definition at line 38 of file AlgorithmManager.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance().

Referenced by export_AlgorithmManager().

◆ getAlgorithm()

IAlgorithm_sptr Mantid::API::AlgorithmManagerImpl::getAlgorithm ( AlgorithmID  id) const

Returns a shared pointer by algorithm id.

Parameters
id:: The ID of the algorithm
Returns
A shared pointer to the algorithm or nullptr if not found

Definition at line 96 of file AlgorithmManager.cpp.

References m_managed_algs, and m_managedMutex.

Referenced by notifyAlgorithmStarting().

◆ notifyAlgorithmStarting()

void Mantid::API::AlgorithmManagerImpl::notifyAlgorithmStarting ( AlgorithmID  id)

Called by an algorithm that is executing asynchronously This sends out the notification.

Parameters
id:: ID of the algorithm being started

Definition at line 132 of file AlgorithmManager.cpp.

References getAlgorithm(), and notificationCenter.

◆ operator=()

AlgorithmManagerImpl & Mantid::API::AlgorithmManagerImpl::operator= ( const AlgorithmManagerImpl )
private

Unimplemented assignment operator.

◆ removeById()

void Mantid::API::AlgorithmManagerImpl::removeById ( AlgorithmID  id)

Removes the given algorithm from the managed list.

Parameters
id:: The ID of the algorithm

Definition at line 111 of file AlgorithmManager.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_managed_algs, and m_managedMutex.

◆ removeFinishedAlgorithms()

size_t Mantid::API::AlgorithmManagerImpl::removeFinishedAlgorithms ( )
private

Removes any finished algorithms from the list of managed algorithms.

Removes all of the finished algorithms this does not lock the mutex as the locking is already assumed to be in place.

Definition at line 172 of file AlgorithmManager.cpp.

References m_managed_algs.

Referenced by create().

◆ runningInstances()

std::vector< IAlgorithm_const_sptr > Mantid::API::AlgorithmManagerImpl::runningInstances ( ) const

Returns all running (& managed) occurances of any algorithm, oldest first.

Definition at line 152 of file AlgorithmManager.cpp.

References m_managed_algs, and m_managedMutex.

◆ runningInstancesOf()

std::vector< IAlgorithm_const_sptr > Mantid::API::AlgorithmManagerImpl::runningInstancesOf ( const std::string &  algorithmName) const

Returns all running (& managed) occurances of the named algorithm, oldest first.

Definition at line 141 of file AlgorithmManager.cpp.

References m_managed_algs, and m_managedMutex.

◆ shutdown()

void Mantid::API::AlgorithmManagerImpl::shutdown ( )

Definition at line 188 of file AlgorithmManager.cpp.

References clear().

◆ size()

std::size_t Mantid::API::AlgorithmManagerImpl::size ( ) const

Definition at line 89 of file AlgorithmManager.cpp.

References m_managed_algs.

Referenced by export_AlgorithmManager().

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< AlgorithmManagerImpl >

Definition at line 64 of file AlgorithmManager.h.

Member Data Documentation

◆ m_managed_algs

std::deque<IAlgorithm_sptr> Mantid::API::AlgorithmManagerImpl::m_managed_algs
private

The list of managed algorithms.

pointers to managed algorithms [policy???]

Definition at line 81 of file AlgorithmManager.h.

Referenced by cancelAll(), clear(), create(), getAlgorithm(), removeById(), removeFinishedAlgorithms(), runningInstances(), runningInstancesOf(), and size().

◆ m_managedMutex

std::mutex Mantid::API::AlgorithmManagerImpl::m_managedMutex
mutableprivate

Mutex for modifying/accessing the m_managed_algs member.

Definition at line 83 of file AlgorithmManager.h.

Referenced by cancelAll(), clear(), create(), getAlgorithm(), removeById(), runningInstances(), and runningInstancesOf().

◆ notificationCenter

Poco::NotificationCenter Mantid::API::AlgorithmManagerImpl::notificationCenter

Sends notifications to observers.

Observers can subscribe to notificationCenter using Poco::NotificationCenter::addObserver(...)

Definition at line 59 of file AlgorithmManager.h.

Referenced by notifyAlgorithmStarting().


The documentation for this class was generated from the following files: