I have a question, not about OF but about object-oriented-programming in c++. not sure if this is the right place to ask this kind of question but here it goes!
I was wondering if there is a way to list all attributes(functions, variables, etc…) from a class. I’m asking this because i want to to make a dynamic GUI.
For example i have a class that is a particle system. That class i have their attributes like position, velocity, acceleration, etc… And i want to to choose what variable a certain control(slider, button…) will modify in real time.
How can I do this, i’ve been reading about class reflexion and RTTI but can’t find anything real helpful!
Does anyone have done this? If so can you share some code with me, or give me some tutorial/documentation links or tips?
Unfortunately, the C++ runtime type system doesn’t contain stuff like that.
As far as I know, the only information that is preserved (and can be looked up) is the name of the entire class, via the type_id function and the type_info::name member.
So, I think you need to do your dynamic GUI in some other way. I think many people use some kind of “parameter” class to hold all values that need to be modifiable by their GUI, and then add all parameter instances to a registry that can be searched from the GUI code. That is, you need to track info about all data members yourself.
thanks for the answer pappis!
So basically it’s impossible to get information about a class attributes?! that’s sad…
Maybe there is another way to do that! no?
I found a c++ library that does exactly what i want here, but i’m having some NOOB problems using it. Can anyone help me with this?
Here the link to the library page http://root.cern.ch/drupal/content/reflex
I was able to include the library, i followed this tutorial http://seal-reflex.web.cern.ch/seal-reflex/examples.html
but i end up with this errors:
I guess i’m missing something, but i can’t figure it out what?
Really appreciate your help.
Since its a linker error, and its complaining about Reflex stuff missing, I would guess that you havent included the Reflex library properly in your project. If the Reflex library is built as a static/dynamic library, you need to link against it (that is, add the library file to your Xcode target). If it is a source code library, you need to include the .cpp files in your Xcode target.