-
Notifications
You must be signed in to change notification settings - Fork 1
Main concepts
pribault edited this page Jan 28, 2023
·
2 revisions
CppReflection focuses on the concept of Type, each type (even not reflectable ones) have their corresponding Type. This type is used to store type informations like attributes, inheritance, name, this way we don't have to add any additional information inside the reflectable classes.
You can retrieve any kind of type using the CppReflection::TypeManager like the following:
#include <CppReflection/TypeManager.h>
#include "MyReflectedClass.h"
using namespace CppReflection;
int main()
{
IType* intType = TypeManager::findType<int>();
IType* pointerType = TypeManager::findType<int*>();
IType* myType = TypeManager::findType<MyReflectedClass>();
return 0;
}
Reflectable objects also have a dedicated method to retrieve their type, getType:
#include "MyReflectedClass.h"
using namespace CppReflection;
int main()
{
MyReflectedClass instance;
IType* myType = instance.getType();
return 0;
}