19#ifndef SCRIPT_INTERFACE_AUTO_PARAMETERS_AUTO_PARAMETER_HPP
20#define SCRIPT_INTERFACE_AUTO_PARAMETERS_AUTO_PARAMETER_HPP
51 template <
typename T,
class O>
53 void (O::*setter)(T const &), T const &(O::*getter)() const)
55 (obj.get()->*setter)(get_value<T>(v));
57 getter_([&obj, getter]() {
return (obj.get()->*getter)(); }) {}
62 template <
typename T,
class O>
64 void (O::*setter)(T const &), T (O::*getter)() const)
66 (obj.get()->*setter)(get_value<T>(v));
68 getter_([&obj, getter]() {
return (obj.get()->*getter)(); }) {}
76 template <
typename T,
class O>
78 T
const &(O::*getter)())
80 getter_([&obj, getter]() {
return (obj.get()->*getter)(); }) {}
85 template <
typename T,
class O>
87 T (O::*getter)() const)
89 getter_([&obj, getter]() {
return (obj.get()->*getter)(); }) {}
94 template <
typename T,
class O>
97 getter_([&obj, getter]() {
return (obj.get()->*getter)(); }) {}
102 template <
typename T,
class O>
104 T &(O::*getter_setter)())
106 (obj.get()->*getter_setter)() = get_value<T>(v);
108 getter_([&obj, getter_setter]() {
109 return (obj.get()->*getter_setter)();
117 template <
typename T>
120 setter_([&binding](
Variant const &v) { binding = get_value<T>(v); }),
126 template <
typename T>
141 template <
typename Setter,
typename Getter>
149 template <
typename Getter>
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
Description and getter/setter for a parameter.
const std::string name
The interface name.
AutoParameter(const char *name, ReadOnly, Getter const &get)
Read-only parameter with a user-provided getter.
AutoParameter(const char *name, std::shared_ptr< O > &obj, T const &(O::*getter)())
Read-only parameter that is bound to an object.
AutoParameter(const char *name, std::shared_ptr< O > &obj, T(O::*getter)() const)
Read-only parameter that is bound to an object.
AutoParameter(const char *name, std::shared_ptr< O > &obj, T O::*getter)
Read-only parameter that is bound to an object.
const std::function< void(Variant const &)> setter_
Set the parameter.
void set(Variant const &v) const
AutoParameter(const char *name, T &binding)
Read-write parameter that is bound to an object.
AutoParameter(const char *name, std::shared_ptr< O > &obj, void(O::*setter)(T const &), T const &(O::*getter)() const)
Read-write parameter that is bound to an object.
AutoParameter(const char *name, std::shared_ptr< O > &obj, T &(O::*getter_setter)())
Read-write parameter that is bound to an object.
AutoParameter(const char *name, Setter const &set, Getter const &get)
Read-write parameter with a user-provided getter and setter.
const std::function< Variant()> getter_
Get the parameter.
static constexpr const ReadOnly read_only
AutoParameter(const char *name, std::shared_ptr< O > &obj, void(O::*setter)(T const &), T(O::*getter)() const)
Read-write parameter that is bound to an object.
AutoParameter(const char *name, T const &binding)
Read-only parameter that is bound to an object.