-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.hpp
107 lines (75 loc) · 2.24 KB
/
atom.hpp
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
// File: Atom.hpp
// Author: Samuel McFalls
#ifndef ATOM_H
#define ATOM_H
#include <string>
#include <tuple>
#include <stdexcept>
#include "graph.hpp"
class Atom {
public:
// Constructs an Atom of type NONE
Atom();
// Constructs an Atom of type BOOL
// @param value The value to set
Atom(bool value);
// Constructs an Atom of type NUMBER
// @param value The value to set
Atom(double value);
// Constructs an Atom of type SYMBOL
// @param value The value to set
Atom(const std::string& value);
// Constructs an Atom of type POINT
// @param value The value to set
Atom(Point value);
// Constructs an Atom of type LINE
// @param value The value to set
Atom(Line value);
// Constructs an Atom of type ARC
// @param value The value to set
Atom(Arc value);
// The possible types of Atom
typedef enum e_AtomType {NONE, BOOL, NUMBER, SYMBOL, POINT, LINE, ARC} Type;
// Gets the type of an Atom
// @return The type of the Atom
Type getType();
// Gets the BOOL value of an Atom
// @return The BOOL value of the Atom
// @throw logic_error if Atom is not of type BOOL
bool getBool();
// Gets the NUMBER value of an Atom
// @return The NUMBER value of the Atom
// @throw logic_error if Atom is not of type NUMBER
double getNumber();
// Gets the SYMBOL value of an Atom
// @return The SYMBOL value of the Atom
// @throw logic_error if Atom is not of type SYMBOL
std::string getSymbol();
// Gets the POINT value of an Atom
// @return The POINT value of the Atom
// @throw logic_error if Atom is not of type POINT
Point getPoint();
// Gets the LINE value of an Atom
// @return The LINE value of the Atom
// @throw logic_error if Atom is not of type LINE
Line getLine();
// Gets the ARC value of an Atom
// @return The ARC value of the Atom
// @throw logic_error if Atom is not of type ARC
Arc getArc();
// Overloaded equality operator
// @return True if the atoms have equal type and value
bool operator==(const Atom& rhs) const noexcept;
// Overloaded inequality operator
// @return True if the atoms have different types or values
bool operator!=(const Atom& rhs) const noexcept;
private:
Type type;
bool boolVal;
double numberVal;
std::string symbolVal;
Point pointVal;
Line lineVal;
Arc arcVal;
};
#endif