#ifndef IProperty_h__ #define IProperty_h__ #include "LString.h" #include "delegate/Delegate.h" #include #include "Error.h" #include "ISerializable.h" namespace LifeCore { enum PropertyEditMode { EM_INPLACE = 0, EM_DROPDOWN = 1, EM_CUSTOM = 2, }; struct Attribute { public: String Name; String Value; }; class IProperty : public ISerializable { public: EVENT0(PropertyEvent); PropertyEvent Event_ValueChanged; int AddAttribute(const String& name, const String& value); int GetAttribute(const String& name, String& value); virtual String ToString() { return STR("Unspecified"); }; virtual void FromString(const String& str) { UNREFERENCED_PARAMETER(str); } bool ContainsAttribute(const String& name); template void Set(const T* src){ Set(static_cast(src), sizeof(T)); } template void Set(const T& src){ Set(static_cast(&src), sizeof(T)); } template const T& Get(){ return *static_cast(GetPtr()); } private: typedef std::map AttributeList; typedef std::map::iterator AttributeListItr; AttributeList attributes; protected: virtual void Set(const void* src, size_t size) = 0; virtual const void* GetPtr() = 0; void OnValueChanged(){ Event_ValueChanged.Invoke(); } }; } #endif // IProperty_h__