X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=action.h;h=606857d8524ade62545f3455d8984e0dfbe4325a;hp=dd14e28798d0ab83b9370901085e983b1d570195;hb=716fc4e282ce52fe953867171c046acd3b614d3b;hpb=3dadaa088d9fff7ca05cbb297f3d7e88179faccb diff --git a/action.h b/action.h index dd14e28..606857d 100644 --- a/action.h +++ b/action.h @@ -5,28 +5,53 @@ #include #include -typedef std::vector literals; -typedef std::vector > preconditionsVector; -typedef __gnu_cxx::hash_map effectsMap; +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 name, preconditionsVector preconditions, effectsMap effects); + Action(std::string name, const Preconditions& preconditions, std::string executable, const EffectsMap& effects); Action(const Action& action); Action(){}; - const literals& effects(int value) const; - const literals& preconditions() const; + const Literals& effects(int value) const; + const Preconditions& preconditions() const; const std::string& name() const; - bool nextExecutable(); int execute() const; - void reset(); protected: - preconditionsVector::const_iterator _currentPrecondition; std::string _name; - preconditionsVector _preconditions; - effectsMap _effects; - static const literals _empty; + std::string _executable; + Preconditions _preconditions; + EffectsMap _effects; + static const Literals _empty; }; + #endif