-
Notifications
You must be signed in to change notification settings - Fork 21
Variable manual reflection
Julien SOYSOUVANH edited this page Oct 26, 2021
·
2 revisions
For the example, we will manually reflect the following variable:
//ThirdPartyVar.h
extern int const thirdPartyVariable;
In any source file, create a function to create our variable metadata:
#include "ThirdPartyVar.h"
#include <string_view>
#include <Refureku/TypeInfo/Variables/Variable.h>
static rfk::Variable const& getVariable_thirdPartyVariable() noexcept
{
static rfk::Variable var("thirdPartyVariable",
std::hash<std::string_view>()("thirdPartyVariable"),
rfk::getType<decltype(thirdPartyVariable)>(),
&thirdPartyVariable,
rfk::EVarFlags::Default);
return var;
}
In any cpp file, write the following:
#include <Refureku/TypeInfo/Entity/DefaultEntityRegisterer.h>
rfk::DefaultEntityRegisterer registerer_thirdPartyVariable = getVariable_thirdPartyVariable();