What if...

Published March 07, 2005
Advertisement
C++

ClassDefinition simpleDef( "Vector" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "x" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "y" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "z" );


Environment env;
env.RegisterClass( simpleDef );

ClassInstance *inst = env.CreateInstance( "Vector" );
inst->Property( "x" ).Set( 100.0f );
inst->Property( "y" ).Set( 200.0f );
std::cout << "x: " << inst->Property( "x" ).GetFloat();
std::cout << "y: " << inst->Property( "y" ).GetFloat();
std::cout << "z: " << inst->Property( "z" ).GetFloat();
Previous Entry Subversioning
Next Entry What if... Pt 2
0 likes 1 comments

Comments

JTippetts
I do something kinda-sorta-but-not-really like that for my configurations class. I store properties as key/value pairs in a map, where the key and value are both strings, and I can query each value as a string, an int, a float, a double, etc...
March 07, 2005 07:17 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement