6 #include <ext/hash_map>
9 typedef std::vector<std::string> Literals;
10 typedef __gnu_cxx::hash_map<std::string,bool> Preconditions;
11 typedef __gnu_cxx::hash_map<int,Literals> EffectsMap;
13 // These are needed to be able to use std::string as key in a hash_map.
15 template< typename CharT, typename Traits, typename Alloc >
16 struct hash< std::basic_string<CharT, Traits, Alloc> > {
17 size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
19 const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
21 return c.hash(s.c_str(), s.c_str() + s.size());
27 template< typename CharT, typename Traits, typename Alloc >
28 struct hash< const std::basic_string<CharT, Traits, Alloc> > { //yes you need this version aswell!
30 size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
32 const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
34 return c.hash(s.c_str(), s.c_str() + s.size());
41 * This class holds the information associated with an action.
42 * This is the name, the preconditions, the executable and the effects.
48 * @param name The name given to this action.
49 * @param preconditions The preconditions needed before execution of this action.
50 * @param executable The executable which will be executed.
51 * @param effects The effects which will be achieved after execution.
53 Action(std::string name, const Preconditions& preconditions, std::string executable, const EffectsMap& effects);
56 * Creates a copy of the given action.
58 Action(const Action& action);
60 * Creates an empty, non-functional, action.
65 * Returns the effects which will be achived if the action returns
68 const Literals& effects(int value) const;
71 * Returns the preconditions needed before execution of this action.
73 const Preconditions& preconditions() const;
75 * Returns the name of this action.
77 const std::string& name() const;
79 * Executes this action.
80 * @return the returnvalue of the execution. Can be used to find out the effects achieved.
85 //! The name of the action.
87 //! The executable which can be executed.
88 std::string _executable;
89 //! The preconditions needed before execution.
90 Preconditions _preconditions;
91 //! The effects which can be achieved.
93 //! An empty list of effects which will be returned if the returnvalue was not found in _effects.
94 static const Literals _empty;