7 using namespace __gnu_cxx;
9 const Literals Action::_empty;
11 Action::Action(std::string name,const Preconditions& preconditions, std::string executable,const EffectsMap& effects){
13 _executable = executable;
14 _preconditions = preconditions;
18 Action::Action(const Action& action){
20 _preconditions = action._preconditions;
21 _effects = action._effects;
22 _executable = action._executable;
25 const Literals& Action::effects(int value) const{
26 EffectsMap::const_iterator effects = _effects.find(value);
27 if (effects != _effects.end())
28 return effects->second;
32 const Preconditions& Action::preconditions() const{
33 return _preconditions;
36 int Action::execute() const{
37 cout << "Executing: " << _name << endl;
38 //return system(_executable.c_str());
40 if (proc == -1) return proc;
44 //execl("/bin/sh", "-c", _executable.c_str(), (char*) NULL);
45 retval = system(_executable.c_str());
46 _exit(WEXITSTATUS(retval));
48 waitpid(proc,&retval,0);
49 cout << "Done executing: " << _name << ", returnvalue: " << WEXITSTATUS(retval) << endl;
50 return WEXITSTATUS(retval);
53 const string& Action::name() const{