-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisitor.h
66 lines (52 loc) · 1.32 KB
/
Visitor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//============================================================================
// Name : Visitor.h
// Created on : 17.04.2020
// Author : Tokmakov Andrey
// Version : 1.0
// Copyright : Your copyright notice
// Description : Visitor pattern tests
//============================================================================
#ifndef VISITOR_PATTERN_TESTS__H_
#define STATE_PATTERN_TESTS__H_
#include <iostream>
#include <string>
#include <memory>
namespace Visitor_Pattern_Tests {
class Foo;
class Bar;
class Baz;
class IVisitor {
public:
virtual void visit(Foo &ref) = 0;
virtual void visit(Bar &ref) = 0;
virtual void visit(Baz &ref) = 0;
virtual ~IVisitor() = default;
};
class IElement {
public:
virtual void accept(IVisitor &v) = 0;
virtual ~IElement() = default;
};
class Foo : public IElement {
public:
void accept(IVisitor &v) override;
};
class Bar : public IElement {
public:
void accept(IVisitor &v) override;
};
class Baz : public IElement {
public:
void accept(IVisitor &v);
};
class CustorVisitor : public IVisitor {
public:
std::string value;
public:
void visit(Foo &ref) override;
void visit(Bar &ref) override;
void visit(Baz &ref) override;
};
void test();
};
#endif !VISITOR_PATTERN_TESTS__H_