00001
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __sym_counter__
00035 #define __sym_counter__
00036
00037
00038 class Problem;
00039
00040
00041 #include "Signature.hpp"
00042 #include "Unit.hpp"
00043
00044
00045 using namespace std;
00046
00047
00048
00049
00050
00051 class SymCounter {
00052 public:
00053
00054 class Fun {
00055 Signature::Fun* _fun;
00056 int _occ;
00057 public:
00058 Fun () : _occ(0) {}
00059 void fun (Signature::Fun* f) { _fun = f; }
00060 int occ () const { return _occ; }
00061 Signature::Fun* fun () { return _fun; }
00062 void add (int add) { _occ += add; }
00063 };
00064
00065 class Pred {
00066 Signature::Pred* _pred;
00067 int _pocc;
00068 int _nocc;
00069 int _docc;
00070 public:
00071 Pred ()
00072 : _pocc (0),
00073 _nocc (0),
00074 _docc (0)
00075 {}
00076 void pred (Signature::Pred* p) { _pred = p; }
00077 int pocc () const { return _pocc; }
00078 int nocc () const { return _nocc; }
00079 int docc () const { return _docc; }
00080 Signature::Pred* pred () { return _pred; }
00081 void add (int polarity, int add);
00082 };
00083
00084 explicit SymCounter (Signature&);
00085 ~SymCounter ();
00086
00087
00088 void count (Problem&, int);
00089 void count (Unit, int);
00090 void count (Clause, int);
00091 void count (Formula, int polarity, int add);
00092 void count (Literal, int);
00093 void count (Atom a, int polarity, int add);
00094 void count (Term t, int add);
00095
00096
00097 Pred* get (const Signature::Pred* p) { return _preds + p->number(); }
00098 Fun* get (const Signature::Fun* f) { return _funs + f->number(); }
00099
00100
00101 void output (ostream& str) const;
00102
00103 static SymCounter* norm;
00104
00105 private:
00106
00107
00108 int _noOfPreds;
00109 int _noOfFuns;
00110 Pred* _preds;
00111 Fun* _funs;
00112 };
00113
00114
00115
00116 inline
00117 ostream& operator << (ostream& str, const SymCounter& c)
00118 {
00119 c.output(str);
00120 return str;
00121 }
00122
00123
00124 #endif // __sym_counter__