-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv_entry.hpp
173 lines (126 loc) · 4.34 KB
/
env_entry.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// File: EnvEntry.hpp
// Author: Samuel McFalls
#ifndef ENVENTRY_H
#define ENVENTRY_H
#include <vector>
#include "atom.hpp"
#include "graph.hpp"
class EnvEntry {
public:
// Typdef for the possible types of Environment Entry
typedef enum e_Env {NONE, BOOL, NUMBER, POINT, LINE, ARC, FPTR_BOOL, FPTR_NUMBER, FPTR_POINT, FPTR_LINE, FPTR_ARC} Type;
// Typedef for a function pointer that takes a vector of Atoms as input and
// produces a bool output
typedef bool(*fptrBool)(std::vector<Atom>);
// Typedef for a function pointer that takes a vector of Atoms as input and
// produces a double output
typedef double(*fptrNumber)(std::vector<Atom>);
// Typedef for a function pointer that takes a vector of Atoms as input and
// produces a point output
typedef Point(*fptrPoint)(std::vector<Atom>);
// Typedef for a function pointer that takes a vector of Atoms as input and
// produces a line output
typedef Line(*fptrLine)(std::vector<Atom>);
// Typedef for a function pointer that takes a vector of Atoms as input and
// produces an arc output
typedef Arc(*fptrArc)(std::vector<Atom>);
// Default constructor
// Type NONE with no value
EnvEntry();
// Contructs an entry with a bool
// Set the type to BOOL
// @param value The value store
EnvEntry(bool value);
// Contructs an entry with a double
// Set the type to NUMBER
// @param value The value store
EnvEntry(double value);
// Contructs an entry with a point
// Set the type to POINT
// @param value The value store
EnvEntry(Point value);
// Contructs an entry with a line
// Set the type to LINE
// @param value The value store
EnvEntry(Line value);
// Contructs an entry with a arc
// Set the type to ARC
// @param value The value store
EnvEntry(Arc value);
// Contructs an entry with a fptrBool
// Set the type to FPTR_BOOL
// @param func The function store
EnvEntry(fptrBool func);
// Contructs an entry with a fptrNumber
// Set the type to FPTR_NUMBER
// @param func The function store
EnvEntry(fptrNumber func);
// Contructs an entry with a fptrPoint
// Set the type to FPTR_POINT
// @param func The function store
EnvEntry(fptrPoint func);
// Contructs an entry with a fptrLine
// Set the type to FPTR_LINE
// @param func The function store
EnvEntry(fptrLine func);
// Contructs an entry with a fptrArc
// Set the type to FPTR_ARC
// @param func The function store
EnvEntry(fptrArc func);
// Gets the type of an EnvEntry
// @return The type of the EnvEntry
Type getType();
// Gets the BOOL value of an EnvEntry
// @return The BOOL value of the EnvEntry
// @throws logic_error if EnvEntry is not of type BOOL
bool getBool();
// Gets the NUMBER value of an EnvEntry
// @return The NUMBER value of the EnvEntry
// @throws logic_error if EnvEntry is not of type NUMBER
double getNumber();
// Gets the POINT value of an EnvEntry
// @return The POINT value of the EnvEntry
// @throws logic_error if EnvEntry is not of type POINT
Point getPoint();
// Gets the LINE value of an EnvEntry
// @return The LINE value of the EnvEntry
// @throws logic_error if EnvEntry is not of type LINE
Line getLine();
// Gets the ARC value of an EnvEntry
// @return The ARC value of the EnvEntry
// @throws logic_error if EnvEntry is not of type ARC
Arc getArc();
// Gets the FPTR_BOOL value of an EnvEntry
// @return The FPTR_BOOL value of the EnvEntry
// @throws logic_error if EnvEntry is not of type FPTR_BOOL
fptrBool getFptrBool();
// Gets the FPTR_NUMBER value of an EnvEntry
// @return The FPTR_NUMBER value of the EnvEntry
// @throws logic_error if EnvEntry is not of type FPTR_NUMBER
fptrNumber getFptrNumber();
// Gets the FPTR_POINT value of an EnvEntry
// @return The FPTR_POINT value of the EnvEntry
// @throws logic_error if EnvEntry is not of type FPTR_POINT
fptrPoint getFptrPoint();
// Gets the FPTR_LINE value of an EnvEntry
// @return The FPTR_LINE value of the EnvEntry
// @throws logic_error if EnvEntry is not of type FPTR_LINE
fptrLine getFptrLine();
// Gets the FPTR_ARC value of an EnvEntry
// @return The FPTR_ARC value of the EnvEntry
// @throws logic_error if EnvEntry is not of type FPTR_ARC
fptrArc getFptrArc();
private:
Type type;
bool boolVal;
double numberVal;
Point pointVal;
Line lineVal;
Arc arcVal;
fptrBool boolFunc;
fptrNumber numberFunc;
fptrPoint pointFunc;
fptrLine lineFunc;
fptrArc arcFunc;
};
#endif