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

Prototype progress

Sign in to follow this  
evolutional

104 views

I've thrown together a simple meta-object. Very simple usage syntax so far, should be easy to get to grips with.

Example:


// create an entity
gamedb::DataEntity ent;
// assign an attribute
ent.set_attribute( gamedb::Attribute( "String", gamedb::Value( new gamedb::ValueData_String( "Hello" ) ) ) );

// Attribute retreival
gamedb::Attribute attr_n = ent.get_attribute( "String" );
gamedb::Value val = attr_n.get_value();
gamedb::ValueData_String *vd = (gamedb::ValueData_String*)val.get_data();
// print
std::cout << vd->get_data();


The ugliness of the setting/retreival will be hidden by helper functions, eventually. You will notice a couple of concepts in play here. First, we have Attribute. An attribute is a effectively a 'named' value. A Value is dynamically typed and must be assigned an instance of ValueData. I've made a few ValueData helpers, specifically those that handle the main native types (int, float, std::string, Function and DataEntity (eg: Entity).

This seems to work nicely (again, helpers will be nice), so tomorrow I can get on with the business of the 'database' side of it and get some simple queries running.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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!