From: Chad \Exodist Admin-Ra\ Granum <granum@sb...> - 2004-08-02 22:19:48
this is a confusing question so I am going to elaborate:
I am planning to make a type of class called a blueprint. it holds data
onhow to build a specific instance of on object, for instance:
a character object has an image object and a string object. say you want
to transfer that over the network or save it to the file. you can do a
flat out binary deep copy into a filestream, but then the image is also
stored inside the file, 20 characters with the same image would store
the data 20 times, same with network transfers a big drain on bandwidth.
the blueprint file would store the name of the image rather then the
image itself, then on the other side it will load the image by it's name
rather than transfer the whole image cause it already has a copy.
now, the problem is loading the image, if there is already an instance
in memory you want it to point there (because a character does not
change the image object, though it might change which image object it
uses the object itself remains unchanged. but if everything is loaded at
the start and fed into sub-classes how would the subclasses reach the
top level and request the instance of the image already in memory?
I figured 2 solutions to this, then a third undesireable one.
first 2 solutions:
create a master array/list that holds a copy of every instance of
in the first solution that I do not like you would read all the data
files into the master list then pass ti as a reference to every
instanciated object, this is redundant and annoying but is tested towork
ina previous program I made.
the second solution which I really want to do I am not sure will work:
read all the data into the master index, but make the master index have
all it's variables static, then rather than passing it down to retrievbe
a copy of something you call: MasterIndex.getWhatever(String name) and
it returns a reference of the object you want.
my question is if I make the variables inside all static (meathods to)
and have an instance of it floating around somewhere would calling the
function on the MasterIndex object (not the instance of it, but the
class itself) draw from the variable that is static?
third option, very undesireable:
create a static meathod thsat is called to re-read the data files every
tiem something is needed from them. resulting in lots of wasted memory
and time do to hd reading.
if option 2 did not make sence let me know it is hard to explain I will
try again if you don't understand.