29 #ifndef _CEGUITplProperty_h_ 30 #define _CEGUITplProperty_h_ 32 #include "CEGUI/TypedProperty.h" 38 template<
class C,
typename T>
39 class TplProperty :
public TypedProperty<T>
42 typedef PropertyHelper<T> Helper;
44 typedef void (C::*Setter)(
typename Helper::pass_type);
51 template<
typename DT>
struct EnsurePlain {
typedef DT result; };
52 template<
typename DT>
struct EnsurePlain<DT&> {
typedef DT result; };
53 template<
typename DT>
struct EnsurePlain<const DT&> {
typedef DT result; };
55 template<
typename DT>
struct EnsureConstRef {
typedef const DT& result; };
56 template<
typename DT>
struct EnsureConstRef<DT&> {
typedef const DT& result; };
57 template<
typename DT>
struct EnsureConstRef<const DT&> {
typedef const DT& result; };
59 template<
typename DT>
struct EnsureRef {
typedef DT& result; };
60 template<
typename DT>
struct EnsureRef<DT&> {
typedef DT& result; };
61 template<
typename DT>
struct EnsureRef<const DT&> {
typedef DT& result; };
63 typedef typename EnsurePlain<typename Helper::safe_method_return_type>::result (C::*PlainGetter)()
const;
64 typedef typename EnsureConstRef<typename Helper::safe_method_return_type>::result (C::*ConstRefGetter)()
const;
65 typedef typename EnsureRef<typename Helper::safe_method_return_type>::result (C::*RefGetter)()
const;
67 GetterFunctor(PlainGetter getter):
73 GetterFunctor(ConstRefGetter getter):
75 d_constRefGetter(getter)
79 GetterFunctor(RefGetter getter):
90 operator bool(
void)
const 92 return d_plainGetter || d_constRefGetter || d_refGetter;
94 typename Helper::safe_method_return_type operator()(
const C* instance)
const 99 return CEGUI_CALL_MEMBER_FN(*instance, d_plainGetter)();
100 if (d_constRefGetter)
101 return CEGUI_CALL_MEMBER_FN(*instance, d_constRefGetter)();
103 return CEGUI_CALL_MEMBER_FN(*instance, d_refGetter)();
107 return CEGUI_CALL_MEMBER_FN(*instance, d_plainGetter)();
110 PlainGetter d_plainGetter;
111 ConstRefGetter d_constRefGetter;
112 RefGetter d_refGetter;
115 TplProperty(
const String& name,
const String& help,
const String& origin, Setter setter, GetterFunctor getter,
typename Helper::pass_type defaultValue = T(),
bool writesXML =
true):
116 TypedProperty<T>(name, help, origin, defaultValue, writesXML),
122 virtual ~TplProperty()
138 GetterFunctor d_getter;
143 #endif // end of guard _CEGUITplProperty_h_ Main namespace for Crazy Eddie's GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
virtual bool isReadable() const
Returns whether the property is readable.
Definition: debian/tmp/usr/include/cegui-0.8.5/CEGUI/TplProperty.h:126
virtual bool isWritable() const
Returns whether the property is writable.
Definition: debian/tmp/usr/include/cegui-0.8.5/CEGUI/TplProperty.h:131