spot  1.99.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
unop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Laboratoire de
3 // Recherche et Développement de l'Epita (LRDE).
4 // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris
5 // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
6 // Université Pierre et Marie Curie.
7 //
8 // This file is part of Spot, a model checking library.
9 //
10 // Spot is free software; you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Spot is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
25 #pragma once
26 
27 #include <map>
28 #include <iosfwd>
29 #include "formula.hh"
30 
31 namespace spot
32 {
33  namespace ltl
34  {
35 
38  class SPOT_API unop final : public formula
39  {
40  public:
41  enum type {
42  // LTL
43  Not, X, F, G,
44  // Closure
45  Closure, NegClosure, NegClosureMarked
46  };
47 
85  static const formula* instance(type op, const formula* child);
86 
87  virtual void accept(visitor& v) const override;
88 
90  const formula* child() const
91  {
92  return child_;
93  }
94 
96  type op() const
97  {
98  return op_;
99  }
100 
102  const char* op_name() const;
103 
105  virtual std::string dump() const override;
106 
108  static unsigned instance_count();
109 
111  static std::ostream& dump_instances(std::ostream& os);
112 
113  protected:
114  typedef std::pair<type, const formula*> key;
115  typedef std::map<key, const unop*> map;
116  static map instances;
117 
118  unop(type op, const formula* child);
119  virtual ~unop();
120 
121  private:
122  type op_;
123  const formula* child_;
124  };
125 
126 
131  inline
132  const unop*
133  is_unop(const formula* f)
134  {
135  if (f->kind() != formula::UnOp)
136  return 0;
137  return static_cast<const unop*>(f);
138  }
139 
144  inline
145  const unop*
146  is_unop(const formula* f, unop::type op)
147  {
148  if (const unop* uo = is_unop(f))
149  if (uo->op() == op)
150  return uo;
151  return 0;
152  }
153 
157  inline
158  const unop*
159  is_Not(const formula* f)
160  {
161  return is_unop(f, unop::Not);
162  }
163 
167  inline
168  const unop*
169  is_X(const formula* f)
170  {
171  return is_unop(f, unop::X);
172  }
173 
177  inline
178  const unop*
179  is_F(const formula* f)
180  {
181  return is_unop(f, unop::F);
182  }
183 
187  inline
188  const unop*
189  is_G(const formula* f)
190  {
191  return is_unop(f, unop::G);
192  }
193 
197  inline
198  const unop*
199  is_GF(const formula* f)
200  {
201  if (const unop* op = is_G(f))
202  return is_F(op->child());
203  return 0;
204  }
205 
209  inline
210  const unop*
211  is_FG(const formula* f)
212  {
213  if (const unop* op = is_F(f))
214  return is_G(op->child());
215  return 0;
216  }
217  }
218 }
Definition: public.hh:31
LTL formula interface.
Formula visitor.
Definition: visitor.hh:40
type op() const
Get the type of this operator.
Definition: unop.hh:96
SPOT_API std::ostream & dump(std::ostream &os, const formula *f)
Dump a formula tree.
An LTL formula.
Definition: formula.hh:71
const formula * child() const
Get the sole operand of this operator.
Definition: unop.hh:90
Unary operators.
Definition: unop.hh:38

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Aug 26 2015 08:42:37 for spot by doxygen 1.8.8