-
Notifications
You must be signed in to change notification settings - Fork 23
Struct Class manual reflection
Julien SOYSOUVANH edited this page Oct 26, 2021
·
1 revision
For the example, we will manually reflect the following class:
//ThirdPartyClass.h
class ThirdPartyClass
{
protected:
int protectedField = 0;
void protectedMethod(){}
};
It is important to note that it is not possible to reflect the entirety of a class manually. We can't reflect private members, or protected/private fields. The best way to get the maximum of reflection through minimum effort is to wrap the class by inheritance or composition:
//ThirdPartyClassWrapper.h
#include "Generated/ThirdPartyClassWrapper.rfkh.h"
class CLASS() ThirdPartyClassWrapper : public ThirdPartyClass
{
protected:
METHOD()
inline void protectedMethod()
{
ThirdPartyClass::protectedMethod();
}
public:
METHOD()
inline int& getProtectedField() { return protectedField; }
ThirdPartyClassWrapper_GENERATED
};
File_ThirdPartyClassWrapper_GENERATED
//ThirdPartyClassWrapper.cpp
#include "Generated/ThirdPartyClassWrapper.rfks.h"