tgbaproduct.hh 2.91 KB
Newer Older
1
2
#ifndef SPOT_TGBA_TGBAPRODUCT_HH
# define SPOT_TGBA_TGBAPRODUCT_HH
3
4
5
6
7
8
9

#include "tgba.hh"
#include "statebdd.hh"

namespace spot
{

10
  /// \brief A state for spot::tgba_product.
11
12
13
  ///
  /// This state is in fact a pair of state: the state from the left
  /// automaton and that of the right.
14
  class state_bdd_product : public state
15
16
17
18
19
20
21
  {
  public:
    /// \brief Constructor
    /// \param left The state from the left automaton.
    /// \param right The state from the right automaton.
    /// These state are acquired by spot::state_bdd_product, and will
    /// be deleted on destruction.
22
    state_bdd_product(state* left, state* right)
23
      :	left_(left),
24
25
26
	right_(right)
    {
    }
27

28
29
30
    /// Copy constructor
    state_bdd_product(const state_bdd_product& o);

31
32
    virtual ~state_bdd_product();

33
    state*
34
35
36
37
38
    left() const
    {
      return left_;
    }

39
    state*
40
41
42
43
44
45
    right() const
    {
      return right_;
    }

    virtual int compare(const state* other) const;
46
    virtual state_bdd_product* clone() const;
47
48

  private:
49
50
    state* left_;		///< State from the left automaton.
    state* right_;		///< State from the right automaton.
51
52
53
54
  };


  /// \brief Iterate over the successors of a product computed on the fly.
55
  class tgba_product_succ_iterator: public tgba_succ_iterator
56
57
  {
  public:
58
    tgba_product_succ_iterator(tgba_succ_iterator* left,
59
60
			       tgba_succ_iterator* right,
			       bdd left_neg, bdd right_neg);
61

62
    virtual ~tgba_product_succ_iterator();
63

64
65
66
    // iteration
    void first();
    void next();
67
    bool done() const;
68
69

    // inspection
70
    state_bdd_product* current_state();
71
    bdd current_condition();
72
    bdd current_accepting_conditions();
73
74
75
76
77
78
79
80
81
82
83
84

  private:
    //@{
    /// Internal routines to advance to the next successor.
    void step_();
    void next_non_false_();
    //@}

  protected:
    tgba_succ_iterator* left_;
    tgba_succ_iterator* right_;
    bdd current_cond_;
85
86
    bdd left_neg_;
    bdd right_neg_;
87
  };
88

89
  /// \brief A lazy product.  (States are computed on the fly.)
90
  class tgba_product : public tgba
91
92
93
94
95
  {
  public:
    /// \brief Constructor.
    /// \param left The left automata in the product.
    /// \param right The right automata in the product.
96
    /// Do not be fooled by these arguments: a product is commutative.
97
    tgba_product(const tgba& left, const tgba& right);
98

99
    virtual ~tgba_product();
100

101
102
    virtual state* get_init_state() const;

103
    virtual tgba_product_succ_iterator*
104
105
106
107
108
109
    succ_iter(const state* state) const;

    virtual const tgba_bdd_dict& get_dict() const;

    virtual std::string format_state(const state* state) const;

110
111
112
    virtual bdd all_accepting_conditions() const;
    virtual bdd neg_accepting_conditions() const;

113
114
115
116
117
118
  private:
    const tgba* left_;
    bool left_should_be_freed_;
    const tgba* right_;
    bool right_should_be_freed_;
    tgba_bdd_dict dict_;
119
120
    bdd all_accepting_conditions_;
    bdd neg_accepting_conditions_;
121
122
123
124
  };

}

125
#endif // SPOT_TGBA_TGBAPRODUCT_HH