I'd just like to mention that, as this seems to be a variant of lazy loading (http://en.wikipedia.org/wiki/Lazy_loading), it might be more appropriate to use that term - not that it matters much here, but moreso in the code.
(IMO Delay loading suggests a *time-based* loading (ie nodes being fully loaded after some time interval), whereas what you describe is deferred partial loading *on demand*.) On Thu, Apr 8, 2010 at 9:33 PM, Mike Caron <[email protected]> wrote: > This is my plan for how Delay Loading will work. This is both for my > reference, and so you guys can comment on it. > > I believe this is necessary for a few reasons. In the future, more lumps will > be in the RELOAD format. Heroes, enemies and text boxes are prime candidates, > right off the bat. However, loading and unloading the entire text box tree > every time you show one would take a forever. And, keeping the tree in memory > might not be a good idea either (I actually have no idea how efficient the > in-memory tree is, to be honest). > > So, instead, you would load the tree once, with delay loading enabled (which > it will be by default, but can be overridden). > > RELOAD will open the document, parse the header and root node, and then stop. > The root node will be marked with a flag saying "this node is only partially > loaded", and the child node will be null. Further, RELOAD will cache the file > handle in the Doc UDT, and the file position in the Node UDT. > > When the child node is dereferenced (by GetFirstChild), RELOAD will notice > that 1. It's null, and 2. It's only partially loaded. It will then partially > load the children of the node, and clear the flag on it. Repeat for all the > children, etc. > > The important thing to keep in mind is that whenever one child is loaded, all > its immediate brethren are loaded too. This ensures that the > Next/PrevSibling() commands are always valid. > > It will also be possible to tell GetFirstChild to disable Delay Loading, > where upon it will load the entire branch of the tree. Again, this will be > useful in the situation of loading a text box, for example. Once you find the > text box in question, you know you're going to read all the children, so it > will be more efficient to load it all at once. > > One last thing. Obviously, adding a new child to a partially loaded node will > trigger loading. I think I will also add a command to go through the entire > tree and load everything, so the file can be closed. (We can't close the file > while not using it, because if it happens to change somehow, then any time we > load a partially loaded node, we risk corrupting something!) > > Anything I'm forgetting here? > > -- > Mike Caron > _______________________________________________ Ohrrpgce mailing list [email protected] http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
