28 #ifndef __RTTR_PROPERTY_CONTAINER_MEMBER_OBJECT_H__
29 #define __RTTR_PROPERTY_CONTAINER_MEMBER_OBJECT_H__
35 template<
typename C,
typename A>
36 class property_container<member_object_ptr, A(C::*), void, return_as_copy, set_value> :
public property_container_base
38 typedef A (C::*accessor);
40 property_container(
const std::string& name,
const type declaring_type, accessor acc)
41 : property_container_base(name, declaring_type), _acc(acc)
45 bool is_readonly()
const {
return false; }
46 bool is_static()
const {
return false; }
47 type get_type()
const {
return type::get<A>(); }
48 bool is_array()
const {
return detail::is_array<A>::value; }
50 bool set_value(detail::instance&
object, detail::argument& arg)
const
52 C* ptr =
object.try_convert<C>();
53 if (ptr && arg.is_type<A>())
54 return property_accessor<A>::set_value((ptr->*_acc), arg);
59 variant get_value(detail::instance&
object)
const
61 if (C* ptr =
object.try_convert<C>())
62 return variant((ptr->*_acc));
76 template<
typename C,
typename A>
77 class property_container<member_object_ptr, A(C::*), void, return_as_copy, read_only> :
public property_container_base
79 typedef A (C::*accessor);
81 property_container(
const std::string& name,
const type declaring_type, accessor acc)
82 : property_container_base(name, declaring_type),
87 bool is_readonly()
const {
return true; }
88 bool is_static()
const {
return false; }
89 type get_type()
const {
return type::get<A>(); }
90 bool is_array()
const {
return detail::is_array<A>::value; }
92 bool set_value(detail::instance&
object, detail::argument& arg)
const
97 variant get_value(detail::instance&
object)
const
99 if (C* ptr =
object.try_convert<C>())
100 return variant((ptr->*_acc));
113 template<
typename C,
typename A>
114 class property_container<member_object_ptr, A(C::*), void, return_as_ptr, set_as_ptr> :
public property_container_base
116 typedef A (C::*accessor);
118 property_container(
const std::string& name,
const type declaring_type, accessor acc)
119 : property_container_base(name, declaring_type), _acc(acc)
121 static_assert(!std::is_pointer<A>::value,
"The given type is already a pointer type!");
124 bool is_readonly()
const {
return false; }
125 bool is_static()
const {
return false; }
126 type get_type()
const {
return type::get<A*>(); }
127 bool is_array()
const {
return detail::is_array<A>::value; }
129 bool set_value(detail::instance&
object, detail::argument& arg)
const
131 C* ptr =
object.try_convert<C>();
132 if (ptr && arg.is_type<A*>())
134 return property_accessor<A*>::set_value(&(ptr->*_acc), arg);
142 variant get_value(detail::instance&
object)
const
144 if (C* ptr =
object.try_convert<C>())
145 return variant(&(ptr->*_acc));
158 template<
typename C,
typename A>
159 class property_container<member_object_ptr, A(C::*), void, return_as_ptr, read_only> :
public property_container_base
161 typedef A (C::*accessor);
163 property_container(
const std::string& name,
const type declaring_type, accessor acc)
164 : property_container_base(name, declaring_type),
167 static_assert(!std::is_pointer<A>::value,
"The given type is already a pointer type!");
170 bool is_readonly()
const {
return true; }
171 bool is_static()
const {
return false; }
172 type get_type()
const {
return type::get<typename std::add_const<A>::type*>(); }
173 bool is_array()
const {
return detail::is_array<A>::value; }
175 bool set_value(detail::instance&
object, detail::argument& arg)
const
180 variant get_value(detail::instance&
object)
const
182 if (C* ptr =
object.try_convert<C>())
183 return variant(const_cast<const A*>(&(ptr->*_acc)));
192 #endif // __RTTR_PROPERTY_CONTAINER_MEMBER_OBJECT_H__