|
GEGELATI
|
The Program class contains a list of program lines that can be executed within a well defined Environment. More...
#include <program.h>
Public Member Functions | |
| Program (const Environment &e, bool actProgram) | |
| Main constructor of the Program. | |
| Program (const Program &other) | |
| Copy constructor of the Program. | |
| Program (const Program &other, bool actProgram) | |
| Copy constructor of the Program. | |
| Program & | operator= (const Program &other)=delete |
| ~Program () | |
| Destructor for the Program class. | |
| Line & | addNewLine () |
| Add a new line to the Program with only 0 bits. | |
| Line & | addNewLine (const uint64_t idx) |
| Add a new line to the Program with only 0 bits. | |
| void | addNewLine (Line newLine) |
| Add a new line to the Program at the end of the program. | |
| void | clearIntrons () |
| Clear all intron instructions in the Program. | |
| void | removeLine (const uint64_t idx) |
| Remove a Line from the Program. | |
| void | swapLines (const uint64_t idx0, const uint64_t idx1) |
| Swap two existing lines from the Program. | |
| const Environment & | getEnvironment () const |
| Get the environment associated to the Program at construction. | |
| size_t | getNbLines () const |
| Get the number of lines in the Program. | |
| const Line & | getLine (uint64_t index) const |
| Get a const ref to a Line of the Program. | |
| Line & | getLine (uint64_t index) |
| Get a non-const ref to a Line of the Program. | |
| bool | isIntron (uint64_t index) const |
| Checks whether a Line at the given index is an intron. | |
| bool | isActionProgram () const |
| Checks wether the current program is or not an action program. | |
| uint64_t | identifyIntrons () |
| Scan the Line of the Program to identify introns. | |
| Data::ConstantHandler & | getConstantHandler () |
| get the constantHandler object of the Program | |
| const Data::ConstantHandler & | cGetConstantHandler () const |
| get a const reference to the constantHandler object of the Program | |
| const Data::Constant | getConstantAt (size_t index) const |
| Get the value of a constant at a given index. | |
| bool | hasIdenticalBehavior (const Program &other) const |
| Check if two Program have the same behavior. | |
| uint64_t | getProgramID () const |
| Get the unique identifier of the Program. | |
| virtual void | setProgramID (uint64_t newID) |
| Set a new unique identifier to the Program. | |
Static Public Member Functions | |
| static uint64_t | getProgramIDCounter () |
| Get the current value of the program ID counter. | |
Protected Member Functions | |
| Program ()=delete | |
| Delete the default constructor. | |
Static Protected Member Functions | |
| static uint64_t | incrementeCounter () |
| Incremente the program ID counter and return the new value. | |
| static void | resetProgramIDCounter () |
| Reset the program ID counter. | |
Protected Attributes | |
| const Environment & | environment |
| Environment within which the Program will be executed. | |
| bool | actionProgram |
| Boolean indicating if true that the program is an action program, if false that it is a context program. | |
| std::vector< std::pair< Line *, bool > > | lines |
| Lines of the program and intron property. | |
| Data::ConstantHandler | constants |
| Constants of the Program. | |
| uint64_t | programID |
| Unique identifier of the Program. | |
Friends | |
| struct | ::CounterReset |
The Program class contains a list of program lines that can be executed within a well defined Environment.
|
inline |
Main constructor of the Program.
| [in] | e | the reference to the Environment that will be referenced |
| [in] | actProgram | boolean specifying if the program is action or context in the Program attributes. |
|
inline |
|
inline |
| Program::Program::~Program | ( | ) |
| Program::Line & Program::Program::addNewLine | ( | ) |
| Program::Line & Program::Program::addNewLine | ( | const uint64_t | idx | ) |
Add a new line to the Program with only 0 bits.
The new line is inserted at the given position of the program.
| [in] | idx | the position at which the line should be inserted. |
| std::out_of_range | if the given position is beyond the end of the Program. |
| void Program::Program::addNewLine | ( | Line | newLine | ) |
| const Data::ConstantHandler & Program::Program::cGetConstantHandler | ( | ) | const |
get a const reference to the constantHandler object of the Program
This method gives a const reference to the constantHandler associated with the program
| void Program::Program::clearIntrons | ( | ) |
Clear all intron instructions in the Program.
All introns lines from the Program are removed by this method. The behavior of the Program should not be modified after a call to this function.
Introns should have been identified before calling this methos, as this method does NOT call the identifyIntrons method.
| const Data::Constant Program::Program::getConstantAt | ( | size_t | index | ) | const |
Get the value of a constant at a given index.
Although this method is not required as the data is accessible from the constantHandler, it allows a shortcut and add readability.
| [in] | index | the position at which we access the constant |
| Data::ConstantHandler & Program::Program::getConstantHandler | ( | ) |
get the constantHandler object of the Program
This method gives a reference to the constantHandler associated with the program
| const Environment & Program::Program::getEnvironment | ( | ) | const |
Get the environment associated to the Program at construction.
| Program::Line & Program::Program::getLine | ( | uint64_t | index | ) |
| const Program::Line & Program::Program::getLine | ( | uint64_t | index | ) | const |
| size_t Program::Program::getNbLines | ( | ) | const |
| uint64_t Program::Program::getProgramID | ( | ) | const |
|
static |
Get the current value of the program ID counter.
This method is mainly used for testing purpose to ensure that program IDs are predictable.
| bool Program::Program::hasIdenticalBehavior | ( | const Program & | other | ) | const |
Check if two Program have the same behavior.
Two Program have the same behaviour if their sequence of non-intron Lines are strictly identical (i.e. same instructions and operands, in the same order, and used Constant with identical values).
| [in] | other | the Program whose behavior is compared. |
| uint64_t Program::Program::identifyIntrons | ( | ) |
| bool Program::Program::isActionProgram | ( | ) | const |
Checks wether the current program is or not an action program.
| bool Program::Program::isIntron | ( | uint64_t | index | ) | const |
| void Program::Program::removeLine | ( | const uint64_t | idx | ) |
|
staticprotected |
Reset the program ID counter.
This method set the ID counter to a new value. It can quickly lead to segmentation fault if not used carefully.
|
virtual |
| void Program::Program::swapLines | ( | const uint64_t | idx0, |
| const uint64_t | idx1 ) |
Swap two existing lines from the Program.
| [in] | idx0 | the index of the first line to swap. |
| [in] | idx1 | the index of the second line to swap. |
| std::out_of_range | if any of the two index is too large. |
|
protected |
Boolean indicating if true that the program is an action program, if false that it is a context program.
An action program is a program used for taking continuous actions, in contrast with classic, or context programs, that output a bid. An Action program source must be a TPGAction.
|
protected |
Constants of the Program.
A Program contains a set of constants in a dedicated Data::DataHandler
|
protected |
Lines of the program and intron property.
Each element of this vector stores a pointer to a Line, and a boolean value indicating whether this Line is an Intron whithin the program.
Introns are Lines of the program that do not contribute to its final result, stored in the first register. Hence, skipping these lines during a program execution can speed up the Program execution.