4 #include "AttributeModifier.h"
17 template<s32 notificationLevel,
typename T, CoreModifiable::ATTRIBUTE_TYPE attributeType>
class maNumericHeritage :
public CoreModifiableAttributeData<T>
19 template<s32 notiflevel>
66 virtual bool setValue(
bool value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = value ? std::numeric_limits<T>::max() : 0; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
67 virtual bool setValue(s8 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
68 virtual bool setValue(s16 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
69 virtual bool setValue(s32 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
70 virtual bool setValue(s64 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
71 virtual bool setValue(u8 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
72 virtual bool setValue(u16 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
73 virtual bool setValue(u32 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
74 virtual bool setValue(u64 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
75 virtual bool setValue(kfloat value)
override
81 T tmpValue = (T)value;
82 CALL_SETMODIFIER(notificationLevel, tmpValue);
83 this->mValue = tmpValue;
84 DO_NOTIFICATION(notificationLevel);
87 virtual bool setValue(kdouble value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue; DO_NOTIFICATION(notificationLevel);
return true; }
88 virtual bool setValue(
const char* value)
override { kstl::string localstr(value);
return setValue(localstr); }
89 virtual bool setValue(
const usString& value)
override { kstl::string localstr(value);
return setValue(localstr); }
90 virtual bool setValue(
const kstl::string& value)
override
94 if (CoreConvertString2Value<T>(value, this->mValue))
96 T tmpValue = this->mValue; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mValue = tmpValue;
97 DO_NOTIFICATION(notificationLevel);
return true;
102 virtual bool getValue(
bool& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (tmpValue != (T)0);
return true; }
103 virtual bool getValue(s8& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s8)tmpValue;
return true; }
104 virtual bool getValue(s16& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s16)tmpValue;
return true; }
105 virtual bool getValue(s32& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s32)tmpValue;
return true; }
106 virtual bool getValue(s64& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s64)tmpValue;
return true; }
107 virtual bool getValue(u8& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u8)tmpValue;
return true; }
108 virtual bool getValue(u16& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u16)tmpValue;
return true; }
109 virtual bool getValue(u32& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u32)tmpValue;
return true; }
110 virtual bool getValue(u64& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u64)tmpValue;
return true; }
111 virtual bool getValue(kfloat& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (kfloat)tmpValue;
return true; }
112 virtual bool getValue(kdouble& value)
const override { T tmpValue = this->mValue; CALL_GETMODIFIER(notificationLevel, tmpValue); value = (kdouble)tmpValue;
return true; }
113 virtual bool getValue(kstl::string& value)
const override
115 T tmpValue = this->mValue;
116 CALL_GETMODIFIER(notificationLevel, tmpValue);
117 return CoreConvertValue2String<T>(value, tmpValue);
119 virtual bool getValue(usString& value)
const override
122 T tmpValue = this->mValue;
123 CALL_GETMODIFIER(notificationLevel, tmpValue);
124 if (CoreConvertValue2String<T>(tmp, tmpValue))
126 value = tmp;
return true;
133 template<typename T, CoreModifiable::ATTRIBUTE_TYPE attributeType = TypeToEnum<T>::value>
159 template<s32 notiflevel>
188 typedef T CurrentAttributeType;
189 static constexpr CoreModifiable::ATTRIBUTE_TYPE type = attributeType;
190 CoreModifiable::ATTRIBUTE_TYPE getType()
const override {
return attributeType; }
194 this->CopyData(attribute);
202 void doPlacementNew(u32 level)
override
210 default: assert(
false);
break;
213 virtual void changeInheritance()
final
217 KigsID old_getter = mGetter;
219 KigsID old_setter = mSetter;
221 AttachedModifierBase* modifier = mAttachedModifier;
222 u32 old_flags = mFlags;
223 u32 inheritlevel = (mFlags >> INHERIT_LEVEL_SHIFT)& INHERIT_LEVEL_MOD;
224 doPlacementNew(inheritlevel);
226 mGetter = old_getter;
227 mSetter = old_setter;
230 mAttachedModifier = modifier;
234 virtual operator CurrentAttributeType()
const
236 CurrentAttributeType tmpValue = mOwner->template SimpleCall<T>(mGetter);
238 CALL_GETMODIFIER(notificationLevel, tmpValue);
241 auto& operator=(
const CurrentAttributeType& value)
243 if (mSetter !=
"") mOwner->SimpleCall(mSetter,value);
249 virtual void* getRawValue()
final {
return nullptr; }
258 virtual bool setValue(
bool value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = value ? std::numeric_limits<T>::max() : 0; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
259 virtual bool setValue(s8 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
260 virtual bool setValue(s16 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
261 virtual bool setValue(s32 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
262 virtual bool setValue(s64 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
263 virtual bool setValue(u8 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
264 virtual bool setValue(u16 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
265 virtual bool setValue(u32 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
266 virtual bool setValue(u64 value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue);
if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
267 virtual bool setValue(kfloat value)
override
273 T tmpValue = (T)value;
274 CALL_SETMODIFIER(notificationLevel, tmpValue);
275 if (mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue);
276 DO_NOTIFICATION(notificationLevel);
279 virtual bool setValue(kdouble value)
override {
if (this->
isReadOnly()) {
return false; } T tmpValue = (T)value; CALL_SETMODIFIER(notificationLevel, tmpValue); this->mOwner->SimpleCall(mSetter,tmpValue); DO_NOTIFICATION(notificationLevel);
return true; }
280 virtual bool setValue(
const char* value)
override { kstl::string localstr(value);
return setValue(localstr); }
281 virtual bool setValue(
const usString& value)
override { kstl::string localstr(value);
return setValue(localstr); }
282 virtual bool setValue(
const kstl::string& value)
override
287 if (CoreConvertString2Value<T>(value, tmpValue))
289 CALL_SETMODIFIER(notificationLevel, tmpValue);
if(mSetter !=
"") this->mOwner->SimpleCall(mSetter,tmpValue);
290 DO_NOTIFICATION(notificationLevel);
return true;
295 virtual bool getValue(
bool& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (tmpValue != (T)0);
return true; }
296 virtual bool getValue(s8& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s8)tmpValue;
return true; }
297 virtual bool getValue(s16& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s16)tmpValue;
return true; }
298 virtual bool getValue(s32& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s32)tmpValue;
return true; }
299 virtual bool getValue(s64& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (s64)tmpValue;
return true; }
300 virtual bool getValue(u8& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u8)tmpValue;
return true; }
301 virtual bool getValue(u16& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u16)tmpValue;
return true; }
302 virtual bool getValue(u32& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u32)tmpValue;
return true; }
303 virtual bool getValue(u64& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (u64)tmpValue;
return true; }
304 virtual bool getValue(kfloat& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (kfloat)tmpValue;
return true; }
305 virtual bool getValue(kdouble& value)
const override { T tmpValue = this->mOwner->template SimpleCall<T>(mGetter); CALL_GETMODIFIER(notificationLevel, tmpValue); value = (kdouble)tmpValue;
return true; }
306 virtual bool getValue(kstl::string& value)
const override
308 T tmpValue = this->mOwner->template SimpleCall<T>(mGetter);
309 CALL_GETMODIFIER(notificationLevel, tmpValue);
310 return CoreConvertValue2String<T>(value, tmpValue);
312 virtual bool getValue(usString& value)
const override
315 T tmpValue = this->mOwner->template SimpleCall<T>(mGetter);
316 CALL_GETMODIFIER(notificationLevel, tmpValue);
317 if (CoreConvertValue2String<T>(tmp, tmpValue))
319 value = tmp;
return true;
326 template<typename T, CoreModifiable::ATTRIBUTE_TYPE attributeType = TypeToEnum<T>::value>