Mantid
Loading...
Searching...
No Matches
PropertyManagerDataService.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/register_ptr_to_python.hpp>
15#include <memory>
16
17using namespace Mantid::API;
18using namespace Mantid::Kernel;
21using namespace boost::python;
22
24using PropertyManager_wptr = std::weak_ptr<PropertyManager>;
25
26namespace {
34void addFromDict(PropertyManagerDataServiceImpl &self, const std::string &name, const dict &mapping) {
35 self.add(name, createPropertyManager(mapping));
36}
44void addOrReplaceFromDict(PropertyManagerDataServiceImpl &self, const std::string &name, const dict &mapping) {
45 self.addOrReplace(name, createPropertyManager(mapping));
46}
47} // namespace
48
50
52
53 register_ptr_to_python<PropertyManager_wptr>();
54
56 auto pmdType = PMDExporter::define("PropertyManagerDataServiceImpl");
57
58 pmdType
59 .def("Instance", &PropertyManagerDataService::Instance, return_value_policy<reference_existing_object>(),
60 "Return a reference to the singleton instance")
61 .staticmethod("Instance")
62 // adds an overload from a dictionary
63 .def("add", &addFromDict)
64 .def("addOrReplace", &addOrReplaceFromDict);
65}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_PropertyManagerDataService()
std::weak_ptr< PropertyManager > PropertyManager_wptr
Weak pointer to DataItem typedef.
virtual void add(const std::string &name, const std::shared_ptr< T > &Tobject)
Add an object to the service.
Definition: DataService.h:190
virtual void addOrReplace(const std::string &name, const std::shared_ptr< T > &Tobject)
Add or replace an object to the service.
Definition: DataService.h:222
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
MANTID_KERNEL_DLL PropertyManager_sptr createPropertyManager(const Json::Value &keyValues)
Attempt to create a PropertyManager from the Json::Value.
std::shared_ptr< Kernel::PropertyManager > createPropertyManager(const boost::python::dict &mapping)
Create a C++ PropertyMananager from a Python dictionary.
A helper struct to export templated DataService<> types to Python.