00001
00002
00003
00004
00005
00006
00007
00008 #ifndef VARIABLETERM_H_
00009 #define VARIABLETERM_H_
00010
00011 #include "Term.h"
00012
00013 Term* _make_ap(const string& name);
00014
00015 class VariableTerm: public Term {
00016
00017 friend class boost::serialization::access;
00018 private:
00019 int var_id;
00020
00021 template<class Archive>
00022 void save(Archive & ar, const unsigned int version) const
00023 {
00024 ar & boost::serialization::base_object<Term>(*this);
00025 const string& name = CNode::get_varmap().get_name(var_id);
00026 ar & name;
00027 int attrib = get_id_attribute();
00028 ar & attrib;
00029 }
00030 template<class Archive>
00031 void load(Archive & ar, const unsigned int version)
00032 {
00033 ar & boost::serialization::base_object<Term>(*this);
00034 string name;
00035 ar & name;
00036 var_id = CNode::get_varmap().get_id(name);
00037 int attrib;
00038 ar & attrib;
00039 var_id |= attrib;
00040 hash_c = (this->var_id+2)* 65537;
00041
00042 }
00043 BOOST_SERIALIZATION_SPLIT_MEMBER()
00044
00045 protected:
00046 VariableTerm()
00047 {
00048
00049 }
00050 public:
00051 VariableTerm(int var_id, int attribute = 0);
00052 virtual ~VariableTerm();
00053 public:
00054 static Term* make(int id);
00055 static Term* make(string name);
00056 virtual bool operator==(const Term& other);
00057 virtual string to_string();
00058 inline int get_id_attribute() const
00059 {
00060 int mask = (1 << NUM_BITS_RESERVED)-1;
00061 int res = var_id & mask;
00062 return res;
00063 }
00064 inline int get_var_id()
00065 {
00066 return var_id;
00067 }
00068 string get_name();
00069 virtual Term* substitute(map<Term*, Term*>& subs);
00070 };
00071
00072
00073
00074
00075
00076 #endif