automatop.hh 3.12 KB
Newer Older
1
2
3
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE)
4
5
6
7
8
//
// 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
9
// the Free Software Foundation; either version 3 of the License, or
10
11
12
13
14
15
16
17
// (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
18
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21
22
23
24
25

/// \file ltlast/automatop.hh
/// \brief ELTL automaton operators
#ifndef SPOT_LTLAST_AUTOMATOP_HH
# define SPOT_LTLAST_AUTOMATOP_HH

# include <vector>
26
# include <iosfwd>
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# include <map>
# include "nfa.hh"
# include "refformula.hh"

namespace spot
{
  namespace ltl
  {
    /// \brief Automaton operators.
    /// \ingroup eltl_ast
    ///
    class automatop : public ref_formula
    {
    public:
      /// List of formulae.
42
      typedef std::vector<const formula*> vec;
43
44
45
46
47
48
49

      /// \brief Build a spot::ltl::automatop with many children.
      ///
      /// This vector is acquired by the spot::ltl::automatop class,
      /// the caller should allocate it with \c new, but not use it
      /// (especially not destroy it) after it has been passed to
      /// spot::ltl::automatop.
50
      static const automatop*
51
      instance(const nfa::ptr nfa, vec* v, bool negated);
52

53
      virtual void accept(visitor& v) const;
54
55
56
57
58
59
60
61
62

      /// Get the number of argument.
      unsigned size() const;
      /// \brief Get the nth argument.
      ///
      /// Starting with \a n = 0.
      const formula* nth(unsigned n) const;

      /// Get the NFA of this operator.
63
      const spot::ltl::nfa::ptr get_nfa() const;
64

65
      /// Whether the automaton is negated.
66
67
      bool is_negated() const;

68
69
70
      /// Return a canonic representation of the atomic proposition
      std::string dump() const;

71
72
73
      /// Number of instantiated multop operators.  For debugging.
      static unsigned instance_count();

74
75
76
77
      /// Dump all instances.  For debugging.
      static std::ostream& dump_instances(std::ostream& os);


78
    protected:
79
      typedef std::pair<std::pair<nfa::ptr, bool>, vec*> triplet;
80
      /// Comparison functor used internally by ltl::automatop.
81
      struct tripletcmp
82
83
      {
	bool
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
84
	operator()(const triplet& p1, const triplet& p2) const
85
	{
86
87
88
89
	  if (p1.first.first != p2.first.first)
	    return p1.first.first < p2.first.first;
	  if (p1.first.second != p2.first.second)
	    return p1.first.second < p2.first.second;
90
91
92
	  return *p1.second < *p2.second;
	}
      };
93
      typedef std::map<triplet, const automatop*, tripletcmp> map;
94
95
      static map instances;

96
      automatop(const nfa::ptr, vec* v, bool negated);
97
98
99
      virtual ~automatop();

    private:
100
      const nfa::ptr nfa_;
101
      vec* children_;
102
      bool negated_;
103
104
105
106
107
    };
  }
}

#endif // SPOT_LTLAST_AUTOMATOP_HH