]> ruin.nu Git - popboot.git/blob - action.cpp
delete remaining actions
[popboot.git] / action.cpp
1 #include "action.h"
2 #include <cstdlib>
3 #include <iostream>
4 using namespace std;
5 using namespace __gnu_cxx;
6
7 const Literals Action::_empty;
8
9 Action::Action(std::string name,const Preconditions& preconditions, std::string executable,const EffectsMap& effects){
10         _name = name;
11         _executable = executable;
12         _preconditions = preconditions;
13         _effects = effects;
14 }
15
16 Action::Action(const Action& action){
17         _name = action._name;
18         _preconditions = action._preconditions;
19         _effects = action._effects;
20         _executable = action._executable;
21 }
22
23 const Literals& Action::effects(int value) const{
24         EffectsMap::const_iterator effects = _effects.find(value);
25         if (effects != _effects.end())
26                 return effects->second;
27         return _empty;
28 }
29
30 const Preconditions& Action::preconditions() const{
31         return _preconditions;
32 }
33
34 int Action::execute() const{
35         cout << "Executing: " << _name << endl;
36         return system(_executable.c_str());
37 }
38
39 const string& Action::name() const{
40         return _name;
41 }