spot  2.3.3.dev
kripke.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2009, 2010, 2013, 2014, 2016, 2017 Laboratoire de Recherche
3 // et Developpement de l'Epita
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 
20 #pragma once
21 
22 #include <spot/kripke/fairkripke.hh>
23 #include <spot/twacube/cube.hh>
24 #include <memory>
25 
26 namespace spot
27 {
36  template<typename State, typename SuccIterator>
37  class SPOT_API kripkecube:
38  public std::enable_shared_from_this<kripkecube<State, SuccIterator>>
39  {
40  public:
43  State initial(unsigned tid);
44 
46  std::string to_string(const State, unsigned tid) const;
47 
49  SuccIterator* succ(const State, unsigned tid);
50 
53  void recycle(SuccIterator*, unsigned tid);
54 
56  const std::vector<std::string> get_ap();
57  };
58 
62  template <typename State, typename SuccIter>
64  {
65  // Hardly waiting C++17 concepts...
66  State (kripkecube<State, SuccIter>::*test_initial)(unsigned) =
68  std::string (kripkecube<State, SuccIter>::*test_to_string)
69  (const State, unsigned) const = &kripkecube<State, SuccIter>::to_string;
70  auto (kripkecube<State, SuccIter>::*test_recycle)(SuccIter*, unsigned) =
72  const std::vector<std::string>
73  (kripkecube<State, SuccIter>::*test_get_ap)() =
75  void (SuccIter::*test_next)() = &SuccIter::next;
76  State (SuccIter::*test_state)() const= &SuccIter::state;
77  bool (SuccIter::*test_done)() const= &SuccIter::done;
78  cube (SuccIter::*test_condition)() const = &SuccIter::condition;
79 
80  // suppress warnings about unused variables
81  (void) test_initial;
82  (void) test_to_string;
83  (void) test_recycle;
84  (void) test_get_ap;
85  (void) test_next;
86  (void) test_state;
87  (void) test_done;
88  (void) test_condition;
89 
90  // Always return true since otherwise a compile-time error will be raised.
91  return true;
92  }
93 
110  class SPOT_API kripke_succ_iterator : public twa_succ_iterator
111  {
112  public:
117  kripke_succ_iterator(const bdd& cond)
118  : cond_(cond)
119  {
120  }
121 
122  void recycle(const bdd& cond)
123  {
124  cond_ = cond;
125  }
126 
127  virtual ~kripke_succ_iterator();
128 
129  virtual bdd cond() const override;
130  virtual acc_cond::mark_t acc() const override;
131  protected:
132  bdd cond_;
133  };
134 
157  class SPOT_API kripke: public fair_kripke
158  {
159  public:
160  kripke(const bdd_dict_ptr& d)
161  : fair_kripke(d)
162  {
163  }
164 
165  virtual ~kripke();
166 
167  virtual
168  acc_cond::mark_t state_acceptance_mark(const state*) const override;
169  };
170 
171  typedef std::shared_ptr<kripke> kripke_ptr;
172  typedef std::shared_ptr<const kripke> const_kripke_ptr;
173 }
Definition: graph.hh:33
Interface for a Fair Kripke structure.
Definition: fairkripke.hh:87
Interface for a Kripke structure.
Definition: kripke.hh:157
Abstract class for states.
Definition: twa.hh:50
Iterator code for Kripke structure.
Definition: kripke.hh:110
bool is_a_kripkecube(kripkecube< State, SuccIter > &)
This method allows to ensure (at compile time) if a given parameter is of type kripkecube. It also check if the iterator has the good interface.
Definition: kripke.hh:63
This class is a template representation of a Kripke structure. It is composed of two template paramet...
Definition: kripke.hh:37
kripke_succ_iterator(const bdd &cond)
Constructor.
Definition: kripke.hh:117
Iterate over the successors of a state.
Definition: twa.hh:397
unsigned * cube
A cube is only a set of bits in memory.
Definition: cube.hh:66
Definition: acc.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Apr 18 2017 14:42:56 for spot by doxygen 1.8.13