Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

OutputStrategy

With the help of the strategy design pattern it is possible to switch easily between several input and output formats. More...

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...


Detailed Description

With the help of the strategy design pattern it is possible to switch easily between several input and output formats.

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:

output_sequence.jpg
In order to reimplement an OutputStrategy subclasses must support these methods: OutputStrategy::writeHeader() is called at the beginning of the output and should print the header. The same is valid for OutputStrategy::writeFooter(). The methods OutputStrategy::writeNormalNode() and OutputStrategy::writeRootNode() print the specific content of the different node types and are called each time the visitor visits the corresponding node type. The method OutputStrategy::writeString() prints a string, i.e. a node name.
DefaultOutputStrategy
This strategy writes the name and the type of a node to standard output. It is used when the OutputVisitor is not configured for another output strategy.
StreamOutputStrategy
All other strategies write their output into a stream. The common functionalities like the setting of the output stream and the output of a string is handled in the abstract class StreamOutputStrategy.
TEXGraphOutputStrategy
This strategy is used for the output of a graphical representation of a tree in LaTeX Format. The scaling of such a graphic can be done with TEXGraphOutputStrategy::setScale(). With the method TEXGraphOutputStrategy::setPositionMap() a position map made by a LayoutVisitor (see section NodeVisitor) can be passed.

outputstrategy2.jpg

Hierarchy of OutputStrategy classes


Generated on Mon Jan 6 12:02:16 2003 for TreeComp by doxygen1.2.17