X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=action.h;h=32fbcb986ad912d43b1c675d878f298ebce5eaf9;hb=921850c029bdaad568b0e40969b0805df785b72a;hp=35119c35c7d245615e10ab6c857d0e02702d089e;hpb=dc49c0c521090f0eb4b9692b25a129537c07e19e;p=popboot.git diff --git a/action.h b/action.h index 35119c3..32fbcb9 100644 --- a/action.h +++ b/action.h @@ -3,22 +3,56 @@ #include #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(){}; - 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