15#include <boost/python/enum.hpp>
17#include <boost/python/list.hpp>
18#include <boost/python/overloads.hpp>
19#include <boost/python/return_value_policy.hpp>
29std::once_flag INIT_FLAG;
40 std::call_once(INIT_FLAG, []() {
41 PyRun_SimpleString(
"import atexit\n"
42 "from mantid.api import AnalysisDataService\n"
43 "atexit.register(lambda: AnalysisDataService.clear())");
55list retrieveWorkspaces(
AnalysisDataServiceImpl const *
const self,
const list &names,
bool unrollGroups =
false) {
56 using WeakPtr = std::weak_ptr<Workspace>;
57 const auto wsSharedPtrs =
59 std::vector<WeakPtr> wsWeakPtrs;
60 wsWeakPtrs.reserve(wsSharedPtrs.size());
61 std::transform(wsSharedPtrs.cbegin(), wsSharedPtrs.cend(), std::back_inserter(wsWeakPtrs),
62 [](
const Workspace_sptr &wksp) -> WeakPtr { return WeakPtr(wksp); });
70BOOST_PYTHON_FUNCTION_OVERLOADS(AdsRetrieveWorkspacesOverloads, retrieveWorkspaces, 2, 3)
77 auto pythonClass = ADSExporter::define(
"AnalysisDataServiceImpl");
79 .def(
"Instance", instance, return_value_policy<reference_existing_object>(),
80 "Return a reference to the singleton instance")
81 .staticmethod(
"Instance")
82 .def(
"retrieveWorkspaces", retrieveWorkspaces,
83 AdsRetrieveWorkspacesOverloads(
"Retrieve a list of workspaces by name",
84 (arg(
"self"), arg(
"names"), arg(
"unrollGroups") =
false)))
86 "Add a workspace in the ADS to a group in the ADS")
88 "Remove a workspace from a group in the ADS");
#define GET_POINTER_SPECIALIZATION(TYPE)
void export_AnalysisDataService()
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
The Analysis data service stores instances of the Workspace objects and anything that derives from te...
void addToGroup(const std::string &groupName, const std::string &wsName)
Add a workspace to a group.
std::vector< Workspace_sptr > retrieveWorkspaces(const std::vector< std::string > &names, bool unrollGroups=false) const
Given a list of names retrieve the corresponding workspace handles.
void removeFromGroup(const std::string &groupName, const std::string &wsName)
Remove a workspace from a group but not from the ADS.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...
Converter that takes a std::vector and converts it into a python list.
A helper struct to export templated DataService<> types to Python.