15#include <boost/python/class.hpp>
16#include <boost/python/copy_non_const_reference.hpp>
17#include <boost/python/iterator.hpp>
18#include <boost/python/make_constructor.hpp>
19#include <boost/python/return_value_policy.hpp>
28 if (Mantid ::API::AnalysisDataService::Instance().doesExist(ws->getName())) {
30 using PtrT = std::weak_ptr<Workspace>;
32 return boost::python::to_python_value<PtrT>()(weak_ptr);
34 return boost::python::to_python_value<Workspace_sptr>()(ws);
82 if (
static_cast<size_t>(-
index) > self.
size())
90 class_<WorkspaceGroup, bases<Workspace>, boost::noncopyable>(
"WorkspaceGroup", no_init)
93 "Returns the number of entries in the group")
96 (arg(
"self"), arg(
"workspace")),
"Returns true if the given name is in the group")
98 .def(
"add",
addItem, (arg(
"self"), arg(
"workspace_name")),
"Add a name to the group")
99 .def(
"addWorkspace",
addWorkspace, (arg(
"self"), arg(
"workspace")),
"Add a workspace to the group.")
100 .def(
"size", &
WorkspaceGroup::size, arg(
"self"),
"Returns the number of workspaces contained in the group")
101 .def(
"remove",
removeItem, (arg(
"self"), arg(
"workspace_name")),
"Remove a name from the group")
102 .def(
"getItem",
getItem, (arg(
"self"), arg(
"index")),
"Returns the item at the given index")
104 "Returns true if the workspace group is multi-period")
107 "Gets the number of entries in the workspace group")
109 (arg(
"self"), arg(
"workspace name")),
"Does this group contain the named workspace?")
110 .def(
"__getitem__",
getItem, (arg(
"self"), arg(
"index")))
111 .def(
"__iter__", range<return_value_policy<copy_non_const_reference>>(&
group_begin, &
group_end));
#define GET_POINTER_SPECIALIZATION(TYPE)
std::map< DeltaEMode::Type, std::string > index
Workspace_sptr makeWorkspaceGroup()
Constructor function for WorkspaceGroup.
PyObject * getItem(WorkspaceGroup &self, const int &index)
void removeItem(WorkspaceGroup &self, const std::string &name)
void export_WorkspaceGroup()
void addItem(WorkspaceGroup &self, const std::string &name)
std::vector< Workspace_sptr >::iterator group_begin(WorkspaceGroup &self)
Returns an iterator pointing to the first element in the group.
std::vector< Workspace_sptr >::iterator group_end(WorkspaceGroup &self)
Returns an iterator pointing to the past-the-end element in the group.
void addWorkspace(WorkspaceGroup &self, const boost::python::object &pyobj)
Class to hold a set of workspaces.
void addWorkspace(const Workspace_sptr &workspace)
Adds a workspace to the group.
void remove(const std::string &wsName)
Remove a name from the group.
std::vector< Workspace_sptr >::iterator end()
Returns a non-const iterator pointing at the last element in the workspace group.
int getNumberOfEntries() const
Return the number of entries within the group.
bool contains(const std::string &wsName) const
Does a workspace exist within the group.
Workspace_sptr getItem(const size_t index) const
Return the ith workspace.
void sortByName()
Invokes the ADS to sort group members by workspace name.
std::vector< std::string > getNames() const
Returns the names of workspaces that make up this group.
void add(const std::string &wsName)
Adds a workspace to the group.
void throwIndexOutOfRangeError(int index) const
Throws an out_of_range error for an invalid index.
bool isMultiperiod() const
Inidicates that the workspace group can be treated as multiperiod.
size_t size() const
Return the size of the group, so it is more like a container.
Defines a structure for releasing the Python GIL using the RAII pattern.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
A helper struct to export templated DataService<> types to Python.
Encapsulates the registration required for an interface type T that sits on top of a Kernel::DataItem...