17 #include <type_traits> 24 template <
typename ValueType>
27 return this->
getEnvironment()->convertProxyToObject(*this).convert<ValueType>();
37 typename std::enable_if<!std::is_same<T, Proxy>::value, T>::type
38 convertProxy(
const Proxy &p)
44 typename std::enable_if<std::is_same<T, Proxy>::value, T>::type
45 convertProxy(
const Proxy &p)
55 typename std::enable_if<!std::is_same<typename std::decay<T>::type,
Proxy>::value,
Proxy>::type
58 return env->makeProxy(std::forward<T>(value));
62 typename std::enable_if<std::is_same<typename std::decay<T>::type,
Proxy>::value,
Proxy>::type
70 template <
typename ReturnType,
typename... ArgsType>
71 ReturnType
Proxy::call(
const std::string &name, ArgsType&&... args)
const 73 Proxy ret = this->
callProxy(name, std::forward<ArgsType>(args)...);
74 return Detail::convertProxy<ReturnType>(ret);
77 template <
typename... ArgsType>
80 const std::array<
Proxy,
sizeof...(ArgsType)> proxyArgs{{Detail::makeProxy(this->
getEnvironment(), std::forward<ArgsType>(args))...}};
83 return handle->call(name, proxyArgs.data(),
sizeof...(args));
86 template <
typename... ArgsType>
89 this->
callProxy(name, std::forward<ArgsType>(args)...);
92 template <
typename ReturnType>
95 return this->call<ReturnType>(
"get:"+name);
98 template <
typename ValueType>
99 void Proxy::set(
const std::string &name, ValueType&& value)
const 101 this->
callVoid(
"set:"+name, std::forward<ValueType>(value));
104 template <
typename... ArgsType>
107 return this->
callProxy(
"()", std::forward<ArgsType>(args)...);
void set(const std::string &name, ValueType &&value) const
Call a field setter.
Definition: ProxyImpl.hpp:99
void callVoid(const std::string &name, ArgsType &&...args) const
Call a method with a void return and variable args.
Definition: ProxyImpl.hpp:87
Definition: Testing.hpp:134
std::shared_ptr< ProxyEnvironment > Sptr
Definition: Environment.hpp:46
Proxy callProxy(const std::string &name, ArgsType &&...args) const
Call a method with a Proxy return and variable args.
Definition: ProxyImpl.hpp:78
std::shared_ptr< ProxyEnvironment > getEnvironment(void) const
ReturnType call(const std::string &name, ArgsType &&...args) const
Call a method with a return type and variable args.
Definition: ProxyImpl.hpp:71
std::shared_ptr< ProxyHandle > getHandle(void) const
Get the handle held in this proxy object.
ReturnType get(const std::string &name) const
Call a field getter with specified return type.
Definition: ProxyImpl.hpp:93
ValueType convert(void) const
Definition: ProxyImpl.hpp:25
Proxy operator()(ArgsType &&...args) const
Call the function operator() with a Proxy return and variable args.
Definition: ProxyImpl.hpp:105