12#include <boost/python/class.hpp>
13#include <boost/python/def.hpp>
14#include <boost/python/list.hpp>
15#include <boost/python/overloads.hpp>
24std::once_flag INIT_FLAG;
35 std::call_once(INIT_FLAG, []() {
36 PyRun_SimpleString(
"import atexit\n"
37 "from mantid.api import AlgorithmManager\n"
38 "atexit.register(lambda: AlgorithmManager.clear())");
45 return self->
create(algName, version);
90boost::python::list runningInstancesOf(
AlgorithmManagerImpl const *
const self,
const std::string &algName) {
92 boost::python::list algs;
94 for (
auto &mgrAlg : mgrAlgs) {
108BOOST_PYTHON_FUNCTION_OVERLOADS(create_overloads, create, 2, 3)
117 class_<AlgorithmManagerImpl, boost::noncopyable>(
"AlgorithmManagerImpl", no_init)
118 .def(
"create", &create, create_overloads((arg(
"name"), arg(
"version")),
"Creates a managed algorithm."))
120 createUnmanaged_overloads((arg(
"name"), arg(
"version")),
"Creates an unmanaged algorithm."))
122 .def(
"getAlgorithm", &getAlgorithm, (arg(
"self"), arg(
"id_holder")),
123 "Return the algorithm instance identified by the given id.")
124 .def(
"removeById", &removeById, (arg(
"self"), arg(
"id_holder")),
"Remove an algorithm from the managed list")
125 .def(
"runningInstancesOf", &runningInstancesOf, (arg(
"self"), arg(
"algorithm_name")),
126 "Returns a list of managed algorithm instances that are "
127 "currently executing")
128 .def(
"clear", &clear, arg(
"self"),
"Clears the current list of managed algorithms")
129 .def(
"cancelAll", &cancelAll, arg(
"self"),
"Requests that all currently running algorithms be cancelled")
130 .def(
"Instance", instance, return_value_policy<reference_existing_object>(),
131 "Return a reference to the singleton instance")
132 .staticmethod(
"Instance");
void export_AlgorithmManager()
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
The AlgorithmManagerImpl class is responsible for controlling algorithm instances.
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.
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::vector< IAlgorithm_const_sptr > runningInstancesOf(const std::string &algorithmName) const
Returns all running (& managed) occurances of the named algorithm, oldest first.
void cancelAll()
Requests cancellation of all running algorithms.
void clear()
Clears all managed algorithm objects that are not currently running.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Defines a structure for releasing the Python GIL using the RAII pattern.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
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.
Provides a concrete type to wrap & return AlgorithmIDs that are actually just typedefs for void*.
API::AlgorithmID id
held ID value