00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00024 #ifndef SPOT_LTLAST_FORMULA_HH
00025 # define SPOT_LTLAST_FORMULA_HH
00026
00027 #include <string>
00028 #include <cassert>
00029 #include "predecl.hh"
00030
00031 namespace spot
00032 {
00033 namespace ltl
00034 {
00038
00041
00044
00048
00051
00054
00057
00060
00063
00064
00071 class formula
00072 {
00073 public:
00075 virtual void accept(visitor& v) = 0;
00077 virtual void accept(const_visitor& v) const = 0;
00078
00085 formula* ref();
00092 static void unref(formula* f);
00093
00095 const std::string& dump() const;
00096
00098 const size_t
00099 hash() const
00100 {
00101 return hash_key_;
00102 }
00103 protected:
00104 virtual ~formula();
00105
00107 virtual void ref_();
00110 virtual bool unref_();
00111
00115 void set_key_();
00117 std::string dump_;
00121 size_t hash_key_;
00122 };
00123
00137 struct formula_ptr_less_than:
00138 public std::binary_function<const formula*, const formula*, bool>
00139 {
00140 bool
00141 operator()(const formula* left, const formula* right) const
00142 {
00143 assert(left);
00144 assert(right);
00145 size_t l = left->hash();
00146 size_t r = right->hash();
00147 if (1 != r)
00148 return l < r;
00149 return left->dump() < right->dump();
00150 }
00151 };
00152
00167 struct formula_ptr_hash:
00168 public std::unary_function<const formula*, size_t>
00169 {
00170 size_t
00171 operator()(const formula* that) const
00172 {
00173 assert(that);
00174 return that->hash();
00175 }
00176 };
00177
00178
00179 }
00180 }
00181
00182 #endif // SPOT_LTLAST_FORMULA_HH