X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=action.cpp;h=6e4b60785917cf7627c7ef1969b9621481c40022;hb=1e6333056c5f2887498b2b8c439171e526af94a3;hp=427440b268c182270bd358d248870de02c78a8be;hpb=498b277372ebab0008b97399d387285b36d88826;p=popboot.git diff --git a/action.cpp b/action.cpp index 427440b..6e4b607 100644 --- a/action.cpp +++ b/action.cpp @@ -1,28 +1,41 @@ #include "action.h" +#include #include using namespace std; +using namespace __gnu_cxx; -Action::Action(std::string executable, literals preconditions, literals effects){ +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){ - _executable = action._executable; + _name = action._name; _preconditions = action._preconditions; _effects = action._effects; + _executable = action._executable; } -literals Action::effects() const{ - 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; } -literals Action::preconditions() const{ +const Preconditions& Action::preconditions() const{ return _preconditions; } int Action::execute() const{ - cout << "Executing: " << _executable << endl; - return 0; + cout << "Executing: " << _name << endl; + return system(_executable.c_str()); +} + +const string& Action::name() const{ + return _name; }