FreeOrion

Forums for the FreeOrion project
It is currently Wed Jun 19, 2013 5:26 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Storing object pointers in Systems
PostPosted: Fri Jul 11, 2003 1:46 am 
Offline
Space Squid

Joined: Thu Jun 26, 2003 12:09 pm
Posts: 95
Location: Chicago
Just want to post notice and give an opportunity for objections to a change I'm going to make to our System objects (that means you, Zach :D ). As initially implemented the System has a map that stores pointers to Universe Objects that are in orbit around the star. This causes a number of complications when it comes to XML decoding and sort of breaks our paradigm that objects are contained by the Universe object map and referred to by ID's elsewhere. The primary benefit of it is to allow predicate iteration through system objects. The problems are that a) it would require ordered creation of objects at the client side so that the orbitting objects exist and have objects to point at when the system is created (this is not that hard to work around), and b) the System stores the pointers as non-const, but the client object lookups only return const pointers. (b) gives a few options:

--Create a non-const lookup in the client
--Have the system object store the pointers as const
--Have different implementations of System for client and server
--Have the system object store ID's instead of pointers

My feeling is that the best solution is to just make the system map hold object ID's as it will be more consistent with how we handle references in similar cases (ships in fleets, universe_object lists in Empire) rather than creating more special exceptions for what is already a special exception. If desireable we can create some utility functions for the more commonly desired predicate searches (ie planet lookup, fleet lookup). I would be willing to hear other proposals though.. I am actually making this change already so that I can progress with the encode/decode work, but I'll reverse the change if a convincing case is made.

_________________
Programming Lead


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 11, 2003 2:12 am 
Offline
Programming Lead Emeritus
User avatar

Joined: Thu Jun 26, 2003 1:33 pm
Posts: 1092
This sounds like a really good change to me; from looking over the code again, it seems obvious that this was a poor design choice on my part. Also, UniverseObjects should return an ID number from System(), rather than a System*, to avoid the same sort of construction-order dependency.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group