Hierarchical Visitor Pattern

Published July 22, 2006
Advertisement
As many of you I use TinyXML for my XML in C++ parsing needs. I lurk on the mailing list too. Once in a while the project manager Lee Thomason decides to change or add something, other than normal fixes. Last time I got involved was when he was going to add a copy constructor. I suggested using the Template Method to implement deep copies. I even implemented it and submitted the patch, so my code's in there! ;)

Now it's time again. He was going to add two new features; a Visitor pattern functionality and a PrintToMemory function. I joined in on the discussion and with a hot tip on (see below) got him on the right track. Of course, DrunkenCoder had something to do with this. ;)

PrintToMemory is obviously a typical Visitor and a perfect way to test the new visitor functionality. It just traverses the whole XML tree and prints it to a in memory buffer, think std::string. The initial Visitor he suggested was a plain game dev vanilla visitor, a special visitor most of us use that allows us to know when we leave a node (so we can differentiate between childs and siblings). But what about those cases when you want to trim away a whole section? I was doing something like that for my MediatorMenu project. This has already been solved and named the Hierarchical Visitor Pattern. I highly recommend you read that!

Lee contacted me about my PrintToMemoryVisitor proposal and I just sent in the patches. I slimmed his Visitor pattern as I like it too. I'll post again when we've sorted things out and my code once again becomes a small part of TinyXML. ^^
0 likes 1 comments

Comments

Will F
Sending patches to open source projects makes me feel all warm and fuzzy inside. [smile]
July 22, 2006 07:54 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement