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