GEGELATI
program.h
1
37#ifndef PROGRAM_H
38#define PROGRAM_H
39
40#include <algorithm>
41#include <vector>
42
43#include "data/constantHandler.h"
44#include "environment.h"
45#include "program/line.h"
46
47namespace Program {
52 class Program
53 {
54 protected:
57
69 std::vector<std::pair<Line*, bool>> lines;
70
78
80 Program() = delete;
81
82 public:
90 : environment{e}, constants{e.getNbConstant()}
91 {
92 constants.resetData(); // force all constant to 0 at first.
93 };
94
103 Program(const Program& other)
104 : environment{other.environment}, lines{other.lines},
105 constants{other.constants}
106 {
107 // Replace lines with their copy
108 // Keep intro info
109 std::transform(
110 lines.begin(), lines.end(), lines.begin(),
111 [](std::pair<Line*, bool>& otherLine)
112 -> std::pair<Line*, bool> {
113 return {new Line(*(otherLine.first)), otherLine.second};
114 });
115 };
116
123 Program& operator=(const Program& other) = delete;
124
131 ~Program();
132
140 Line& addNewLine();
141
152 Line& addNewLine(const uint64_t idx);
153
164 void clearIntrons();
165
175 void removeLine(const uint64_t idx);
176
184 void swapLines(const uint64_t idx0, const uint64_t idx1);
185
193 const Environment& getEnvironment() const;
194
200 size_t getNbLines() const;
201
209 const Line& getLine(uint64_t index) const;
210
218 Line& getLine(uint64_t index);
219
228 bool isIntron(uint64_t index) const;
229
238 uint64_t identifyIntrons();
239
248 Data::ConstantHandler& getConstantHandler();
249
259 const Data::ConstantHandler& cGetConstantHandler() const;
260
270 const Data::Constant getConstantAt(size_t index) const;
271
281 bool hasIdenticalBehavior(const Program& other) const;
282 };
283} // namespace Program
284#endif
Data::DataHandler used by Program::Program to handle their set of Constant values.
Definition: constantHandler.h:56
void resetData() override
Sets all elements of the Array to 0 (or its equivalent for the given template param....
Definition: primitiveTypeArray.h:169
The Environment class contains all information needed to execute a Program.
Definition: environment.h:84
Definition: line.h:48
const Environment & environment
Environment within which the Program will be executed.
Definition: program.h:56
Program(const Environment &e)
Main constructor of the Program.
Definition: program.h:89
Program()=delete
Delete the default constructor.
Program & operator=(const Program &other)=delete
Data::ConstantHandler constants
Constants of the Program.
Definition: program.h:77
Program(const Program &other)
Copy constructor of the Program.
Definition: program.h:103
std::vector< std::pair< Line *, bool > > lines
Lines of the program and intron property.
Definition: program.h:69
Definition: line.h:43
Data type used in Program::Program to define constant values, accessible to Instructions,...
Definition: constant.h:48