]> ruin.nu Git - popboot.git/blob - planner.h
Might be good to have a destructor too
[popboot.git] / planner.h
1 #ifndef __PLANNER_H__
2 #define __PLANNER_H__
3
4 #include <ext/hash_map>
5 #include <vector>
6 #include "action.h"
7
8 class Node;
9
10
11
12 namespace __gnu_cxx {
13
14     template< typename CharT, typename Traits, typename Alloc >
15     struct hash< std::basic_string<CharT, Traits, Alloc> > {
16         size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
17             
18            const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
19            
20            return c.hash(s.c_str(), s.c_str() + s.size());
21
22 }
23
24     };
25
26     template< typename CharT, typename Traits, typename Alloc >
27     struct hash< const std::basic_string<CharT, Traits, Alloc> > { //yes you need this version aswell!
28
29 size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
30        
31           const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
32       
33           return c.hash(s.c_str(), s.c_str() + s.size());
34         }
35
36     };
37 };
38
39 class Planner {
40         public:
41                 Planner(std::vector<Action> actions, literals init, literals goal);
42                 ~Planner();
43
44                 void execute();
45
46         protected:
47
48                 void makePlan(Node* node);
49                 void addNode(Node* node);
50                 
51                 Node* _start;
52                 __gnu_cxx::hash_map<std::string,Node*> _addedNodes;
53                 __gnu_cxx::hash_map<std::string,Action> _actions;
54 };
55 #endif