state.hh

Go to the documentation of this file.
00001 // Copyright (C) 2009 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 
00077     virtual ~state()
00078     {
00079     }
00080   };
00081 
00094   struct state_ptr_less_than:
00095     public std::binary_function<const state*, const state*, bool>
00096   {
00097     bool
00098     operator()(const state* left, const state* right) const
00099     {
00100       assert(left);
00101       return left->compare(right) < 0;
00102     }
00103   };
00104 
00118   struct state_ptr_equal:
00119     public std::binary_function<const state*, const state*, bool>
00120   {
00121     bool
00122     operator()(const state* left, const state* right) const
00123     {
00124       assert(left);
00125       return 0 == left->compare(right);
00126     }
00127   };
00128 
00143   struct state_ptr_hash:
00144     public std::unary_function<const state*, size_t>
00145   {
00146     size_t
00147     operator()(const state* that) const
00148     {
00149       assert(that);
00150       return that->hash();
00151     }
00152   };
00153 
00154   // Functions related to shared_ptr.
00156 
00157   typedef boost::shared_ptr<const state> shared_state;
00158 
00172   struct state_shared_ptr_less_than:
00173     public std::binary_function<shared_state,
00174                                 shared_state, bool>
00175   {
00176     bool
00177     operator()(shared_state left,
00178                shared_state right) const
00179     {
00180       assert(left);
00181       return left->compare(right.get()) < 0;
00182     }
00183   };
00184 
00200   struct state_shared_ptr_equal:
00201     public std::binary_function<shared_state,
00202                                 shared_state, bool>
00203   {
00204     bool
00205     operator()(shared_state left,
00206                shared_state right) const
00207     {
00208       assert(left);
00209       return 0 == left->compare(right.get());
00210     }
00211   };
00212 
00229   struct state_shared_ptr_hash:
00230     public std::unary_function<shared_state, size_t>
00231   {
00232     size_t
00233     operator()(shared_state that) const
00234     {
00235       assert(that);
00236       return that->hash();
00237     }
00238   };
00239 
00240 }
00241 
00242 #endif // SPOT_TGBA_STATE_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Fri Apr 16 09:40:33 2010 for spot by doxygen 1.6.3