X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=action.h;h=a0a1173e4cc0ce9ff6507f615e8c911ed529bb7c;hb=47c99f0a381056fb14d9871fc9f93536624df780;hp=4550771568b6b7a73d7286db32751d147126042d;hpb=84d555cb9ab1ce1bce673393a83d67e99d555d33;p=popboot.git diff --git a/action.h b/action.h index 4550771..a0a1173 100644 --- a/action.h +++ b/action.h @@ -1,13 +1,59 @@ #ifndef __ACTION_H__ #define __ACTION_H__ +#include +#include +#include + +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 { + + size_t hash = 0; + for (unsigned int i = 0; i < s.size(); ++i) + hash += static_cast(s[i]); + return hash + 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 { + + size_t hash = 0; + for (unsigned int i = 0; i < s.size(); ++i) + hash += static_cast(s[i]); + return hash + s.size(); + } + + }; +}; class Action { + public: + 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 Preconditions& preconditions() const; + const std::string& name() const; + int execute() const; protected: - std::string executable; - std::vector preconditions; - std::vector effects; - + std::string _name; + std::string _executable; + Preconditions _preconditions; + EffectsMap _effects; + static const Literals _empty; }; + #endif