21 #ifndef CAELUM__TYPE_DESCRIPTOR_H 22 #define CAELUM__TYPE_DESCRIPTOR_H 26 #if CAELUM_TYPE_DESCRIPTORS 32 class ValuePropertyDescriptor;
53 typedef std::map<String, const ValuePropertyDescriptor*> PropertyMap;
64 virtual const std::vector<String> getPropertyNames ()
const = 0;
69 virtual const PropertyMap getFullPropertyMap ()
const = 0;
94 virtual bool canGetValue ()
const = 0;
97 virtual bool canSetValue ()
const = 0;
104 virtual const Ogre::Any getValue (
const void* target)
const = 0;
111 virtual void setValue (
void* target,
const Ogre::Any& value)
const = 0;
114 virtual const std::type_info& getValueTypeId ()
const = 0;
129 template<
typename ValueT>
134 virtual const ValueT getValueTyped (
const void* target)
const = 0;
136 virtual void setValueTyped (
void* target,
const ValueT& value)
const = 0;
139 virtual const Ogre::Any getValue (
const void* target)
const {
140 return Ogre::Any(this->getValueTyped (target));
143 virtual void setValue (
void* target,
const Ogre::Any& value)
const {
144 this->setValueTyped (target, Ogre::any_cast<ValueT>(value));
147 virtual const std::type_info& getValueTypeId ()
const {
148 return typeid(ValueT);
151 virtual bool implementsTypedValuePropertyDescriptor ()
const {
158 template <
class TargetT,
typename ParamT,
typename InParamT = const ParamT&,
typename OutParamT = const ParamT>
162 typedef void(TargetT::*SetFunc)(InParamT);
163 typedef OutParamT(TargetT::*GetFunc)(void)
const;
177 return mGetFunc != 0;
181 return mSetFunc != 0;
186 const TargetT* typedTarget = reinterpret_cast<const TargetT*>(target);
187 return (typedTarget->*mGetFunc)();
192 TargetT* typedTarget = reinterpret_cast<TargetT*>(target);
193 (typedTarget->*mSetFunc)(value);
233 void deleteAllPropertyDescriptors ();
235 PropertyMap mPropertyMap;
269 #endif // CAELUM_TYPE_DESCRIPTORS 271 #endif // CAELUM__TYPE_DESCRIPTOR_H virtual const std::vector< String > getPropertyNames() const
Get a map of all supported properties.
Basic property descriptor interface.
virtual const PropertyMap getFullPropertyMap() const
Get a map of all supported properties.
virtual bool canSetValue() const
If the value of the property can be set (false means read-only).
Abstract interface for a type descriptor.
Default implementation of a TypeDescriptor.
ValuePropertyDescriptor implementation based on function pointers to get/set methods.
virtual const ParamT getValueTyped(const void *target) const
Get the property's value.
void add(const Ogre::String &name, const ValuePropertyDescriptor *descriptor)
Add a property. Type descriptor takes ownership.
virtual const ValuePropertyDescriptor * getPropertyDescriptor(const Ogre::String &name) const
Get a property descriptor; or null if not available.
Standard type descriptors for caelum components.
virtual bool canGetValue() const
If the value of the property can be read (true means write-only).
virtual void setValueTyped(void *target, const ParamT &value) const
Set the property's value.
PropertyMap & getPropertyMap()
Direct access to the internal property map.
virtual bool implementsTypedValuePropertyDescriptor() const
Check if this class also implements TypedValuePropertyDescriptor.
Variant of ValuePropertyDescriptor which allows faster typed get/set methods.
void clear()
Clear the property map; delete all property descriptors.