X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=planner.h;fp=planner.h;h=fc49df9d5659e42646fa307e034c4c59b6ec58b4;hp=55d572877e61641cbdce15d0186bee9b4da9c235;hb=44054bc3e498f77571a9448d0cea201fcca6bb0f;hpb=92aca829cc32e9e4d5965259bd565e727469358d diff --git a/planner.h b/planner.h index 55d5728..fc49df9 100644 --- a/planner.h +++ b/planner.h @@ -12,20 +12,56 @@ class Node; class Planner { public: + /** + * Creates a plan given the input actions, initial state and goal. + * + * @param actions A list of actions which will be used to reach the goal. + * @param init The initial state which the plan will start from. + * @param goal The goal state which the plan will try to reach. + */ Planner(std::vector actions, Literals init, Literals goal); + + /** + * Deletes all the remaining nodes and actions. + */ ~Planner(); + /** + * Executes the plan. + * Creates new threads for execution of each action. + * + * If any action fail in some way, this method will try to replan and + * recursively call itself. + */ void execute(); protected: + /** + * This method does the actual planning. Given the input node it will + * try to find all preconditions and create links from parent nodes + * to this node and, if the precondition did not have a node associated + * with it, create a new and recursively call this method for the newly + * created node. + * + * @param node The node which this method will find parent nodes for. + */ void makePlan(Node* node); + + /** + * Adds this node to the internal map and vector. + */ void addNode(Node* node); + + /** + * This method goes through the executed nodes and then calls + * executeChildren for these nodes. + */ void executePlan(); + int executeChildren(Node* node); void replan(); int cleanupExecution(); - int executeChildren(Node* node); sem_t _nodes; sem_t _list;