binop.hh 2.71 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
/// \file ltlast/binop.hh
/// \brief LTL binary operators
///
/// This does not include \c AND and \c OR operators.  These are
/// considered to be multi-operand operators (see spot::ltl::multop).
27
28
29
#ifndef SPOT_LTLAST_BINOP_HH
# define SPOT_LTLAST_BINOP_HH

30
#include <map>
31
#include "refformula.hh"
32
33
34
35
36

namespace spot
{
  namespace ltl
  {
37

38
39
    /// \brief Binary operator.
    /// \ingroup ltl_ast
40
    class binop : public ref_formula
41
42
    {
    public:
43
44
45
46
      /// Different kinds of binary opertaors
      ///
      /// And and Or are not here.  Because they
      /// are often nested we represent them as multops.
47
48
      enum type { Xor, Implies, Equiv, U, R };

49
50
51
      /// Build an unary operator with operation \a op and
      /// children \a first and \a second.
      static binop* instance(type op, formula* first, formula* second);
52
53
54
55

      virtual void accept(visitor& v);
      virtual void accept(const_visitor& v) const;

56
      /// Get the first operand.
57
      const formula* first() const;
58
      /// Get the first operand.
59
      formula* first();
60
      /// Get the second operand.
61
      const formula* second() const;
62
      /// Get the second operand.
63
      formula* second();
64

65
      /// Get the type of this operator.
66
      type op() const;
67
      /// Get the type of this operator, as a string.
68
69
      const char* op_name() const;

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

73
74
75
76
77
78
79
80
81
    protected:
      typedef std::pair<formula*, formula*> pairf;
      typedef std::pair<type, pairf> pair;
      typedef std::map<pair, formula*> map;
      static map instances;

      binop(type op, formula* first, formula* second);
      virtual ~binop();

82
83
    private:
      type op_;
84
85
      formula* first_;
      formula* second_;
86
87
88
89
90
91
    };

  }
}

#endif // SPOT_LTLAST_BINOP_HH