Loki  0.1.7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups
Loki::Visitor< T, R, ConstVisit > Class Template Reference

#include <Visitor.h>

Inheritance diagram for Loki::Visitor< T, R, ConstVisit >:

Detailed Description

template<class T, typename R = void, bool ConstVisit = false>
class Loki::Visitor< T, R, ConstVisit >

The building block of Acyclic Visitor

Usage

Defining the visitable class:

* class RasterBitmap : public BaseVisitable<>
* {
* public:
* };
*

Way 1 to define a visitor:

* class SomeVisitor :
* public BaseVisitor // required
* public Visitor<RasterBitmap>,
* public Visitor<Paragraph>
* {
* public:
* void Visit(RasterBitmap&); // visit a RasterBitmap
* void Visit(Paragraph &); // visit a Paragraph
* };
*

Way 2 to define the visitor:

* class SomeVisitor :
* public BaseVisitor // required
* public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
* {
* public:
* void Visit(RasterBitmap&); // visit a RasterBitmap
* void Visit(Paragraph &); // visit a Paragraph
* };
*

Way 3 to define the visitor:

* class SomeVisitor :
* public BaseVisitor // required
* public Visitor<Seq<RasterBitmap, Paragraph>::Type>
* {
* public:
* void Visit(RasterBitmap&); // visit a RasterBitmap
* void Visit(Paragraph &); // visit a Paragraph
* };
*
Using const visit functions:

Defining the visitable class (true for const):

* class RasterBitmap : public BaseVisitable<void, DefaultCatchAll, true>
* {
* public:
* };
*

Defining the visitor which only calls const member functions:

* class SomeVisitor :
* public BaseVisitor // required
* public Visitor<RasterBitmap, void, true>,
* {
* public:
* void Visit(const RasterBitmap&); // visit a RasterBitmap by a const member function
* };
*
Example:

test/Visitor/main.cpp


The documentation for this class was generated from the following file: