Re: [Libxmlplusplus-general] dom_parser example using Visitor pattern



On Thu, 2003-02-06 at 17:50, Stefan Seefeld wrote:
> Murray Cumming wrote:
> > On Tue, 2003-02-04 at 08:21, Stefan Seefeld wrote:
> > 
> >>* add a 'Visitor' class to get rid of all the dynamic_casts in the existing
> >>   examples
> > 
> > 
> > I read that chapter in the Design Patterns book yesterday. It would be
> > interesting, but I think it should be a separate example (maybe
> > dom_parser_visitor) because we still need a simple example of the API.
> 
> I don't quite see the link between a parser (a document factory), and
> a visitor.

Sorry, I thought you just wanted to change an example rather than the
library.

> I agree that this is quite independent of the rest. It merely addresses
> the type safety issue, i.e. it helps us recover the exact type of a
> child node.
> 
> In terms of API complexity it requires all nodes to have an 'accept'
> method, to be implemented as
> 
> void Element::accept(Visitor *v) { v->visit_element(this);}
>
>
> plus a 'Visitor' base class that has one 'visit' method per node type.
> (to be implemented by users)

Hmm. Let's see a patch - I'm not sure how this will be useful for
non-generic stuff. And I think that accept() should probably be called
visitor_accept().

-- 
Murray Cumming
murray usa net
www.murrayc.com





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]