formula.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00026 #ifndef SPOT_LTLAST_FORMULA_HH
00027 # define SPOT_LTLAST_FORMULA_HH
00028
00029 #include <string>
00030 #include <cassert>
00031 #include "predecl.hh"
00032
00033 namespace spot
00034 {
00035 namespace ltl
00036 {
00040
00043
00046
00050
00053
00056
00059
00062
00065
00066
00073 class formula
00074 {
00075 public:
00076 formula() : count_(++max_count) {}
00077
00079 virtual void accept(visitor& v) = 0;
00081 virtual void accept(const_visitor& v) const = 0;
00082
00087 formula* clone() const;
00092 void destroy() const;
00093
00095 virtual std::string dump() const = 0;
00096
00098 size_t
00099 hash() const
00100 {
00101 return count_;
00102 }
00103 protected:
00104 virtual ~formula();
00105
00107 virtual void ref_();
00110 virtual bool unref_();
00111
00113 size_t count_;
00114
00115 private:
00117 static size_t max_count;
00118 };
00119
00133 struct formula_ptr_less_than:
00134 public std::binary_function<const formula*, const formula*, bool>
00135 {
00136 bool
00137 operator()(const formula* left, const formula* right) const
00138 {
00139 assert(left);
00140 assert(right);
00141 if (left == right)
00142 return false;
00143 size_t l = left->hash();
00144 size_t r = right->hash();
00145 if (l != r)
00146 return l < r;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 return left->dump() < right->dump();
00158 }
00159 };
00160
00175 struct formula_ptr_hash:
00176 public std::unary_function<const formula*, size_t>
00177 {
00178 size_t
00179 operator()(const formula* that) const
00180 {
00181 assert(that);
00182 return that->hash();
00183 }
00184 };
00185
00186
00187 }
00188 }
00189
00190 #endif // SPOT_LTLAST_FORMULA_HH