BenchGen
BenchGen is a tool for generating benchmarks to stress-test a computing system.
Loading...
Searching...
No Matches
generatorVariable.h
Go to the documentation of this file.
1#ifndef VARIABLEGENERATOR_H
2#define VARIABLEGENERATOR_H
3#include <cstdlib>
4#include <memory>
5#include <string>
6
7#include "../shared/enums.h"
10
18 public:
19 int id; // Unique identifier for the variable
20 std::string name; // Name of the variable
21 std::string typeString; // String representing the type of the variable
22
23 virtual ~GeneratorVariable() {}
24
34 virtual std::vector<std::string> new_(bool inFunction = false) = 0;
35
43 virtual std::vector<std::string> insert() = 0;
44
52 virtual std::vector<std::string> remove() = 0;
53
62 virtual std::vector<std::string> contains(bool shouldReturn = false) = 0;
63
72 virtual std::vector<std::string> free() = 0;
73
82 virtual std::vector<std::string> genIncludes() = 0;
83
92 virtual std::vector<std::string> genGlobalVars() = 0;
93
104 virtual std::vector<std::string> genParams(std::string paramName, std::vector<GeneratorVariable*> varsParams) = 0;
105};
106
108 public:
110
111 GeneratorSortedList(int id);
112
114
115 std::vector<std::string> new_(bool inFunction = false) override;
116 std::vector<std::string> insert() override;
117 std::vector<std::string> remove() override;
118 std::vector<std::string> contains(bool shouldReturn = false) override;
119 std::vector<std::string> free() override;
120 std::vector<std::string> genIncludes() override;
121 std::vector<std::string> genGlobalVars() override;
122 std::vector<std::string> genParams(std::string paramName, std::vector<GeneratorVariable*> varsParams) override;
123};
124
131 public:
132 int totalSize; // The total size of the array
133
138
146 GeneratorArray(int totalSize, int id);
147
152
153 std::vector<std::string> new_(bool inFunction = false) override;
154 std::vector<std::string> insert() override;
155 std::vector<std::string> remove() override;
156 std::vector<std::string> contains(bool shouldReturn = false) override;
157 std::vector<std::string> free() override;
158 std::vector<std::string> genIncludes() override;
159 std::vector<std::string> genGlobalVars() override;
160 std::vector<std::string> genParams(std::string paramName, std::vector<GeneratorVariable*> varsParams) override;
161};
162
170 public:
171 static unsigned int var_counter;
172
183 static GeneratorVariable* createVariable(std::string type, int identifier);
184
193 static std::string genTypeString(std::string type);
194
204 static std::vector<std::string> genIncludes(std::string type);
205
214 static std::vector<std::string> genGlobalVars(std::string type);
215
227 static std::vector<std::string> genParams(std::string type, std::string paramName, std::vector<GeneratorVariable*> varsParams);
228};
229
230#endif
Class representing an array variable.
Definition generatorVariable.h:130
std::vector< std::string > genGlobalVars() override
Generates global variable declarations for the variable type.
Definition generatorVariable.cpp:110
std::vector< std::string > genParams(std::string paramName, std::vector< GeneratorVariable * > varsParams) override
Generates parameter handling code for functions using this variable type.
Definition generatorVariable.cpp:124
~GeneratorArray()
Destructor for the Array class.
Definition generatorVariable.cpp:135
std::vector< std::string > new_(bool inFunction=false) override
Creates a new variable.
Definition generatorVariable.cpp:42
std::vector< std::string > insert() override
Generates code to perform an insertion operation on the variable.
Definition generatorVariable.cpp:65
std::vector< std::string > genIncludes() override
Generates necessary include statements for the variable.
Definition generatorVariable.cpp:104
GeneratorArray()
Default constructor for the Array class.
Definition generatorVariable.h:137
std::vector< std::string > free() override
Generates code to free or release resources associated with the variable.
Definition generatorVariable.cpp:94
std::vector< std::string > remove() override
Generates code to perform a removal operation on the variable.
Definition generatorVariable.cpp:72
int totalSize
Definition generatorVariable.h:132
std::vector< std::string > contains(bool shouldReturn=false) override
Generates code to perform a contains operation on the variable.
Definition generatorVariable.cpp:79
Definition generatorVariable.h:107
GeneratorSortedList()
Definition generatorVariable.h:109
~GeneratorSortedList()
Definition generatorVariable.cpp:147
std::vector< std::string > contains(bool shouldReturn=false) override
Generates code to perform a contains operation on the variable.
Definition generatorVariable.cpp:250
std::vector< std::string > genParams(std::string paramName, std::vector< GeneratorVariable * > varsParams) override
Generates parameter handling code for functions using this variable type.
Definition generatorVariable.cpp:309
std::vector< std::string > genIncludes() override
Generates necessary include statements for the variable.
Definition generatorVariable.cpp:150
std::vector< std::string > free() override
Generates code to free or release resources associated with the variable.
Definition generatorVariable.cpp:267
std::vector< std::string > new_(bool inFunction=false) override
Creates a new variable.
Definition generatorVariable.cpp:156
std::vector< std::string > insert() override
Generates code to perform an insertion operation on the variable.
Definition generatorVariable.cpp:179
std::vector< std::string > remove() override
Generates code to perform a removal operation on the variable.
Definition generatorVariable.cpp:222
std::vector< std::string > genGlobalVars() override
Generates global variable declarations for the variable type.
Definition generatorVariable.cpp:288
Abstract base class for variable generation.
Definition generatorVariable.h:17
virtual std::vector< std::string > genIncludes()=0
Generates necessary include statements for the variable.
virtual std::vector< std::string > genParams(std::string paramName, std::vector< GeneratorVariable * > varsParams)=0
Generates parameter handling code for functions using this variable type.
virtual ~GeneratorVariable()
Definition generatorVariable.h:23
std::string name
Definition generatorVariable.h:20
virtual std::vector< std::string > insert()=0
Generates code to perform an insertion operation on the variable.
int id
Definition generatorVariable.h:19
virtual std::vector< std::string > contains(bool shouldReturn=false)=0
Generates code to perform a contains operation on the variable.
virtual std::vector< std::string > remove()=0
Generates code to perform a removal operation on the variable.
virtual std::vector< std::string > new_(bool inFunction=false)=0
Creates a new variable.
std::string typeString
Definition generatorVariable.h:21
virtual std::vector< std::string > genGlobalVars()=0
Generates global variable declarations for the variable type.
virtual std::vector< std::string > free()=0
Generates code to free or release resources associated with the variable.
Factory class for creating generator variables.
Definition generatorVariable.h:169
static std::vector< std::string > genGlobalVars(std::string type)
Generates global variable declarations for the specified variable type.
Definition generatorVariable.cpp:19
static std::vector< std::string > genIncludes(std::string type)
Generates include statements required for the specified variable type.
Definition generatorVariable.cpp:12
static std::vector< std::string > genParams(std::string type, std::string paramName, std::vector< GeneratorVariable * > varsParams)
Generates parameter handling code for functions using the specified variable type.
Definition generatorVariable.cpp:26
static std::string genTypeString(std::string type)
Generates a string representation of the variable type.
Definition generatorVariable.cpp:5
static GeneratorVariable * createVariable(std::string type, int identifier)
Creates a GeneratorVariable of the specified type.
Definition factory.cpp:3
static unsigned int var_counter
Definition generatorVariable.h:171