I\'ve been working for years with Java. During those years, I\'ve made extensive (or maybe just frequent) use of reflection, and found it useful and enjoyable. But 8 months ago
You need to use the visitor pattern. Any class that can be reflected on would need to inherit a base class that gave it a Reflect
member function, which would accept a visitor class. Then the Reflect
function would pass information or capabilities about the other members to the visitor.
Many popular libraries use this pattern for specific cases, for example, the Serialize
function in MFC does this but specifically for serialization.
You could probably design a system in such a way that the visitor would be able to make dynamic calls to member functions, get or set the values of data members, etc. But it would be the responsibility of each class to maintain a Reflect
function written by hand, which would be a repetition of the structure of the class.