spot  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
nfa.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2010, 2013, 2014 Laboratoire de Recherche et
3 // Développement de l'Epita (LRDE).
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
22 #ifndef SPOT_LTLAST_NFA_HH
23 # define SPOT_LTLAST_NFA_HH
24 
25 # include "misc/common.hh"
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 SPOT_API 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  {
63  label lbl;
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 
108  is_map is_;
109  si_map si_;
110 
111  size_t arity_;
112  std::string name_;
113 
114  state* init_;
115  std::set<int> finals_;
116 
119  nfa(const nfa& other);
120  nfa& operator=(const nfa& other);
121  };
122 
123  class SPOT_API succ_iterator
124  {
125  public:
126  succ_iterator(const nfa::state::const_iterator s)
127  : i_(s)
128  {
129  }
130 
131  void
132  operator++()
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 direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sat Dec 6 2014 12:28:43 for spot by doxygen 1.8.4