tgbaproduct.hh 2.7 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
14
15
16
17
18
19
20
21
  ///
  /// This state is in fact a pair of state: the state from the left
  /// automaton and that of the right.
  class state_bdd_product : public state_bdd
  {
  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
23
24
    state_bdd_product(state* left, state* right)
      : state_bdd(left->as_bdd() & right->as_bdd()),
	left_(left),
25
26
27
	right_(right)
    {
    }
28

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

32
33
    virtual ~state_bdd_product();

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

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

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

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


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

62
    virtual ~tgba_product_succ_iterator();
63

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

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

  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_;
  };
86

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

97
    virtual ~tgba_product();
98

99
100
    virtual state* get_init_state() const;

101
    virtual tgba_product_succ_iterator*
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    succ_iter(const state* state) const;

    virtual const tgba_bdd_dict& get_dict() const;

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

  private:
    const tgba* left_;
    bool left_should_be_freed_;
    const tgba* right_;
    bool right_should_be_freed_;
    tgba_bdd_dict dict_;
  };

}

118
#endif // SPOT_TGBA_TGBAPRODUCT_HH