spot
0.8.2
|
00001 // Copyright (C) 2009, 2011 Laboratoire de Recherche et Développement 00002 // de l'Epita (LRDE). 00003 // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 00004 // (LIP6), département Systèmes Répartis Coopératifs (SRC), Université 00005 // Pierre et Marie Curie. 00006 // 00007 // This file is part of Spot, a model checking library. 00008 // 00009 // Spot is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Spot is distributed in the hope that it will be useful, but WITHOUT 00015 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00016 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00017 // License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Spot; see the file COPYING. If not, write to the Free 00021 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00022 // 02111-1307, USA. 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 #include "misc/casts.hh" 00033 00034 namespace spot 00035 { 00036 00039 class state 00040 { 00041 public: 00052 virtual int compare(const state* other) const = 0; 00053 00073 virtual size_t hash() const = 0; 00074 00076 virtual state* clone() const = 0; 00077 00087 virtual void destroy() const 00088 { 00089 delete this; 00090 } 00091 00092 protected: 00097 virtual ~state() 00098 { 00099 } 00100 }; 00101 00114 struct state_ptr_less_than: 00115 public std::binary_function<const state*, const state*, bool> 00116 { 00117 bool 00118 operator()(const state* left, const state* right) const 00119 { 00120 assert(left); 00121 return left->compare(right) < 0; 00122 } 00123 }; 00124 00138 struct state_ptr_equal: 00139 public std::binary_function<const state*, const state*, bool> 00140 { 00141 bool 00142 operator()(const state* left, const state* right) const 00143 { 00144 assert(left); 00145 return 0 == left->compare(right); 00146 } 00147 }; 00148 00163 struct state_ptr_hash: 00164 public std::unary_function<const state*, size_t> 00165 { 00166 size_t 00167 operator()(const state* that) const 00168 { 00169 assert(that); 00170 return that->hash(); 00171 } 00172 }; 00173 00174 // Functions related to shared_ptr. 00176 00177 typedef boost::shared_ptr<const state> shared_state; 00178 00179 inline void shared_state_deleter(state* s) { s->destroy(); } 00180 00194 struct state_shared_ptr_less_than: 00195 public std::binary_function<shared_state, 00196 shared_state, bool> 00197 { 00198 bool 00199 operator()(shared_state left, 00200 shared_state right) const 00201 { 00202 assert(left); 00203 return left->compare(right.get()) < 0; 00204 } 00205 }; 00206 00222 struct state_shared_ptr_equal: 00223 public std::binary_function<shared_state, 00224 shared_state, bool> 00225 { 00226 bool 00227 operator()(shared_state left, 00228 shared_state right) const 00229 { 00230 assert(left); 00231 return 0 == left->compare(right.get()); 00232 } 00233 }; 00234 00251 struct state_shared_ptr_hash: 00252 public std::unary_function<shared_state, size_t> 00253 { 00254 size_t 00255 operator()(shared_state that) const 00256 { 00257 assert(that); 00258 return that->hash(); 00259 } 00260 }; 00261 00262 } 00263 00264 #endif // SPOT_TGBA_STATE_HH