Implemented operator overloads for Reflection

This commit is contained in:
Vulpovile
2023-11-05 00:37:25 -07:00
parent 901539e594
commit cab66d1152
8 changed files with 273 additions and 59 deletions

View File

@@ -20,8 +20,19 @@ namespace B3D{
ReflectionProperty(std::string key, T defaultValue, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false);
ReflectionProperty(void);
~ReflectionProperty(void);
T getValue();
T getValueClone();
T* getValuePtr();
void setValue(T);
void dispose();
//Too many
#include "ReflectionProperty_op_overload.h"
private:
std::string propertyName;
bool archivable;

View File

@@ -47,4 +47,27 @@ void ReflectionProperty<T>::dispose()
delete extData;
extData = NULL;
}
}
template<class T>
T ReflectionProperty<T>::getValueClone()
{
return T(value);
}
template<class T>
T ReflectionProperty<T>::getValue()
{
return *value;
}
template<class T>
T* ReflectionProperty<T>::getValuePtr()
{
return value;
}
template<class T>
void ReflectionProperty<T>::setValue(T value){
this=value;
}

View File

@@ -0,0 +1,175 @@
//Operator Overloads
T operator()()
{
return *value;
}
//Assignment Operators
T operator=(T nVal)
{
(*value) = nVal;
return *value;
}
T operator+=(T nVal)
{
(*value) += nVal;
return *value;
}
T operator-=(T nVal)
{
(*value)-= nVal;
return *value;
}
T operator/=(T nVal)
{
(*value) /= nVal;
return *value;
}
T operator*=(T nVal)
{
(*value) *= nVal;
return *value;
}
T operator%=(T nVal)
{
(*value) %= nVal;
return *value;
}
T operator^=(T nVal)
{
(*value) ^= nVal;
return *value;
}
T operator&=(T nVal)
{
(*value) &= nVal;
return *value;
}
T operator|=(T nVal)
{
(*value) |= nVal;
return *value;
}
T operator>>=(T nVal)
{
(*value) >>= nVal;
return *value;
}
T operator<<=(T nVal)
{
(*value) <<= nVal;
return *value;
}
//Mathematical Operations
T operator+(T nVal)
{
return (*value) + nVal;
}
T operator-(T nVal)
{
return (*value) - nVal;
}
T operator*(T nVal)
{
return (*value) - nVal;
}
T operator/(T nVal)
{
return (*value) / nVal;
}
T operator%(T nVal)
{
return (*value) % nVal;
}
//Boolean operations
bool operator==(T nVal)
{
return (*value) == nVal;
}
bool operator!=(T nVal)
{
return (*value) != nVal;
}
bool operator<(T nVal)
{
return (*value) < nVal;
}
bool operator<=(T nVal)
{
return (*value) <= nVal;
}
bool operator>(T nVal)
{
return (*value) > nVal;
}
bool operator>=(T nVal)
{
return (*value) >= nVal;
}
T operator&&(T nVal)
{
return (*value) && nVal;
}
T operator||(T nVal)
{
return (*value) && nVal;
}
T operator!()
{
return !(*value);
}
//Bitwise operations
T operator&(T nVal)
{
return (*value) && nVal;
}
T operator|(T nVal)
{
return (*value) && nVal;
}
T operator>>(T nVal)
{
return (*value) >> nVal;
}
T operator<<(T nVal)
{
return (*value) << nVal;
}
T operator^(T nVal)
{
return (*value) ^ nVal;
}
T operator~()
{
return ~(*value);
}