39#ifndef PROGRAMENGINE_H
40#define PROGRAMENGINE_H
42#include "data/primitiveTypeArray.h"
43#include "data/untypedSharedPtr.h"
44#include "program/program.h"
74 std::vector<std::reference_wrapper<const Data::DataHandler>>
78 std::vector<std::reference_wrapper<const Data::DataHandler>>
128 const std::vector<std::reference_wrapper<T>>& dataSrc)
130 registers{prog.getEnvironment().getParams().nbRegisters},
135 std::is_convertible<T&, const Data::DataHandler&>::value);
139 if (prog.getEnvironment().getParams().nbProgramConstant > 0) {
141 prog.cGetConstantHandler());
146 for (std::reference_wrapper<T> data : dataSrc) {
196 const std::vector<std::reference_wrapper<T>>& dataSrc);
204 const std::vector<std::reference_wrapper<const Data::DataHandler>>&
259 std::vector<Data::UntypedSharedPtr>& operands)
const;
301 const std::vector<std::reference_wrapper<T>>& dataSrc)
304 static_assert(std::is_convertible<T&, const Data::DataHandler&>::value);
317 for (
size_t idx = 0; idx < this->
dataSources.size(); idx++) {
DataHandler for 2D arrays of primitive types.
Definition primitiveTypeArray2D.h:69
The Environment class contains all information needed to execute a Program.
Definition environment.h:86
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources() const
Get the DataHandler of the Environment.
Definition environment.cpp:204
const Learn::LearningParameters & getParams() const
Get the instance of parameters used.
Definition environment.cpp:168
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getFakeDataSources() const
Definition environment.cpp:210
This abstract class is the base class for any instruction to be used in a Program.
Definition instruction.h:61
This abstract class is the base class for any program engine (generation and execution)
Definition programEngine.h:55
const Program * program
Definition programEngine.h:59
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:93
uint64_t programCounter
Program counter of the execution engine.
Definition programEngine.h:82
const void fetchCurrentOperands(std::vector< Data::UntypedSharedPtr > &operands) const
Get the operands for the current Instruction.
Definition programEngine.cpp:126
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:300
const bool next()
Increments the programCounter and checks for the end of the Program.
Definition programEngine.cpp:98
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources() const
Get the DataHandler of the ProgramExecutionEngine.
Definition programEngine.cpp:93
virtual void iterateThroughtProgram(const bool ignoreException)
Function that iterates through the lines of the program and execute the function processLine().
Definition programEngine.cpp:167
virtual std::vector< double > getRegisterValues(uint64_t nbRegisters)
Return the current registers value of the program indicated.
Definition programEngine.cpp:194
std::vector< std::reference_wrapper< const Data::DataHandler > > dataScsConstsAndRegs
Data sources (including registers) used in the Program.
Definition programEngine.h:79
uint64_t getOperandLocation(uint64_t idxOp) const
Get the location for the current Instruction.
Definition programEngine.cpp:150
void setProgram(const Program &prog)
Method for changing the Program executed by a ProgramExecutionEngin.
Definition programEngine.cpp:43
std::vector< std::reference_wrapper< const Data::DataHandler > > dataSources
Data sources from the environment used for archiving a program.
Definition programEngine.h:75
ProgramEngine()=delete
Default constructor is deleted.
const Line & getCurrentLine() const
Get the Program Line corresponding to the current programCounter.
Definition programEngine.cpp:109
Data::PrimitiveTypeArray< double > registers
Registers used for the Program execution.
Definition programEngine.h:66
const Instructions::Instruction & getCurrentInstruction() const
Get the Instruction corresponding to the current programCounter.
Definition programEngine.cpp:114
ProgramEngine(const Program &prog, const std::vector< std::reference_wrapper< T > > &dataSrc)
Constructor of the class.
Definition programEngine.h:127
ProgramEngine(const Program &prog)
Constructor of the class.
Definition programEngine.h:164
const Data::ConstantHandler & cGetConstantHandler() const
get a const reference to the constantHandler object of the Program
Definition program.cpp:236
const Environment & getEnvironment() const
Get the environment associated to the Program at construction.
Definition program.cpp:126
size_t nbProgramConstant
Number of Constants available in a program.
Definition learningParameters.h:144