Mantid
Loading...
Searching...
No Matches
PropertyManagerFactory.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/extract.hpp>
12#include <memory>
13
14using boost::python::extract;
15using boost::python::handle;
16using boost::python::object;
17
18namespace Mantid {
19using Kernel::Direction;
20using Kernel::PropertyManager;
21
22namespace PythonInterface::Registry {
23
28std::shared_ptr<Kernel::PropertyManager> createPropertyManager(const boost::python::dict &mapping) {
29 auto pmgr = std::make_shared<PropertyManager>();
30 object view(mapping.attr("items")());
31 object itemIter(handle<>(PyObject_GetIter(view.ptr())));
32 auto length = len(mapping);
33 for (ssize_t i = 0; i < length; ++i) {
34 const object keyValue(handle<>(PyIter_Next(itemIter.ptr())));
35 const std::string cppkey = extract<std::string>(keyValue[0])();
36 pmgr->declareProperty(PropertyWithValueFactory::create(cppkey, keyValue[1], Direction::Input));
37 }
38 return pmgr;
39}
40} // namespace PythonInterface::Registry
41} // namespace Mantid
static std::unique_ptr< Kernel::Property > create(const std::string &name, const boost::python::object &defaultValue, const boost::python::object &validator, const unsigned int direction)
Creates a PropertyWithValue<Type> instance from the given information.
MANTID_KERNEL_DLL PropertyManager_sptr createPropertyManager(const Json::Value &keyValues)
Attempt to create a PropertyManager from the Json::Value.
Helper class which provides the Collimation Length for SANS instruments.
@ Input
An input workspace.
Definition: Property.h:53