]> ruin.nu Git - popboot.git/blob - action.h
delete remaining actions
[popboot.git] / action.h
1 #ifndef __ACTION_H__
2 #define __ACTION_H__
3
4 #include <vector>
5 #include <string>
6 #include <ext/hash_map>
7
8 typedef std::vector<std::string> Literals;
9 typedef __gnu_cxx::hash_map<std::string,bool> Preconditions;
10 typedef __gnu_cxx::hash_map<int,Literals> EffectsMap;
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 class Action {
39         public:
40                 Action(std::string name, const Preconditions& preconditions, std::string executable, const EffectsMap& effects);
41                 Action(const Action& action);
42                 Action(){};
43                 const Literals& effects(int value) const;
44                 const Preconditions& preconditions() const;
45                 const std::string& name() const;
46                 int execute() const;
47
48         protected:
49                 std::string _name;
50                 std::string _executable;
51                 Preconditions _preconditions;
52                 EffectsMap _effects;
53                 static const Literals _empty;
54 };
55
56
57 #endif