#define GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName,PropertyName) \
static std::string Get##PropertyName##Attribute() \
{ \
return #PropertyName; \
}
#define GAMEPLAYATTRIBUTE_VALUE_GETTER(ClassType,PropertyName) \
__inline ClassType Get##PropertyName() \
{ \
return PropertyName; \
}
#define GAMEPLAYATTRIBUTE_VALUE_SETTER(ClassType,PropertyName) \
__forceinline void Set##PropertyName(ClassType NewVal) \
{ \
PropertyName = NewVal; \
}
#define ATTRIBUTE_ACCESSORS(ClassName,ClassType,PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName,PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(ClassType,PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_SETTER(ClassType,PropertyName)
class MyClass
{
private:
float Health;
public:
MyClass();
~MyClass();
ATTRIBUTE_ACCESSORS(MyClass,float,Health)
};
MyClass::MyClass()
{
Health = 20;
}
MyClass::~MyClass()
{
}
#define A 2
#define _STR(s) #s
#define STR(s) _STR(s)
#define _CONS(a,b) (int)a##e##b
#define CONS(a,b) _CONS(a,b)
#define ANY_PACKAGE ((MyClass*)-1)
int main()
{
printf("int max:%s\n",STR(INT_MAX));
printf("CONS(a,b)=>%d\n",CONS(A,A));
MyClass Temp;
std::cout << MyClass::GetHealthAttribute() << std::endl;
std::cout << Temp.GetHealth() << std::endl;
Temp.SetHealth(100);
std::cout << Temp.GetHealth() << std::endl;
}