nfa.hh

Go to the documentation of this file.
00001 // Copyright (C) 2008, 2010 Laboratoire de Recherche et Développement
00002 // de l'Epita (LRDE).
00003 //
00004 // This file is part of Spot, a model checking library.
00005 //
00006 // Spot is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // Spot is distributed in the hope that it will be useful, but WITHOUT
00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
00014 // License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with Spot; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019 // 02111-1307, USA.
00020 
00023 #ifndef SPOT_LTLAST_NFA_HH
00024 # define SPOT_LTLAST_NFA_HH
00025 
00026 # include "misc/hash.hh"
00027 # include <boost/shared_ptr.hpp>
00028 # include <list>
00029 # include <set>
00030 # include <map>
00031 
00032 namespace spot
00033 {
00034   namespace ltl
00035   {
00037     class succ_iterator;
00040     namespace formula_tree
00041     {
00042       struct node;
00043     }
00044 
00050     class nfa
00051     {
00052     public:
00053       struct transition;
00054       typedef std::list<transition*> state;
00055       typedef boost::shared_ptr<formula_tree::node> label;
00057       typedef succ_iterator iterator;
00058       typedef boost::shared_ptr<nfa> ptr;
00059 
00061       struct transition
00062       {
00063         label lbl;
00064         const state* dst;
00065       };
00066 
00067       nfa();
00068       ~nfa();
00069 
00070       void add_transition(int src, int dst, const label lbl);
00071       void set_init_state(int name);
00072       void set_final(int name);
00073 
00075       const state* get_init_state();
00076 
00078       bool is_final(const state* s);
00079 
00081       bool is_loop();
00082 
00084       unsigned arity();
00085 
00092       iterator begin(const state* s) const;
00093 
00095       iterator end(const state* s) const;
00096 
00097       int format_state(const state* s) const;
00098 
00099       const std::string& get_name() const;
00100       void set_name(const std::string&);
00101 
00102     private:
00103       state* add_state(int name);
00104 
00105       typedef Sgi::hash_map<int, state*, Sgi::hash<int> > is_map;
00106       typedef Sgi::hash_map<const state*, int, ptr_hash<state> > si_map;
00107 
00108       is_map is_;
00109       si_map si_;
00110 
00111       size_t arity_;
00112       std::string name_;
00113 
00114       state* init_;
00115       std::set<int> finals_;
00116 
00119       nfa(const nfa& other);
00120       nfa& operator=(const nfa& other);
00121     };
00122 
00123     class succ_iterator
00124     {
00125     public:
00126       succ_iterator(const nfa::state::const_iterator s)
00127         : i_(s)
00128       {
00129       }
00130 
00131       void
00132       operator++()
00133       {
00134         ++i_;
00135       }
00136 
00137       bool
00138       operator!=(const succ_iterator& rhs) const
00139       {
00140         return i_ != rhs.i_;
00141       }
00142 
00143       const nfa::transition* operator*() const
00144       {
00145         return *i_;
00146       }
00147 
00148     private:
00149       nfa::state::const_iterator i_;
00150     };
00151 
00152   }
00153 }
00154 
00155 #endif // SPOT_LTLAST_NFA_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