#include "action.h"
+#include <iostream>
+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, preconditionsVector preconditions, effectsMap effects){
+ _name = name;
_preconditions = preconditions;
_effects = effects;
+ _currentPrecondition = _preconditions.begin();
}
-
-const literals Action::effects(){
- return _effects;
+Action::Action(const Action& action){
+ _name = action._name;
+ _preconditions = action._preconditions;
+ _effects = action._effects;
}
-const literals Action::preconditions(){
- return _preconditions;
+const literals& Action::effects(int value) const{
+ effectsMap::const_iterator effects = _effects.find(value);
+ if (effects != _effects.end())
+ return effects->second;
+ return _empty;
}
-int Action::execute(){
+const literals& Action::preconditions() const{
+ return _currentPrecondition->second;
+}
+int Action::execute() const{
+ cout << "Executing: " << _currentPrecondition->first << endl;
return 0;
}
+
+const string& Action::name() const{
+ return _name;
+}
+
+bool Action::nextExecutable(){
+ if (++_currentPrecondition != _preconditions.end())
+ return true;
+ return false;
+}
+
+void Action::reset(){
+ _currentPrecondition = _preconditions.begin();
+}