38#ifndef PROGRAMENGINE_H
39#define PROGRAMENGINE_H
41#include "data/primitiveTypeArray.h"
42#include "data/untypedSharedPtr.h"
43#include "program/program.h"
73 std::vector<std::reference_wrapper<const Data::DataHandler>>
77 std::vector<std::reference_wrapper<const Data::DataHandler>>
127 const std::vector<std::reference_wrapper<T>>& dataSrc)
133 std::is_convertible<T&, const Data::DataHandler&>::value);
137 if (prog.getEnvironment().getNbConstant() > 0) {
139 prog.cGetConstantHandler());
144 for (std::reference_wrapper<T> data : dataSrc) {
194 const std::vector<std::reference_wrapper<T>>& dataSrc);
202 const std::vector<std::reference_wrapper<const Data::DataHandler>>&
257 std::vector<Data::UntypedSharedPtr>& operands)
const;
289 const std::vector<std::reference_wrapper<T>>& dataSrc)
292 static_assert(std::is_convertible<T&, const Data::DataHandler&>::value);
303 for (
size_t idx = 0; idx < this->
dataSources.size(); idx++) {
The Environment class contains all information needed to execute a Program.
Definition: environment.h:84
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources() const
Get the DataHandler of the Environment.
Definition: environment.cpp:203
size_t getNbConstant() const
Get the number of constants used by programs.
Definition: environment.cpp:172
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getFakeDataSources() const
Definition: environment.cpp:209
This abstract class is the base class for any instruction to be used in a Program.
Definition: instruction.h:59
This abstract class is the base class for any program engine (generation and execution)
Definition: programEngine.h:54
const Program * program
Definition: programEngine.h:58
virtual void processLine()=0
operator parenthesis used when iterating through the program with the function iterationThroughtProgr...
ProgramEngine(const Environment &env)
Constructor of the class.
Definition: programEngine.h:92
uint64_t programCounter
Program counter of the execution engine.
Definition: programEngine.h:81
const void fetchCurrentOperands(std::vector< Data::UntypedSharedPtr > &operands) const
Get the operands for the current Instruction.
Definition: programEngine.cpp:124
void setDataSources(const std::vector< std::reference_wrapper< T > > &dataSrc)
Method for changing the dataSources on which the Program will be executed.
Definition: programEngine.h:288
const bool next()
Increments the programCounter and checks for the end of the Program.
Definition: programEngine.cpp:96
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources() const
Get the DataHandler of the ProgramExecutionEngine.
Definition: programEngine.cpp:91
virtual void iterateThroughtProgram(const bool ignoreException)
Function that iterates through the lines of the program and execute the function processLine().
Definition: programEngine.cpp:161
std::vector< std::reference_wrapper< const Data::DataHandler > > dataScsConstsAndRegs
Data sources (including registers) used in the Program.
Definition: programEngine.h:78
uint64_t getOperandLocation(uint64_t idxOp) const
Get the location for the current Instruction.
Definition: programEngine.cpp:144
void setProgram(const Program &prog)
Method for changing the Program executed by a ProgramExecutionEngin.
Definition: programEngine.cpp:41
std::vector< std::reference_wrapper< const Data::DataHandler > > dataSources
Data sources from the environment used for archiving a program.
Definition: programEngine.h:74
ProgramEngine()=delete
Default constructor is deleted.
const Line & getCurrentLine() const
Get the Program Line corresponding to the current programCounter.
Definition: programEngine.cpp:107
Data::PrimitiveTypeArray< double > registers
Registers used for the Program execution.
Definition: programEngine.h:65
const Instructions::Instruction & getCurrentInstruction() const
Get the Instruction corresponding to the current programCounter.
Definition: programEngine.cpp:112
ProgramEngine(const Program &prog, const std::vector< std::reference_wrapper< T > > &dataSrc)
Constructor of the class.
Definition: programEngine.h:126
ProgramEngine(const Program &prog)
Constructor of the class.
Definition: programEngine.h:162
const Data::ConstantHandler & cGetConstantHandler() const
get a const reference to the constantHandler object of the Program
Definition: program.cpp:203
const Environment & getEnvironment() const
Get the environment associated to the Program at construction.
Definition: program.cpp:110