Mantid
Loading...
Searching...
No Matches
Workspace.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10
13
14#include <boost/python/class.hpp>
15#include <boost/python/copy_const_reference.hpp>
16#include <boost/python/overloads.hpp>
17
18using namespace Mantid::API;
19using namespace Mantid::Kernel;
20using namespace Mantid::PythonInterface;
22using namespace boost::python;
23
25
26namespace {
28GNU_DIAG_OFF("unused-local-typedef")
29// Ignore -Wconversion warnings coming from boost::python
30// Seen with GCC 7.1.1 and Boost 1.63.0
31GNU_DIAG_OFF("conversion")
32BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Workspace_isDirtyOverloads, Workspace::isDirty, 0, 1)
33GNU_DIAG_ON("conversion")
34GNU_DIAG_ON("unused-local-typedef")
35
37} // namespace
38
44std::string getName(const Workspace &self) {
45 PyErr_Warn(PyExc_DeprecationWarning, ".getName() is deprecated. Use .name() instead.");
46 return self.getName();
47}
48
50 class_<Workspace, bases<DataItem>, boost::noncopyable>("Workspace", no_init)
51 .def("getName", &getName, arg("self"), "Returns the name of the workspace. This could be an empty string")
52 .def("getTitle", &Workspace::getTitle, arg("self"), "Returns the title of the workspace")
53 .def("isGroup", &Workspace::isGroup, arg("self"), "Returns if it is a group workspace")
54 .def("setTitle", &Workspace::setTitle, (arg("self"), arg("title")), "Set the title of the workspace")
55 .def("getComment", &Workspace::getComment, arg("self"), return_value_policy<copy_const_reference>(),
56 "Returns the comment field on the workspace")
57 .def("setComment", &Workspace::setComment, (arg("self"), arg("comment")),
58 "Set the comment field of the workspace")
59 .def("isDirty", &Workspace::isDirty,
60 Workspace_isDirtyOverloads((arg("self"), arg("n")), "True if the workspace has run "
61 "more than n algorithms "
62 "(Default=1)"))
63 .def("getMemorySize", &Workspace::getMemorySize, arg("self"),
64 "Returns the memory footprint of the workspace in KB")
65 .def("getHistory", (const WorkspaceHistory &(Workspace::*)() const) & Workspace::getHistory, arg("self"),
66 return_value_policy<reference_existing_object>(),
67 "Return read-only access to the "
68 ":class:`~mantid.api.WorkspaceHistory`");
69
70 // register pointers
72}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_Workspace()
Definition: Workspace.cpp:49
std::string getName(const Workspace &self)
DEPRECATED.
Definition: Workspace.cpp:44
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
Definition: Property.cpp:102
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
This class stores information about the Workspace History used by algorithms on a workspace and the e...
Base Workspace Abstract Class.
Definition: Workspace.h:30
const WorkspaceHistory & getHistory() const
Returns a reference to the WorkspaceHistory const.
Definition: Workspace.h:84
virtual void setTitle(const std::string &)
Set the title of the workspace.
Definition: Workspace.cpp:28
const std::string & getComment() const
Get the workspace comment.
Definition: Workspace.cpp:52
virtual size_t getMemorySize() const =0
Get the footprint in memory in bytes.
virtual bool isGroup() const
Definition: Workspace.h:75
bool isDirty(const int n=1) const
Check whether other algorithms have been applied to the workspace by checking the history length.
Definition: Workspace.cpp:71
virtual const std::string getTitle() const
Get the workspace title.
Definition: Workspace.cpp:46
void setComment(const std::string &)
Set the comment field of the workspace.
Definition: Workspace.cpp:34
STL namespace.
Encapsulates the registration required for an interface type T that sits on top of a Kernel::DataItem...