I'm doing this right now.
Compiletime it's just a matter of template meta-programming, so that the overhead is nil - same as an straight assign / function call.
In Runtime, it's more interesting. You can use templates that take any times for any number of arguments up to a predefined level, then, when it is instantiated, check the type ID of that type to the type ID exposed in the property definition...
Yep.
That's what'll I do (I've been stuck on this since sunday)
..
This is what my code looks like right now (Compiletime only):
struct vertex_b { float pos[3]; void rotate(float);};namespace VertexProp { GDN_DEFINE_PROPERTY(x) GDN_DEFINE_PROPERTY(y) GDN_DEFINE_PROPERTY(z) GDN_DEFINE_PROPERTY(Rotate)}template <> struct MetaClass<vertex_b> { typedef Implements< VertexProp::x, MemberArray<vertex_b,float,&vertex_b::pos,0>, VertexProp::y, MemberArray<vertex_b,float,&vertex_b::pos,1>, VertexProp::z, MemberArray<vertex_b,float,&vertex_b::pos,2>,VertexProp::Rotate,Function1<void,vertex_b,float,&vertex_b::rotate> > Implemented;};typedef Interface< VertexProp::x,float, VertexProp::y,float, VertexProp::z,float,VertexProp::Rotate,Function<void,float>> VertexIntf; vertex_b obj;BindToClass<VertexIntf,vertex_b> vertex(obj);cout << "("<< vertex.x.Get() << "," << vertex.y.Get() << "," << vertex.z.Get() << ")"; vertex.rotate(12);//..and to comeBindToClassRT<VertexIntf,vertex_b> vertexRT(obj);vertexRT["x"] = 12.23;vertexRT["y"] = 23.45;vertexRT["Rotate"](123.45);
There are more stuff, like member get/set pairs, read only properties; the function system works polymorphically.
Properties can have different get / set type signitures. And so on. There is a list, I haven't got around to finishing the features list yet
(I hear the flames already....)
*500
EDIT: And, you can do proper Interface MI (java style MI) with the Property::Inherits property
-----------------------------
Gamedev for learning.
libGDN for putting it all together.
[edited by - risingdragon3 on March 3, 2003 4:52:48 PM]