state.hh

Go to the documentation of this file.
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 
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     // FIXME: Make the destructor protected after Spot 0.7.
00092     //protected:
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   // Functions related to shared_ptr.
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

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Feb 7 2011 14:29:29 for spot by doxygen 1.7.1