properties, lists of properties and API access

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Fri, 21 Jan 2011 09:56:42 -0700

Hello all,
I have a quick question, or maybe not so quick, after I explain.
Aspen's properties are what are stored that allows a coder to serialize properties and access them with other components. It essentially is just a hash_map<std::string, Variant>. Now, I have a bit of an issue. I'm looking at building an object such as a ship, for example. Now, each ship wil have multiple different weapons, so I will need a sort of collection. I'm having a problem with this, because right now I can just do object["hp"]=100 and it sets the hp varaint to 100. Now, if I want collections I want to do something like: object['weapons'][0]['damage']... Are there any solutions to setting something like this up? Maybe I can just overload the [] operator on my PropertyContainer class, so that it will check for the existance of a variant, and if such a variant does not exist it will then proceed to check for the value in the collections list? Which leads me to another concern. My property list will end up looking something like: std::hash_map<std::string, std::vector<std::hash_map<std::string, Variant> > >; This does not seem like a great idea, at all. But I'm not really sure how to set it up so that it might work faster, etc. Ideas would be welcome.

--

Thanks,
Ty
http://tds-solutions.net
Peace cannot be kept by force; it can only be achieved by understanding.-- 
Albert Einstein
Live as if you were to die tomorrow. Learn as if you were to live 
forever.-gandhi
I know that you believe you understand what you think I said, but I'm not sure 
you realize that what you heard is not what I meant.-Robert McCloskey

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: