AspLaw.h
Go to the documentation of this file.
00001 #ifndef actasp_AspLaw_h__guard
00002 #define actasp_AspLaw_h__guard
00003 
00004 #include <vector>
00005 #include <string>
00006 
00007 namespace actasp {
00008 
00009 template<typename AtomType>
00010 struct AspLaw {
00011   
00012   AspLaw() : head(), body() {}
00013   
00014   
00015   AspLaw& operator<< (AtomType fluent) throw (){
00016     body.push_back(fluent);
00017     return *this;
00018   }
00019   
00020   bool operator== (const AspLaw<AtomType> other) const throw () {
00021     if (other.head.size() != this->head.size())
00022       return false;
00023     if (other.body.size() != this->body.size())
00024       return false;
00025     typename std::vector<AtomType>::const_iterator otherHead = other.head.begin();
00026     typename std::vector<AtomType>::const_iterator thisHead = this->head.begin();
00027     for (; otherHead!=other.head.end(); ++otherHead) {
00028       std::string otherString = otherHead->toString(0);
00029       std::string thisString = thisHead->toString(0);
00030       if (otherString.compare(thisString)!=0)
00031         return false;
00032       ++thisHead;
00033     }
00034 
00035     typename std::vector<AtomType>::const_iterator otherBody = other.body.begin();
00036     typename std::vector<AtomType>::const_iterator thisBody = this->body.begin();
00037     for (; otherBody!=other.body.end(); ++otherBody) {
00038       std::string otherString = otherBody->toString(0);
00039       std::string thisString = thisBody->toString(0);
00040       if (otherString.compare(thisString)!=0)
00041         return false;
00042       ++thisBody;
00043     }
00044 
00045     //at this point:
00046     return true; 
00047   }
00048   
00049   std::vector<AtomType> head;
00050   std::vector<AtomType> body;
00051 
00052 };
00053 
00054 }
00055 
00056 #endif


bwi_kr_execution
Author(s): Matteo Leonetti, Piyush Khandelwal
autogenerated on Thu Jun 6 2019 17:57:36