12#include <boost/python/class.hpp>
13#include <boost/python/import.hpp>
14#include <boost/python/reference_existing_object.hpp>
15#include <boost/python/return_value_policy.hpp>
27std::once_flag INIT_FLAG;
28bool INSTANCE_CALLED =
false;
29constexpr auto PYTHONPATHS_KEY =
"pythonscripts.directories";
43void updatePythonPaths() {
44 auto packagesetup =
import(
"mantid.kernel.packagesetup");
45 packagesetup.attr(
"update_sys_paths")(
46 ConfigService::Instance().getValue<std::string>(PYTHONPATHS_KEY).get_value_or(
""));
63 auto &frameworkMgr = FrameworkManager::Instance();
64 std::call_once(INIT_FLAG, []() {
65 INSTANCE_CALLED =
true;
66 declareCPPAlgorithms();
68 import(
"mantid.simpleapi");
73 PyRun_SimpleString(
"import atexit\n"
74 "from mantid.api import FrameworkManager\n"
75 "atexit.register(lambda: FrameworkManager.shutdown())");
83bool hasInstance() {
return INSTANCE_CALLED; }
87 class_<FrameworkManagerImpl, boost::noncopyable>(
"FrameworkManagerImpl", no_init)
89 "Sets the number of OpenMP threads to the value "
94 "Set the number of OpenMP threads to the given value")
97 "Returns the number of OpenMP threads that will be used.")
102 "Clear memory held by algorithms (does not include workspaces)")
105 "Clear memory held by the data service (essentially all "
110 "Clear memory held by the cached instruments")
113 "Clear memory held by the PropertyManagerDataService")
117 .def(
"hasInstance", hasInstance,
"Returns True if Instance has been called, false otherwise")
118 .staticmethod(
"hasInstance")
120 .def(
"Instance", instance,
"Return a reference to the singleton instance",
121 return_value_policy<reference_existing_object>())
122 .staticmethod(
"Instance");
void export_FrameworkManager()
The main public API via which users interact with the Mantid framework.
void clearPropertyManagers()
Clear memory associated with the PropertyManagers.
void setNumOMPThreads(const int nthreads)
Set the number of OpenMP threads to the given value.
void clearInstruments()
Clear memory associated with the IDS.
void clearData()
Clear memory associated with the ADS.
void shutdown()
shuts down and performs clean up tasks
int getNumOMPThreads() const
Returns the number of OpenMP threads that will be used.
void setNumOMPThreadsToConfigValue()
Set the number of OpenMP threads to use based on the config value.
void clear()
Clears all memory associated with the AlgorithmManager, ADS & IDS.
void clearAlgorithms()
Clear memory associated with the AlgorithmManager.
Manage the lifetime of a class intended to be a singleton.