karbon

VVisitor Class Reference

#include <vvisitor.h>

Inheritance diagram for VVisitor:

VCommand VComputeBoundingBox VDrawSelection VSelection VSelectionDescription VSelectObjects VDeleteCmd VDistributeCmd VReplacingCmd VZOrderCmd

List of all members.


Detailed Description

The abstract visitor class.

(From Wikipedia)

In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure. A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures.

The idea is to use a structure of element classes, each of which has an accept method that takes a visitor object as an argument. The visitor is an interface that has a different visit() method for each element class. The accept() method of an element class calls back the visit() method for its class. Separate concrete visitor classes can then be written that perform some particular operations.

One of these visit() methods of a concrete visitor can be thought of as methods not of a single class, but rather methods of a pair of classes: the concrete visitor and the particular element class. Thus the visitor pattern simulates double dispatch in a conventional single-dispatch object-oriented language such as Java, Smalltalk, and C++.

The visitor pattern also specifies how iteration occurs over the object structure. In the simplest version, where each algorithm needs to iterate in the same way, the accept() method of a container element, in addition to calling back the visit() method of the visitor, also passes the visitor object to the accept() method of all its constituent child elements.

Because the Visitor object has one principal function (manifested in a plurality of specialized methods) and that function is called visit(), the Visitor can be readily identified as a potential function object or functor. Likewise, the accept() function can be identified as a function applicator, a mapper, which knows how to traverse a particular type of object and apply a function to its elements.

Definition at line 50 of file vvisitor.h.


Public Member Functions

 VVisitor ()
virtual bool visit (VObject &object)
virtual void visitVObject (VObject &object)
virtual void visitVPath (VPath &composite)
virtual void visitVDocument (VDocument &document)
virtual void visitVGroup (VGroup &group)
virtual void visitVLayer (VLayer &layer)
virtual void visitVSubpath (VSubpath &path)
virtual void visitVSelection (VSelection &selection)
virtual void visitVText (VText &text)
virtual void visitVImage (VImage &img)
bool success () const

Protected Member Functions

virtual ~VVisitor ()
void setSuccess (bool success=true)

Constructor & Destructor Documentation

VVisitor::VVisitor (  )  [inline]

Constructs a new visitor class.

Definition at line 56 of file vvisitor.h.

virtual VVisitor::~VVisitor (  )  [inline, protected, virtual]

Destructs a visitor class.

Definition at line 137 of file vvisitor.h.


Member Function Documentation

bool VVisitor::visit ( VObject object  )  [virtual]

General visit method.

Pass an object to this function. This is a virtual function so you need to implement it in the subclass if you want to use it. Return the success value.

Definition at line 31 of file vvisitor.cc.

void VVisitor::visitVObject ( VObject object  )  [virtual]

Visit method for a VObject.

Pass an object to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Definition at line 112 of file vvisitor.cc.

void VVisitor::visitVPath ( VPath composite  )  [virtual]

Visit method for a VPath.

Pass a composite path to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox, VDrawSelection, VSelectionDescription, and VSelectObjects.

Definition at line 74 of file vvisitor.cc.

void VVisitor::visitVDocument ( VDocument document  )  [virtual]

Visit method for a VDocument.

Pass a document to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox.

Definition at line 41 of file vvisitor.cc.

void VVisitor::visitVGroup ( VGroup group  )  [virtual]

Visit method for a VGroup.

Pass a group of objects to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox, VSelectionDescription, and VSelectObjects.

Definition at line 52 of file vvisitor.cc.

void VVisitor::visitVLayer ( VLayer layer  )  [virtual]

Visit method for a VLayer.

Pass a layer to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox, and VSelectObjects.

Definition at line 63 of file vvisitor.cc.

void VVisitor::visitVSubpath ( VSubpath path  )  [virtual]

Visit method for a VSubpath.

Pass a path to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Definition at line 86 of file vvisitor.cc.

void VVisitor::visitVSelection ( VSelection selection  )  [virtual]

Visit method for a VSelection.

Pass a selection to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VSelectionDescription.

Definition at line 91 of file vvisitor.cc.

void VVisitor::visitVText ( VText &  text  )  [virtual]

Visit method for a VText.

Pass some text to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox, VSelectionDescription, and VSelectObjects.

Definition at line 102 of file vvisitor.cc.

void VVisitor::visitVImage ( VImage &  img  )  [virtual]

Visit method for a VImage.

Pass an image to this function. This is a virtual function so you need to implement it in the subclass if you want to use it.

Reimplemented in VComputeBoundingBox, VSelectionDescription, and VSelectObjects.

Definition at line 107 of file vvisitor.cc.

bool VVisitor::success (  )  const [inline]

Return if the operation was a success or not.

Definition at line 125 of file vvisitor.h.

void VVisitor::setSuccess ( bool  success = true  )  [inline, protected]

Set the success property.

Definition at line 142 of file vvisitor.h.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys