spot  1.1.3
nfa.hh
Go to the documentation of this file.
1 // Copyright (C) 2008, 2010 Laboratoire de Recherche et Développement
2 // de l'Epita (LRDE).
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
21 #ifndef SPOT_LTLAST_NFA_HH
22 # define SPOT_LTLAST_NFA_HH
23 
24 # include "misc/hash.hh"
25 # include <boost/shared_ptr.hpp>
26 # include <list>
27 # include <set>
28 # include <map>
29 
30 namespace spot
31 {
32  namespace ltl
33  {
35  class succ_iterator;
38  namespace formula_tree
39  {
40  struct node;
41  }
42 
48  class nfa
49  {
50  public:
51  struct transition;
52  typedef std::list<transition*> state;
53  typedef boost::shared_ptr<formula_tree::node> label;
56  typedef boost::shared_ptr<nfa> ptr;
57 
59  struct transition
60  {
62  const state* dst;
63  };
64 
65  nfa();
66  ~nfa();
67 
68  void add_transition(int src, int dst, const label lbl);
69  void set_init_state(int name);
70  void set_final(int name);
71 
73  const state* get_init_state();
74 
76  bool is_final(const state* s);
77 
79  bool is_loop();
80 
82  unsigned arity();
83 
90  iterator begin(const state* s) const;
91 
93  iterator end(const state* s) const;
94 
95  int format_state(const state* s) const;
96 
97  const std::string& get_name() const;
98  void set_name(const std::string&);
99 
100  private:
101  state* add_state(int name);
102 
103  typedef Sgi::hash_map<int, state*, Sgi::hash<int> > is_map;
104  typedef Sgi::hash_map<const state*, int, ptr_hash<state> > si_map;
105 
108 
109  size_t arity_;
110  std::string name_;
111 
113  std::set<int> finals_;
114 
117  nfa(const nfa& other);
118  nfa& operator=(const nfa& other);
119  };
120 
122  {
123  public:
124  succ_iterator(const nfa::state::const_iterator s)
125  : i_(s)
126  {
127  }
128 
129  void
131  {
132  ++i_;
133  }
134 
135  bool
136  operator!=(const succ_iterator& rhs) const
137  {
138  return i_ != rhs.i_;
139  }
140 
141  const nfa::transition* operator*() const
142  {
143  return *i_;
144  }
145 
146  private:
147  nfa::state::const_iterator i_;
148  };
149 
150  }
151 }
152 
153 #endif // SPOT_LTLAST_NFA_HH_

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jul 9 2013 14:04:33 for spot by doxygen 1.8.4