-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagram.h
108 lines (89 loc) · 2.49 KB
/
diagram.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef DIAGRAM_H
#define DIAGRAM_H
#include <vector>
#include <list>
#include "diagramcode.h"
#include "diagrammove.h"
class Diagram
{
public:
// Constructors, destructors, operators
Diagram(const DiagramCode&);
~Diagram();
Diagram& operator=(const Diagram&);
const bool operator==(const Diagram&);
// Gives diagram code
const DiagramCode getCode();
// Lists possible moves
const std::array<DiagramMove> getMoves();
// Returns a copy of diagram after a move
const Diagram makeMove(const DiagramMove&);
private:
class Vertex
{
public:
Vertex();
~Vertex();
Vertex * forward() const;
Vertex * backward() const;
virtual void setForward(Vertex*);
virtual void setBackward(Vertex*);
virtual bool isCrossing() const;
virtual bool isEnding() const;
private:
Vertex(const Vertex&);
Vertex& operator=(const Vertex&);
Vertex * _forward;
Vertex * _backward;
};
class Crossing : public Vertex
{
public:
// construct THIS and OTHER strand
Crossing(bool upper,bool positive);
~Crossing();
Vertex * left() const;
Vertex * right() const;
Vertex * upForward() const;
Vertex * upBackward() const;
Vertex * downForward() const;
Vertex * downBackward() const;
Vertex * upStrand() const;
Vertex * downStrand() const;
Vertex * otherStrand() const;
bool isUpStrand() const;
bool isDownStrand() const;
bool isPositive() const;
bool isNegative() const;
bool isCrossing() const;
private:
Crossing(const Crossing&);
Crossing& operator=(const Crossing&);
// ALLOW
Crossing(bool,bool,Vertex *);
void setOtherStrand(Vertex *) const;
Vertex * _otherStrand;
bool _positive;
bool _up;
};
class Ending : public Vertex
{
public:
Ending();
~Ending();
bool isEmpty() const;
bool isStart() const;
bool isEnd() const;
bool setForward(Vertex *);
bool setBackward(Vertex *);
bool isEnding() const;
private:
Ending(const Ending&);
Ending& operator=(const Ending&);
};
// No empty diagram allowed
Diagram();
// Diagram vertices
std::list<Vertex *> _vertices;
};
#endif