Mantid
|
A helper struct to export templated DataService<> types to Python. More...
#include <DataServiceExporter.h>
Public Types | |
using | PythonType = boost::python::class_< SvcType, boost::noncopyable > |
using | WeakPtr = std::weak_ptr< typename SvcPtrType::element_type > |
Static Public Member Functions | |
static void | addItem (SvcType &self, const std::string &name, const boost::python::object &item) |
Add an item into the service, if it exists then an error is raised. More... | |
static void | addOrReplaceItem (SvcType &self, const std::string &name, const boost::python::object &item) |
Add or replace an item into the service, if it exists then an error is raised. More... | |
static void | clearItems (SvcType &self) |
Remove an item from the service. More... | |
static PythonType | define (const char *pythonClassName) |
Define the necessary boost.python framework to expor the templated DataService type Note: This does not add the Instance method as that is on the SingletonHolder typedef. More... | |
static SvcPtrType | extractCppValue (const boost::python::object &pyvalue) |
Extract a SvcPtrType C++ value from the Python object. More... | |
static boost::python::list | getObjectNamesAsList (SvcType const *const self, const std::string &contain) |
Return a Python list of object names from the ADS as this is far easier to work with than a set. More... | |
static void | removeItem (SvcType &self, const std::string &name) |
Remove an item from the service. More... | |
static WeakPtr | retrieveOrKeyError (SvcType &self, const std::string &name) |
Retrieves a shared_ptr from the ADS and raises a Python KeyError if it does not exist. More... | |
A helper struct to export templated DataService<> types to Python.
SvcType | Type of DataService to export |
SvcHeldType | The type held within the DataService map |
Definition at line 29 of file DataServiceExporter.h.
using Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::PythonType = boost::python::class_<SvcType, boost::noncopyable> |
Definition at line 31 of file DataServiceExporter.h.
using Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::WeakPtr = std::weak_ptr<typename SvcPtrType::element_type> |
Definition at line 32 of file DataServiceExporter.h.
|
inlinestatic |
Add an item into the service, if it exists then an error is raised.
self | A reference to the calling object |
name | The name to assign to this in the service |
item | A boost.python wrapped SvcHeldType object |
Definition at line 88 of file DataServiceExporter.h.
References Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::extractCppValue().
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().
|
inlinestatic |
Add or replace an item into the service, if it exists then an error is raised.
self | A reference to the calling object |
name | The name to assign to this in the service |
item | A boost.python wrapped SvcHeldType object |
Definition at line 100 of file DataServiceExporter.h.
References Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::extractCppValue().
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().
|
inlinestatic |
Remove an item from the service.
self | A reference to the calling object |
Definition at line 119 of file DataServiceExporter.h.
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().
|
inlinestatic |
Define the necessary boost.python framework to expor the templated DataService type Note: This does not add the Instance method as that is on the SingletonHolder typedef.
To add this call the following methods on the object this function returns .def("Instance", &SingletonType::Instance, return_value_policy<reference_existing_object>(), "Return a reference to the ADS singleton") .staticmethod("Instance") where SingletonType is the typedef of the SingletonHolder, e.g. AnalysisDataService
pythonClassName | The name that the class should have in Python |
Definition at line 49 of file DataServiceExporter.h.
References Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::addItem(), Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::addOrReplaceItem(), Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::clearItems(), Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::getObjectNamesAsList(), Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::removeItem(), and Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::retrieveOrKeyError().
|
inlinestatic |
Extract a SvcPtrType C++ value from the Python object.
pyvalue | Value of the |
Definition at line 129 of file DataServiceExporter.h.
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::addItem(), and Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::addOrReplaceItem().
|
inlinestatic |
Return a Python list of object names from the ADS as this is far easier to work with than a set.
self | :: A reference to the ADS object that called this method |
contain | :: If provided, the function will return only names that contain this string |
Definition at line 176 of file DataServiceExporter.h.
References Mantid::Kernel::Auto, and Mantid::Kernel::Unsorted.
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().
|
inlinestatic |
Remove an item from the service.
self | A reference to the calling object |
name | The name of the item in the service to remove |
Definition at line 110 of file DataServiceExporter.h.
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().
|
inlinestatic |
Retrieves a shared_ptr from the ADS and raises a Python KeyError if it does not exist.
self | :: A pointer to the object calling this function. Allows it to act as a member function |
name | :: The name of the object to retrieve |
Definition at line 153 of file DataServiceExporter.h.
Referenced by Mantid::PythonInterface::DataServiceExporter< SvcType, SvcPtrType >::define().