]> ruin.nu Git - popboot.git/blob - planner.h
c74d536b5e5d03ac7f439921bd06a6793c2b715b
[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
43         protected:
44
45                 void makePlan(Node* node);
46                 void addNode(Node* node);
47                 
48                 Node* _start;
49                 __gnu_cxx::hash_map<std::string,Node*> _addedNodes;
50                 __gnu_cxx::hash_map<std::string,Action> _actions;
51 };
52 #endif