dupexp.cc 2.25 KB
Newer Older
1
// Copyright (C) 2003, 2004  Laboratoire d'Informatique de Paris 6 (LIP6),
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING.  If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.

22
23
24
25
26
27
#include "dupexp.hh"
#include <sstream>
#include <string>
#include <map>
#include "reachiter.hh"

28
29
30
namespace spot
{
  namespace
31
  {
32
33
    template <class T>
    class dupexp_iter: public T
34
    {
35
36
37
38
    public:
      dupexp_iter(const tgba* a)
	: T(a), out_(new tgba_explicit(a->get_dict()))
      {
39
	out_->copy_acceptance_conditions_of(a);
40
      }
41

42
43
44
45
46
      tgba_explicit*
      result()
      {
	return out_;
      }
47

48
      void
49
50
51
      process_link(const state* in_s, int in,
		   const state* out_s, int out,
		   const tgba_succ_iterator* si)
52
      {
53
54
55
56
	std::ostringstream in_name;
	in_name << "(#" << in << ") " << this->automata_->format_state(in_s);
	std::ostringstream out_name;
	out_name << "(#" << out << ") " << this->automata_->format_state(out_s);
57
58

	tgba_explicit::transition* t =
59
	  out_->create_transition(in_name.str(), out_name.str());
60
61
62
	out_->add_conditions(t, si->current_condition());
	out_->add_acceptance_conditions(t, si->current_acceptance_conditions());
      }
63

64
65
66
    private:
      tgba_explicit* out_;
    };
67

68
  } // anonymous
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

  tgba_explicit*
  tgba_dupexp_bfs(const tgba* aut)
  {
    dupexp_iter<tgba_reachable_iterator_breadth_first> di(aut);
    di.run();
    return di.result();
  }

  tgba_explicit*
  tgba_dupexp_dfs(const tgba* aut)
  {
    dupexp_iter<tgba_reachable_iterator_depth_first> di(aut);
    di.run();
    return di.result();
  }

}