spot  0.9.2
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 2 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 Spot; see the file COPYING. If not, write to the Free
18 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 // 02111-1307, USA.
20 
23 #ifndef SPOT_LTLAST_NFA_HH
24 # define SPOT_LTLAST_NFA_HH
25 
26 # include "misc/hash.hh"
27 # include <boost/shared_ptr.hpp>
28 # include <list>
29 # include <set>
30 # include <map>
31 
32 namespace spot
33 {
34  namespace ltl
35  {
37  class succ_iterator;
40  namespace formula_tree
41  {
42  struct node;
43  }
44 
50  class nfa
51  {
52  public:
53  struct transition;
54  typedef std::list<transition*> state;
55  typedef boost::shared_ptr<formula_tree::node> label;
58  typedef boost::shared_ptr<nfa> ptr;
59 
61  struct transition
62  {
64  const state* dst;
65  };
66 
67  nfa();
68  ~nfa();
69 
70  void add_transition(int src, int dst, const label lbl);
71  void set_init_state(int name);
72  void set_final(int name);
73 
75  const state* get_init_state();
76 
78  bool is_final(const state* s);
79 
81  bool is_loop();
82 
84  unsigned arity();
85 
92  iterator begin(const state* s) const;
93 
95  iterator end(const state* s) const;
96 
97  int format_state(const state* s) const;
98 
99  const std::string& get_name() const;
100  void set_name(const std::string&);
101 
102  private:
103  state* add_state(int name);
104 
105  typedef Sgi::hash_map<int, state*, Sgi::hash<int> > is_map;
106  typedef Sgi::hash_map<const state*, int, ptr_hash<state> > si_map;
107 
110 
111  size_t arity_;
112  std::string name_;
113 
115  std::set<int> finals_;
116 
119  nfa(const nfa& other);
120  nfa& operator=(const nfa& other);
121  };
122 
124  {
125  public:
126  succ_iterator(const nfa::state::const_iterator s)
127  : i_(s)
128  {
129  }
130 
131  void
133  {
134  ++i_;
135  }
136 
137  bool
138  operator!=(const succ_iterator& rhs) const
139  {
140  return i_ != rhs.i_;
141  }
142 
143  const nfa::transition* operator*() const
144  {
145  return *i_;
146  }
147 
148  private:
149  nfa::state::const_iterator i_;
150  };
151 
152  }
153 }
154 
155 #endif // SPOT_LTLAST_NFA_HH_

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Jul 2 2012 17:35:47 for spot by doxygen 1.8.1.1