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
00024 #ifndef SPOT_TGBA_STATE_HH
00025 # define SPOT_TGBA_STATE_HH
00026
00027 #include <cstddef>
00028 #include <bdd.h>
00029 #include <cassert>
00030 #include <functional>
00031 #include <boost/shared_ptr.hpp>
00032
00033 namespace spot
00034 {
00035
00038 class state
00039 {
00040 public:
00051 virtual int compare(const state* other) const = 0;
00052
00072 virtual size_t hash() const = 0;
00073
00075 virtual state* clone() const = 0;
00076
00086 virtual void destroy() const
00087 {
00088 delete this;
00089 }
00090
00091
00092
00093
00098 virtual ~state()
00099 {
00100 }
00101 };
00102
00115 struct state_ptr_less_than:
00116 public std::binary_function<const state*, const state*, bool>
00117 {
00118 bool
00119 operator()(const state* left, const state* right) const
00120 {
00121 assert(left);
00122 return left->compare(right) < 0;
00123 }
00124 };
00125
00139 struct state_ptr_equal:
00140 public std::binary_function<const state*, const state*, bool>
00141 {
00142 bool
00143 operator()(const state* left, const state* right) const
00144 {
00145 assert(left);
00146 return 0 == left->compare(right);
00147 }
00148 };
00149
00164 struct state_ptr_hash:
00165 public std::unary_function<const state*, size_t>
00166 {
00167 size_t
00168 operator()(const state* that) const
00169 {
00170 assert(that);
00171 return that->hash();
00172 }
00173 };
00174
00175
00177
00178 typedef boost::shared_ptr<const state> shared_state;
00179
00180 inline void shared_state_deleter(state* s) { s->destroy(); }
00181
00195 struct state_shared_ptr_less_than:
00196 public std::binary_function<shared_state,
00197 shared_state, bool>
00198 {
00199 bool
00200 operator()(shared_state left,
00201 shared_state right) const
00202 {
00203 assert(left);
00204 return left->compare(right.get()) < 0;
00205 }
00206 };
00207
00223 struct state_shared_ptr_equal:
00224 public std::binary_function<shared_state,
00225 shared_state, bool>
00226 {
00227 bool
00228 operator()(shared_state left,
00229 shared_state right) const
00230 {
00231 assert(left);
00232 return 0 == left->compare(right.get());
00233 }
00234 };
00235
00252 struct state_shared_ptr_hash:
00253 public std::unary_function<shared_state, size_t>
00254 {
00255 size_t
00256 operator()(shared_state that) const
00257 {
00258 assert(that);
00259 return that->hash();
00260 }
00261 };
00262
00263 }
00264
00265 #endif // SPOT_TGBA_STATE_HH