]> ruin.nu Git - popboot.git/blobdiff - action.h
delete remaining actions
[popboot.git] / action.h
index 35119c35c7d245615e10ab6c857d0e02702d089e..606857d8524ade62545f3455d8984e0dfbe4325a 100644 (file)
--- a/action.h
+++ b/action.h
@@ -3,22 +3,55 @@
 
 #include <vector>
 #include <string>
+#include <ext/hash_map>
 
-typedef std::vector<std::string> literals;
+typedef std::vector<std::string> Literals;
+typedef __gnu_cxx::hash_map<std::string,bool> Preconditions;
+typedef __gnu_cxx::hash_map<int,Literals> EffectsMap;
 
+namespace __gnu_cxx {
+
+       template< typename CharT, typename Traits, typename Alloc >
+               struct hash< std::basic_string<CharT, Traits, Alloc> > {
+                       size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
+
+                               const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
+
+                               return c.hash(s.c_str(), s.c_str() + s.size());
+
+                       }
+
+               };
+
+       template< typename CharT, typename Traits, typename Alloc >
+               struct hash< const std::basic_string<CharT, Traits, Alloc> > { //yes you need this version aswell!
+
+                       size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
+
+                               const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
+
+                               return c.hash(s.c_str(), s.c_str() + s.size());
+                       }
+
+               };
+};
 class Action {
        public:
-               Action(std::string executable, literals preconditions, literals effects);
+               Action(std::string name, const Preconditions& preconditions, std::string executable, const EffectsMap& effects);
                Action(const Action& action);
                Action(){};
-               literals effects() const;
-               literals preconditions() const;
+               const Literals& effects(int value) const;
+               const Preconditions& preconditions() const;
+               const std::string& name() const;
                int execute() const;
 
        protected:
+               std::string _name;
                std::string _executable;
-               literals _preconditions;
-               literals _effects;
+               Preconditions _preconditions;
+               EffectsMap _effects;
+               static const Literals _empty;
 };
 
+
 #endif