Compounds | |
class | DefaultOutputStrategy |
This OutputStrategy writes the node-type and name to 'cout.'. More... | |
class | NullOutputStrategy |
NullOutputStrategies are used to define the output-format of the tree -this one is a placeholder, which doesn't produce any output. More... | |
class | OutputStrategy |
OutputStrategies are used to define the output-format of the tree. They are used together with an OutputVisitor which calls their methods appropriately. More... | |
class | StreamOutputStrategy |
This OutputStrategy is used as base-class for all OutputStrategies which write to a stream. More... |
The Strategy classes realize the different formats by implementing the interface of the abstract base class OutputStrategy. The same idea can be used to implement input strategies that create trees or read them from a file.
The output of one format is encapsulated in one class so that changes to a format involve only changes to one class. OutputStrategies are usually used together with a Visitor class. By having a loose coupling between the OutputStrategy and the OutputVisitor a lot of configurations are possible with having to extend the OutputVisitor or even the Node classes.
While the visitor traverses the nodes, the OutputStrategy determines the output. The cooperation between the output of a NormalNode and the DefaultOutputStrategy is shown in this sequence diagram:
Hierarchy of OutputStrategy classes