00001
00002
00003
00004
00005
00006
00007
00008 #ifndef QUANTIFIEDLEAF_H_
00009 #define QUANTIFIEDLEAF_H_
00010
00011 #include "Leaf.h"
00012 #include <set>
00013 #include <vector>
00014 #include <iostream>
00015 #include "VarMap.h"
00016 using namespace std;
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class QuantifiedLeaf: public Leaf {
00035 friend class boost::serialization::access;
00036 template<class Archive>
00037 void save(Archive & ar, const unsigned int version) const
00038 {
00039 ar & boost::serialization::base_object<Leaf>(*this);
00040 vector<pair<string, int> > qvars;
00041 set<int>::iterator it = quantified_vars.begin();
00042 for(; it!= quantified_vars.end(); it++)
00043 {
00044 int attrib = CNode::get_varmap().get_attrib(*it);
00045 string name = CNode::get_varmap().get_name(*it);
00046 pair<string, int> key(name, attrib);
00047 qvars.push_back(key);
00048 }
00049 ar & qvars;
00050 ar & index_guard;
00051 ar & value_guard;
00052
00053 }
00054 template<class Archive>
00055 void load(Archive & ar, const unsigned int version)
00056 {
00057 ar & boost::serialization::base_object<Leaf>(*this);
00058 vector<pair<string, int> > qvars;
00059 ar & qvars;
00060 ar & index_guard;
00061 ar & value_guard;
00062 vector<pair<string, int> >::iterator it = qvars.begin();
00063 for(; it!= qvars.end(); it++)
00064 {
00065 string name = it->first;
00066 int attrib = it->second;
00067 int id = CNode::get_varmap().get_id(name) | attrib;
00068 quantified_vars.insert(id);
00069 }
00070 hash_c = index_guard->hash_code()*47 + value_guard->hash_code()*7;
00071
00072 }
00073 BOOST_SERIALIZATION_SPLIT_MEMBER()
00074 private:
00075 set<int> quantified_vars;
00076 CNode* index_guard;
00077 CNode* value_guard;
00078
00079 protected:
00080 QuantifiedLeaf(set<int>& q_vars, CNode* index_guard, CNode* value_guard);
00081 public:
00082 QuantifiedLeaf(){};
00083 virtual ~QuantifiedLeaf();
00084 static CNode* make(set<int>& q_vars, CNode* index_guard, CNode* value_guard);
00085 set<int>& get_quantified_vars();
00086 CNode* get_index_guard();
00087 CNode* get_value_guard();
00088 virtual bool operator==(const CNode& other);
00089 virtual string to_string();
00090 virtual CNode* substitute(map<Term*, Term*>& subs);
00091
00092 };
00093
00094 #endif