X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=action.cpp;h=6e4b60785917cf7627c7ef1969b9621481c40022;hp=695c74fb71d4b7b6d8e764e186a730ad4354317f;hb=d385ba13a2ded8ce22b83c82d8a50c89a5d1d63e;hpb=eb5481635b31a8517a2f443ca7b414e4ff515028 diff --git a/action.cpp b/action.cpp index 695c74f..6e4b607 100644 --- a/action.cpp +++ b/action.cpp @@ -1,21 +1,41 @@ #include "action.h" +#include +#include +using namespace std; +using namespace __gnu_cxx; -Action::Action(std::string executable, literals preconditions, literals effects){ - _execututable = executable; +const Literals Action::_empty; + +Action::Action(std::string name,const Preconditions& preconditions, std::string executable,const EffectsMap& effects){ + _name = name; + _executable = executable; _preconditions = preconditions; _effects = effects; } +Action::Action(const Action& action){ + _name = action._name; + _preconditions = action._preconditions; + _effects = action._effects; + _executable = action._executable; +} -const literals Action::effects(){ - return _effects; +const Literals& Action::effects(int value) const{ + EffectsMap::const_iterator effects = _effects.find(value); + if (effects != _effects.end()) + return effects->second; + return _empty; } -const literals Action::preconditions(){ +const Preconditions& Action::preconditions() const{ return _preconditions; } -int Action::execute(){ +int Action::execute() const{ + cout << "Executing: " << _name << endl; + return system(_executable.c_str()); +} - return 0; +const string& Action::name() const{ + return _name; }