Mantid
Loading...
Searching...
No Matches
DataItem.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
11#include <boost/python/bases.hpp>
12#include <boost/python/class.hpp>
13#include <boost/python/copy_const_reference.hpp>
14#include <boost/python/register_ptr_to_python.hpp>
15#include <boost/python/return_value_policy.hpp>
16
18using namespace Mantid::PythonInterface;
19using namespace boost::python;
20
21namespace {
22void readLock(DataItem &self) {
24 self.readLock();
25}
26void unlock(DataItem &self) {
28 self.unlock();
29}
30} // namespace
31
33
35 register_ptr_to_python<std::shared_ptr<DataItem>>();
36
37 class_<DataItem, boost::noncopyable>("DataItem", no_init)
38 .def("id", &DataItem::id, arg("self"), "The string ID of the class")
39 .def("name", &DataItem::getName, arg("self"), "The name of the object",
40 return_value_policy<copy_const_reference>())
41 .def("threadSafe", &DataItem::threadSafe, arg("self"),
42 "Returns true if the object "
43 "can be accessed safely from "
44 "multiple threads")
45 .def("readLock", &readLock, arg("self"), "Acquires a read lock on the data item.")
46 .def("unlock", &unlock, arg("self"), "Unlocks a read or write lock on the data item.")
47 .def("__str__", &DataItem::getName, arg("self"), "Returns the string name of the object if it has been stored",
48 return_value_policy<copy_const_reference>())
49 .def("__repr__", &DataItem::toString, arg("self"), "Returns a description of the object");
50}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_DataItem()
Definition: DataItem.cpp:34
This class forms the base class of any item that wishes to be stored in the analysis data service.
Definition: DataItem.h:39
virtual const std::string & getName() const =0
The name of the object.
void readLock()
Acquires a read lock.
Definition: DataItem.cpp:30
virtual const std::string toString() const =0
Serializes the object to a string.
virtual const std::string id() const =0
A string ID for the class.
virtual bool threadSafe() const =0
Can this object be accessed from multiple threads safely.
Defines a structure for releasing the Python GIL using the RAII pattern.