Base class for writing custom Class visitors.
A ClassVisitor, when applied to a Class, will be notified for each member property and function of the target class. To receive this notification for a specific type T of property or function, you have to override the visit(T)
function.
The benefit of such visitation is that you directly get the actual type of the property or function, and can handle it safely without having to use dangerous downcasts.
Another benefit of this method is that you can easily filter the properties and functions according to their C++ type: if you don't want to handle a specific type of property or function, just don't override the corresponding visit
function.
Here an example of a visitor which prints the contents of a class:
{
{
std::cout << "Simple property: " << property.name() << std::endl;
}
{
std::cout << "Array property: " << property.name() << " - "
<< "dynamic:" << property.dynamic() << std::endl;
}
{
std::cout << "Enum property: " << property.name() << " - "
<< "owner enum:" << property.getEnum().name() << std::endl;
}
{
std::cout << "User property: " << property.name() << " - "
<< "owner class:" << property.getClass().name() << std::endl;
}
{
std::cout << "Function: " << function.name() << " - "
<< "number of parameters:" << function.paramCount() << std::endl;
}
};
MyClassVisitor visitor;
metaclass.
visit(visitor);