cnode/EqLeaf.h
00001 /*
00002  * EqLeaf.h
00003  *
00004  *  Created on: Sep 1, 2008
00005  *      Author: tdillig
00006  */
00007 
00008 #ifndef EQLEAF_H_
00009 #define EQLEAF_H_
00010 #include "CNode.h"
00011 #include "Leaf.h"
00012 #include <string>
00013 #include "term.h"
00014 using namespace std;
00015 
00016 class VarMap;
00017 class Term;
00018 
00019 class EqLeaf:public Leaf{
00020         friend class boost::serialization::access;
00021 private:
00022         Term* lhs;
00023         Term* rhs;
00024         template<class Archive>
00025         void save(Archive & ar, const unsigned int version) const
00026         {
00027                 ar & boost::serialization::base_object<Leaf>(*this);
00028                 ar & lhs;
00029                 ar & rhs;
00030         }
00031         template<class Archive>
00032         void load(Archive & ar, const unsigned int version)
00033         {
00034                 ar & boost::serialization::base_object<Leaf>(*this);
00035                 ar & lhs;
00036                 ar & rhs;
00037 
00038                 lhs = Term::get_term_nodelete(lhs);
00039                 rhs = Term::get_term_nodelete(rhs);
00040                 /*if(lhs > rhs)
00041                 {
00042                         Term* t = lhs;
00043                         lhs = rhs;
00044                         rhs = t;
00045                 }*/
00046 
00047                 compute_hash_code();
00048 
00049         }
00050         BOOST_SERIALIZATION_SPLIT_MEMBER()
00051         EqLeaf(){}
00052 protected:
00053         EqLeaf(Term* lhs, Term* rhs);
00054         virtual ~EqLeaf();
00055 
00056 public:
00057         static CNode* make(Term* lhs, Term* rhs);
00058         virtual bool operator==(const CNode& other);
00059         virtual string to_string();
00060         virtual CNode* substitute(map<Term*, Term*>& subs);
00061         Term* get_lhs();
00062         Term* get_rhs();
00063 
00064 
00065 private:
00066         void compute_hash_code();
00067 };
00068 
00069 
00070 
00071 #endif /* EQLEAF_H_ */