tgbaexplicit.hh 2.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SPOT_TGBA_TGBAEXPLICIT_HH
# define SPOT_TGBA_TGBAEXPLICIT_HH

#include <list>
#include <map>
#include "tgba.hh"
#include "ltlast/formula.hh"
#include "bddfactory.hh"

namespace spot
{
  // Forward declarations.  See below.
  class state_explicit;
  class tgba_explicit_succ_iterator;

  /// Explicit representation of a spot::tgba.
  class tgba_explicit : public tgba, public bdd_factory
  {
  public:
    tgba_explicit();

    struct transition;
    typedef std::list<transition*> state;
    struct transition
    {
      bdd condition;
      bdd promise;
      state* dest;
    };

    transition*
    create_transition(const std::string& source, const std::string& dest);

    void add_condition(transition* t, ltl::formula* f);
35
    void add_neg_condition(transition* t, ltl::formula* f);
36
    void add_promise(transition* t, ltl::formula* f);
37
    void add_neg_promise(transition* t, ltl::formula* f);
38
39
40
41
42
43
44
45
46
47
48

    // tgba interface
    virtual ~tgba_explicit();
    virtual spot::state* get_init_state() const;
    virtual tgba_succ_iterator*
    succ_iter(const spot::state* state) const;
    virtual const tgba_bdd_dict& get_dict() const;
    virtual std::string format_state(const spot::state* state) const;

  protected:
    state* add_state(const std::string& name);
49
50
51
    int get_condition(ltl::formula* f);
    int get_promise(ltl::formula* f);

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    typedef std::map<const std::string, tgba_explicit::state*> ns_map;
    typedef std::map<const tgba_explicit::state*, std::string> sn_map;
    ns_map name_state_map_;
    sn_map state_name_map_;
    tgba_bdd_dict dict_;
    tgba_explicit::state* init_;
  };


  class state_explicit : public spot::state
  {
  public:
    state_explicit(const tgba_explicit::state* s)
      : state_(s)
    {
    }

    virtual int compare(const spot::state* other) const;

    virtual ~state_explicit()
    {
    }

    const tgba_explicit::state* get_state() const;
  private:
    const tgba_explicit::state* state_;
  };


  class tgba_explicit_succ_iterator : public tgba_succ_iterator
  {
  public:
    tgba_explicit_succ_iterator(const tgba_explicit::state* s);

    virtual
    ~tgba_explicit_succ_iterator()
    {
    }

    virtual void first();
    virtual void next();
    virtual bool done();

    virtual state_explicit* current_state();
    virtual bdd current_condition();
    virtual bdd current_promise();

  private:
    const tgba_explicit::state* s_;
    tgba_explicit::state::const_iterator i_;
  };

}

#endif // SPOT_TGBA_TGBAEXPLICIT_HH