15#include <boost/python/class.hpp>
16#include <boost/python/copy_const_reference.hpp>
17#include <boost/python/dict.hpp>
18#include <boost/python/iterator.hpp>
19#include <boost/python/list.hpp>
20#include <boost/python/register_ptr_to_python.hpp>
21#include <boost/python/return_internal_reference.hpp>
22#include <boost/python/stl_iterator.hpp>
23#include <boost/python/str.hpp>
43 if (valuecpp.check()) {
48 const auto &entry = Registry::TypeRegistry::retrieve(*(p->
type_info()));
50 }
catch (std::invalid_argument &e) {
51 throw std::invalid_argument(
"When converting parameter \"" +
name +
"\": " + e.what());
56void setProperties(
IPropertyManager &self,
const boost::python::dict &kwargs) {
57 const object view = kwargs.attr(
"items")();
58 const object objectItems(handle<>(PyObject_GetIter(view.ptr())));
59 auto begin = stl_input_iterator<object>(objectItems);
60 auto end = stl_input_iterator<object>();
61 for (
auto it = begin; it != end; ++it) {
74 auto p = std::unique_ptr<Property>(Registry::PropertyWithValueFactory::create(
name,
value, 0));
105 const boost::python::object &defaultValue,
const boost::python::object &validator,
106 const std::string &doc,
const int direction) {
108 std::unique_ptr<Property>(Registry::PropertyWithValueFactory::create(
name, defaultValue, validator, direction));
120void setPropertySettings(
IPropertyManager &self,
const std::string &propName,
134 const size_t numProps = props.size();
136 boost::python::list result;
137 for (
size_t i = 0; i < numProps; ++i) {
138 result.append(props[i]->
name());
160 return Registry::PropertyWithValueFactory::create(
name,
value, 0).release();
166 register_ptr_to_python<IPropertyManager *>();
168 class_<IPropertyManager, boost::noncopyable>(
"IPropertyManager", no_init)
170 "Returns the number of properties being managed")
173 return_internal_reference<>(),
174 "Returns the property of the given name. Use .value to give the "
178 "Returns a string representation of the named property's value")
181 "Returns the list of properties managed by this object")
183 .def(
"declareProperty", &declareProperty, (arg(
"self"), arg(
"name"), arg(
"value")),
"Create a new named property")
185 .def(
"declareOrReplaceProperty", &declareOrReplaceProperty,
186 (arg(
"self"), arg(
"name"), arg(
"defaultValue"), arg(
"validator") =
object(), arg(
"doc") =
"",
188 "Declares or replaces a named property where the type is taken from "
189 "the type of the defaultValue and mapped to an appropriate C++ "
193 "Set the value of the named property via a string")
195 .def(
"setProperty", &setProperty, (arg(
"self"), arg(
"name"), arg(
"value")),
"Set the value of the named property")
196 .def(
"setProperties", &setProperties, (arg(
"self"), arg(
"kwargs")),
"Set a collection of properties from a dict")
198 .def(
"setPropertySettings", &setPropertySettings, (arg(
"self"), arg(
"name"), arg(
"settingsManager")),
199 "Assign the given IPropertySettings object to the named property")
202 "Set the group for a given property")
205 "Returns whether a property exists")
212 return_value_policy<return_by_value>(),
213 "Returns the property of the given name. Use .value to give the "
215 .def(
"__setitem__", &declareOrSetProperty, (arg(
"self"), arg(
"name"), arg(
"value")),
216 "Set the value of the named property or create it if it doesn't "
218 .def(
"__delitem__", &deleteProperty, (arg(
"self"), arg(
"name")),
"Delete the named property")
221 "Returns whether a property exists")
225 "Returns whether a property exists")
226 .def(
"keys", &getKeys, arg(
"self"))
228 "Returns the list of properties managed by this object")
229 .def(
"get", &get, (arg(
"self"), arg(
"name"), arg(
"value")), return_value_policy<return_by_value>(),
230 "Returns the property of the given name. Use .value to give the "
231 "value. If property with given name does not exist, returns given "
double value
The value of the point.
#define GET_POINTER_SPECIALIZATION(TYPE)
boost::python::extract< std::string > ExtractStdString
void export_IPropertyManager()
Exception for when an item is not found in a collection.
Interface to PropertyManager.
virtual void setPropertyValue(const std::string &name, const std::string &value)=0
Sets property value from a string.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
virtual bool existsProperty(const std::string &name) const =0
Checks whether the named property is already in the list of managed property.
virtual void removeProperty(const std::string &name, const bool delproperty=true)=0
Removes the property from management.
virtual void declareProperty(std::unique_ptr< Property > p, const std::string &doc="")=0
Function to declare properties (i.e. store them)
virtual void declareOrReplaceProperty(std::unique_ptr< Property > p, const std::string &doc="")=0
Function to declare properties (i.e. store them)
virtual Property * getPointerToProperty(const std::string &name) const =0
Get a pointer to property by name.
virtual TypedValue getProperty(const std::string &name) const =0
Get the value of a property.
virtual std::string getPropertyValue(const std::string &name) const =0
Get the value of a property as a string.
virtual size_t propertyCount() const =0
Returns the number of properties under management.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
virtual const std::vector< Property * > & getProperties() const =0
Get the list of managed properties.
Interface for modifiers to Property's that specify if they should be enabled or visible in a GUI.
virtual IPropertySettings * clone() const =0
Make a copy of the present type of IPropertySettings.
Base class for properties.
const std::type_info * type_info() const
Get the property type_info.
@ Input
An input workspace.