00001 #ifndef actasp_ReplanningActionExecutor_h__guard 00002 #define actasp_ReplanningActionExecutor_h__guard 00003 00004 00005 #include <actasp/ActionExecutor.h> 00006 00007 #include <stdexcept> 00008 #include <list> 00009 #include <map> 00010 00011 namespace actasp { 00012 00013 class AspKR; 00014 class Planner; 00015 class Action; 00016 class PlanningObserver; 00017 00018 class ReplanningActionExecutor : public ActionExecutor { 00019 00020 public: 00021 00022 ReplanningActionExecutor(actasp::AspKR* reasoner, 00023 actasp::Planner *planner, 00024 const std::map<std::string, Action * > &actionMap 00025 ) throw (std::invalid_argument); 00026 00027 using ActionExecutor::setGoal; 00028 void setGoal(const std::vector<actasp::AspRule>& goalRules) throw(); 00029 00030 bool goalReached() const throw() { 00031 return isGoalReached; 00032 } 00033 00034 bool failed() const throw() { 00035 return hasFailed; 00036 } 00037 00038 void executeActionStep(); 00039 00040 void addExecutionObserver(ExecutionObserver *observer) throw(); 00041 void removeExecutionObserver(ExecutionObserver *observer) throw(); 00042 00043 void addPlanningObserver(PlanningObserver *observer) throw(); 00044 void removePlanningObserver(PlanningObserver *observer) throw(); 00045 00046 ~ReplanningActionExecutor(); 00047 00048 00049 private: 00050 std::vector<actasp::AspRule> goalRules; 00051 bool isGoalReached; 00052 bool hasFailed; 00053 std::map<std::string, Action * > actionMap; 00054 00055 std::list<Action *> plan; 00056 unsigned int actionCounter; 00057 bool newAction; 00058 00059 AspKR* kr; 00060 Planner *planner; 00061 00062 std::list<ExecutionObserver*> executionObservers; 00063 std::list<PlanningObserver*> planningObservers; 00064 00065 void computePlan(); 00066 00067 00068 }; 00069 00070 00071 } 00072 #endif