jeudi 17 mars 2016

Visitor pattern and logical operations

Okay i've been strugling with this problem I'm having.

I have created a tree structure with logical nodes e.g. And, Or, Equals, Between. I don't want these nodes to have anything more than an accept method for the visitor, because there will be more visitors with different implementations.

So for example i'm visiting the and. It first visits itself so i know i'm dealing with an and, then it is visiting the left and the right nodes. Which can be any of earlier said nodes.

The problem is, that I need a way of checking that I am finished with visiting the childnodes. For example I want this output

"And(Equals()/Or(Equals()/Between())"

But since I have no way of knowing when childs have been visited it will be someting like this.

"And()Equals()/Or()Equals()/Between()

Any suggestions on how to overcome this problem?

Aucun commentaire:

Enregistrer un commentaire