Hi,
I'm in the process of building a complex system using a sort of "system
services" model. I'm looking at putting together various services like
serialization, networking, 2D/3D rendering, debugger-like class
inspection and other assorted stuff, but I need a way to bind them to
other people's C++ code at runtime using external scripting.
In particular I need a way to be able to access members of a class at
runtime by name, and I need the system to work in a non-intrusive way.
The classes being accessed are pre-existing (user code, toolkit
libraries...etc) and I can't add any code to the classes being accessed
or force them to inherit from a common base. In other words, the
dictionary information and code that does the introspection needs to be
completely outboard of the classes being inspected.
I've been searching the net awhile and have found a number of systems
for doing this, but most are very intrusive or compiler-specific. Can
anyone put up some pointers to systems/approaches they think might fit
the bill?
It's ok if some manual work is needed to generate the dictionary of
class members, it doesn't have to be totally automatic.
Specifically, the sort of things I want to use this for are:
1. A service that can be given a pointer to an object, then pull member
values out of that object and display them in an auto-generated GUI.
2. A service that can be given a pointer to an object, pull specific
member values out of the object and send them over a network link to a
"mirror" version of the object on another computer.
3. A service that can be given a pointer to a class and
serialize/deserialize select members to disk/xml.
4. Allowing scripts to bind to values in running objects ie: allowing a
script to push values into a class (such as a script that puts the
appropriate color, model...etc into an instance of "Car") or a script
that creates bindings between classes (ie: something that says "every
1/60th of a second grab car1.SteeringWheelPosition, convert it into a
rotation matrix and deposit it in rendererNode1.TransformationMatrix")
5. Allowing a 2d/3d renderer to be given a pointer to an object, look
up information on its class and connect to specific members containing
details about the type of the object, position, orentation...etc so it
can be rendered.
The main goal is to allow users to write their classes independent of
any specific application framework, then use this introspection
information and scripts to sort of "wire up" the system at runtime
(connect classes to each other and to the system services).
Any help/suggestions would be appreciated!