]> ruin.nu Git - popboot.git/blobdiff - action.cpp
some done, need parser
[popboot.git] / action.cpp
index 3e9cddf692163b41a515655c33e37ef29bffd270..87947ca054bb6684bfe9e23e006a16ff94df7c6c 100644 (file)
@@ -1,26 +1,39 @@
 #include "action.h"
+#include <iostream>
+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;
 }
 
-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;
 }
+
+const string& Action::name() const{
+       return _name;
+}