Go to the documentation of this file.00001
00002
00003 #ifndef actasp_state_util_h__guard
00004 #define actasp_state_util_h__guard
00005
00006 #include <actasp/AspFluent.h>
00007
00008 #include <functional>
00009 #include <set>
00010
00011 namespace actasp {
00012
00013 template<typename FluentClass>
00014 struct StateComparator : public std::binary_function<std::set<FluentClass>,std::set<FluentClass>, bool> {
00015
00016 bool operator()(const std::set<FluentClass> &first,const std::set<FluentClass> &second) const {
00017
00018
00019 if (first.size() != second.size())
00020 return first.size() < second.size();
00021
00022
00023 typename std::set<FluentClass>::const_iterator thisV = first.begin();
00024 typename std::set<FluentClass>::const_iterator otherV = second.begin();
00025
00026 ActionComparator lessThen;
00027
00028 for (; thisV != first.end(); ++thisV, ++otherV) {
00029
00030 if (lessThen(*thisV , *otherV))
00031 return true;
00032 if (lessThen(*otherV , *thisV))
00033 return false;
00034 }
00035
00036
00037 return false;
00038
00039 }
00040
00041 };
00042
00043
00044
00045 struct stateEquals {
00046
00047 stateEquals(const std::set<AspFluent>& state) : state(state) {}
00048
00049 bool operator()(const std::set<AspFluent>& otherstate) const;
00050
00051 std::set<AspFluent> state;
00052 };
00053
00054
00055 }
00056
00057 #endif