*
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#ifndef IProperty_h__
|
||||
#define IProperty_h__
|
||||
|
||||
#include "LString.h"
|
||||
#include "delegate/Delegate.h"
|
||||
#include <map>
|
||||
#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<typename T> void Set(const T* src){
|
||||
Set(static_cast<const void*>(src), sizeof(T));
|
||||
}
|
||||
template<typename T> void Set(const T& src){
|
||||
Set(static_cast<const void*>(&src), sizeof(T));
|
||||
}
|
||||
template<typename T> const T& Get(){
|
||||
return *static_cast<const T*>(GetPtr());
|
||||
}
|
||||
private:
|
||||
typedef std::map<String, String> AttributeList;
|
||||
typedef std::map<String, String>::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__
|
||||
Reference in New Issue
Block a user