X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=action.h;h=606857d8524ade62545f3455d8984e0dfbe4325a;hp=9b3c9276a105ab8366324c63839ffde92d34d70f;hb=d385ba13a2ded8ce22b83c82d8a50c89a5d1d63e;hpb=e26fd7b3195576b25ffe51253a391b53f412a650 diff --git a/action.h b/action.h index 9b3c927..606857d 100644 --- a/action.h +++ b/action.h @@ -3,23 +3,55 @@ #include #include +#include -typedef std::vector literals; +typedef std::vector Literals; +typedef __gnu_cxx::hash_map Preconditions; +typedef __gnu_cxx::hash_map EffectsMap; +namespace __gnu_cxx { + + template< typename CharT, typename Traits, typename Alloc > + struct hash< std::basic_string > { + size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(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 > { //yes you need this version aswell! + + size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(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(){}; - const literals& effects() const; - const literals& preconditions() const; - const std::string& executable() 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