Empirical
|
InstLib maintains a set of instructions for use in virtual hardware. More...
#include <InstLib.h>
Classes | |
struct | InstDef |
Public Types | |
using | hardware_t = HARDWARE_T |
using | inst_t = typename hardware_t::inst_t |
using | genome_t = emp::vector< inst_t > |
using | arg_t = ARG_T |
using | fun_t = std::function< void(hardware_t &, const inst_t &)> |
using | inst_properties_t = std::unordered_set< std::string > |
Public Member Functions | |
InstLib () | |
Default Constructor. More... | |
InstLib (const InstLib &)=default | |
Copy Constructor. More... | |
InstLib (InstLib &&)=default | |
Move Constructor. More... | |
~InstLib () | |
Destructor. More... | |
InstLib & | operator= (const InstLib &)=default |
Copy Operator. More... | |
InstLib & | operator= (InstLib &&)=default |
Move Operator. More... | |
const std::string & | GetName (size_t id) const |
Return the name associated with the specified instruction ID. More... | |
const fun_t & | GetFunction (size_t id) const |
Return the function associated with the specified instruction ID. More... | |
size_t | GetNumArgs (size_t id) const |
Return the number of arguments expected for the specified instruction ID. More... | |
const std::string & | GetDesc (size_t id) const |
Return the provided description for the provided instruction ID. More... | |
ScopeType | GetScopeType (size_t id) const |
What type of scope does this instruction state? ScopeType::NONE is default. More... | |
size_t | GetScopeArg (size_t id) const |
If this instruction alters scope, identify which argument does so. More... | |
const inst_properties_t & | GetProperties (size_t id) const |
Return the set of properties for the provided instruction ID. More... | |
bool | HasProperty (size_t id, std::string property) const |
Does the given instruction ID have the given property value? More... | |
size_t | GetSize () const |
Get the number of instructions in this set. More... | |
bool | IsInst (const std::string name) const |
size_t | GetID (const std::string &name) const |
Return the ID of the instruction that has the specified name. More... | |
arg_t | GetArg (const std::string &name) |
Return the argument value associated with the provided keyword. More... | |
void | AddInst (const std::string &name, const fun_t &fun_call, size_t num_args=0, const std::string &desc="", ScopeType scope_type=ScopeType::NONE, size_t scope_arg=(size_t)-1, const inst_properties_t &inst_properties=inst_properties_t()) |
Add a new instruction to the set. More... | |
void | AddArg (const std::string &name, arg_t value) |
Specify a keyword and arg value. More... | |
void | ProcessInst (hardware_t &hw, const inst_t &inst) const |
Process a specified instruction in the provided hardware. More... | |
template<typename IN_HW > | |
void | ProcessInst (emp::Ptr< IN_HW > hw, const inst_t &inst) const |
Process a specified instruction on hardware that can be converted to the correct type. More... | |
void | WriteGenome (const genome_t &genome, std::ostream &os=std::cout) const |
Write out a full genome to the provided ostream. More... | |
void | ReadInst (genome_t &genome, std::string info) const |
Read the instruction in the provided info and append it to the provided genome. More... | |
Static Public Member Functions | |
static constexpr char | GetSymbol (size_t id) |
Retrieve a unique letter associared with the specified instruction ID. More... | |
static constexpr size_t | GetID (char symbol) |
Return the ID of the instruction associated with the specified symbol. More... | |
Protected Attributes | |
emp::vector< InstDef > | inst_lib |
Full definitions for instructions. More... | |
emp::vector< fun_t > | inst_funs |
Map of instruction IDs to their functions. More... | |
std::map< std::string, size_t > | name_map |
How do names link to instructions? More... | |
std::map< std::string, arg_t > | arg_map |
How are different arguments named? More... | |
InstLib maintains a set of instructions for use in virtual hardware.
HARDWARE_T | Type of the virtual hardware class to track instructions. |
ARG_T | What types of arguments are associated with instructions. |
ARG_COUNT | Max number of arguments on an instruction. |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::arg_t = ARG_T |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::fun_t = std::function<void(hardware_t &, const inst_t &)> |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::genome_t = emp::vector<inst_t> |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::hardware_t = HARDWARE_T |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::inst_properties_t = std::unordered_set<std::string> |
using emp::InstLib< HARDWARE_T, ARG_T, ARG_COUNT >::inst_t = typename hardware_t::inst_t |
|
inline |
Default Constructor.
|
default |
Copy Constructor.
|
default |
Move Constructor.
|
inline |
Destructor.
|
inline |
Specify a keyword and arg value.
|
inline |
Add a new instruction to the set.
name | A unique string name for this instruction. |
fun_call | The function that should be called when this instruction is executed. |
num_args | How many arguments does this function require? (default=0) |
desc | A description of how this function operates. (default="") |
scope_type | Type of scope does this instruction creates. (default=ScopeType::NONE) |
scope_arg | If instruction changes scope, which argument specified new scope? (defualt=-1) |
|
inline |
Return the argument value associated with the provided keyword.
|
inline |
Return the provided description for the provided instruction ID.
|
inline |
Return the function associated with the specified instruction ID.
|
inline |
Return the ID of the instruction that has the specified name.
|
inlinestatic |
Return the ID of the instruction associated with the specified symbol.
|
inline |
Return the name associated with the specified instruction ID.
|
inline |
Return the number of arguments expected for the specified instruction ID.
|
inline |
Return the set of properties for the provided instruction ID.
|
inline |
If this instruction alters scope, identify which argument does so.
|
inline |
What type of scope does this instruction state? ScopeType::NONE is default.
|
inline |
Get the number of instructions in this set.
|
inlinestatic |
Retrieve a unique letter associared with the specified instruction ID.
|
inline |
Does the given instruction ID have the given property value?
|
inline |
|
default |
Copy Operator.
|
default |
Move Operator.
|
inline |
Process a specified instruction in the provided hardware.
|
inline |
Process a specified instruction on hardware that can be converted to the correct type.
|
inline |
Read the instruction in the provided info and append it to the provided genome.
|
inline |
Write out a full genome to the provided ostream.
|
protected |
How are different arguments named?
|
protected |
Map of instruction IDs to their functions.
|
protected |
Full definitions for instructions.
|
protected |
How do names link to instructions?