Jump to content
  • Advertisement
  • entries
    437
  • comments
    1000
  • views
    336866

What if...

Sign in to follow this  
evolutional

109 views

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();
Sign in to follow this  


1 Comment


Recommended Comments

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...

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!