RE: properties, lists of properties and API access

  • From: "Sina Bahram" <sbahram@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 21 Jan 2011 16:39:57 -0500

Also, if these happen to be objects in their own right, then make them static 
and also use a singleton pattern.

Take care,
Sina


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ken Perry
Sent: Friday, January 21, 2011 4:37 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: properties, lists of properties and API access

I think what you're looking for is a static member.  Static members of
classes means there is only one and they are all the same.  You can use this
to count how many objects of a type or set things like a global object
value.

Ken

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield,
Tyler
Sent: Friday, January 21, 2011 11:57 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: properties, lists of properties and API access

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

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

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

Other related posts: