24 #ifndef GAMMARAY_METAPROPERTY_H
25 #define GAMMARAY_METAPROPERTY_H
27 #include "gammaray_core_export.h"
44 virtual QString name()
const = 0;
47 virtual QVariant value(
void *
object)
const = 0;
50 virtual bool isReadOnly()
const = 0;
53 virtual void setValue(
void *
object,
const QVariant &value) = 0;
56 virtual QString typeName()
const = 0;
72 struct strip_const_ref {
typedef T type; };
75 struct strip_const_ref<const T&> {
typedef T type; };
81 template <
typename Class,
typename GetterReturnType,
typename SetterArgType = GetterReturnType>
85 typedef typename detail::strip_const_ref<GetterReturnType>::type ValueType;
90 GetterReturnType (Class::*getter)()
const,
void (Class::*setter)(SetterArgType) = 0)
91 : m_name(name), m_getter(getter), m_setter(setter)
95 inline QString
name()
const
102 return m_setter == 0 ;
105 inline QVariant
value(
void *
object)
const
108 return value(static_cast<Class*>(
object));
113 setValue(static_cast<Class*>(
object), value);
117 inline QVariant
value(Class *
object)
const
120 const ValueType v = (
object->*(m_getter))();
121 return QVariant::fromValue(v);
129 (
object->*(m_setter))(value.value<ValueType>());
132 inline QString typeName()
const
134 return QMetaType::typeName(qMetaTypeId<ValueType>()) ;
139 GetterReturnType (Class::*m_getter)()
const;
140 void (Class::*m_setter)(SetterArgType);