1#include "PrimitiveSetAP.h"
2#include "../../ECF/tree/Tree.h"
3#include "../../ECF/tree/Primitive.h"
10 PrimitiveSetAP::PrimitiveSetAP()
14 PrimitiveSetAP::~PrimitiveSetAP()
18 bool PrimitiveSetAP::initialize(StateP state)
23 PrimitiveP prim = (PrimitiveP)(
new Primitives::Add);
25 prim = (PrimitiveP)(
new Primitives::Sub);
27 prim = (PrimitiveP)(
new Primitives::Mul);
29 prim = (PrimitiveP)(
new Primitives::Div);
31 prim = (PrimitiveP)(
new Primitives::Sin);
33 prim = (PrimitiveP)(
new Primitives::Cos);
35 prim = (PrimitiveP)(
new Primitives::Pos);
37 prim = (PrimitiveP)(
new Primitives::Neg);
39 prim = (PrimitiveP)(
new Primitives::Max);
41 prim = (PrimitiveP)(
new Primitives::Min);
46 primIter->second->initialize(state);
49 mTypeNames_.insert(std::pair<std::string, Primitives::terminal_type>(
"DOUBLE", Primitives::Double));
50 mTypeNames_.insert(std::pair<std::string, Primitives::terminal_type>(
"INT", Primitives::Int));
51 mTypeNames_.insert(std::pair<std::string, Primitives::terminal_type>(
"BOOL", Primitives::Bool));
52 mTypeNames_.insert(std::pair<std::string, Primitives::terminal_type>(
"CHAR", Primitives::Char));
53 mTypeNames_.insert(std::pair<std::string, Primitives::terminal_type>(
"STRING", Primitives::String));
101 PrimitiveP PrimitiveSetAP::getTerminalByIndex(uint index) {
105 PrimitiveP PrimitiveSetAP::getGFSOneByIndex(uint index) {
109 PrimitiveP PrimitiveSetAP::getGFSTwoByIndex(uint index) {
113 PrimitiveP PrimitiveSetAP::getPrimitiveByIndex(uint index) {
128 int argNum = iter->second->getNumberOfArguments();
134 else if (argNum == 1) {
138 else if (argNum == 2) {
156 mTerminalSet_[terminalPrimitive->getName()] = terminalPrimitive;
163 uint PrimitiveSetAP::getFunctionSetSize()
165 return getGFSOneSetSize() + getGFSTwoSetSize();
168 uint PrimitiveSetAP::getGFSOneSetSize()
173 uint PrimitiveSetAP::getGFSTwoSetSize()
std::vector< PrimitiveP > GFSOneSet_
vector of active (actual used) functions
PrimitiveP getTerminalByName(std::string name)
Access terminal by name (active terminals only).
std::map< std::string, PrimitiveP > mAllPrimitives_
map of all registered primitive functions
std::vector< PrimitiveP > primitives_
vector of active (actual used) primitives
void addTerminal(PrimitiveP terminalPrimitive)
Add a terminal primitive to the set of active primitives.
std::vector< PrimitiveP > GFSTwoSet_
vector of active (actual used) functions
uint getTerminalSetSize()
Get the number of active terminals.
bool addFunction(std::string name)
Add a function primitive to the set of active primitives - if found by name in collection of all prim...
PrimitiveP getPrimitiveByName(std::string name)
Access primitive by name (active functions or terminals only).
PrimitiveP getGFSTwoByName(std::string name)
Access function by name (active functions only).
std::map< std::string, PrimitiveP > mPrimitiveSet_
map of active (actual used) primitives
uint getPrimitivesSize()
Get the number of active primitives (functions and terminals).
std::vector< PrimitiveP > terminalSet_
vector of active (actual used) terminals
std::map< std::string, PrimitiveP > mGFSTwoSet_
map of active (actual used) functions
std::map< std::string, PrimitiveP > mTerminalSet_
map of active (actual used) terminals
PrimitiveP getGFSOneByName(std::string name)
Access function by name (active functions only).
std::map< std::string, PrimitiveP > mGFSOneSet_
map of active (actual used) functions