spot  1.2.1a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
unop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
3 // 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 #ifndef SPOT_LTLAST_UNOP_HH
26 # define SPOT_LTLAST_UNOP_HH
27 
28 #include <map>
29 #include <iosfwd>
30 #include "refformula.hh"
31 #include "bunop.hh"
32 
33 namespace spot
34 {
35  namespace ltl
36  {
37 
40  class SPOT_API unop : public ref_formula
41  {
42  public:
43  enum type {
44  // LTL
45  Not, X, F, G,
46  // ELTL
47  Finish,
48  // Closure
49  Closure, NegClosure, NegClosureMarked
50  };
51 
89  static const formula* instance(type op, const formula* child);
90 
91  virtual void accept(visitor& v) const;
92 
94  const formula* child() const;
95 
97  type op() const;
99  const char* op_name() const;
100 
102  virtual std::string dump() const;
103 
105  static unsigned instance_count();
106 
108  static std::ostream& dump_instances(std::ostream& os);
109 
110  protected:
111  typedef std::pair<type, const formula*> pair;
112  typedef std::map<pair, const unop*> map;
113  static map instances;
114 
115  unop(type op, const formula* child);
116  virtual ~unop();
117 
118  private:
119  type op_;
120  const formula* child_;
121  };
122 
123 
128  inline
129  const unop*
130  is_unop(const formula* f)
131  {
132  if (f->kind() != formula::UnOp)
133  return 0;
134  return static_cast<const unop*>(f);
135  }
136 
141  inline
142  const unop*
143  is_unop(const formula* f, unop::type op)
144  {
145  if (const unop* uo = is_unop(f))
146  if (uo->op() == op)
147  return uo;
148  return 0;
149  }
150 
154  inline
155  const unop*
156  is_Not(const formula* f)
157  {
158  return is_unop(f, unop::Not);
159  }
160 
164  inline
165  const unop*
166  is_X(const formula* f)
167  {
168  return is_unop(f, unop::X);
169  }
170 
174  inline
175  const unop*
176  is_F(const formula* f)
177  {
178  return is_unop(f, unop::F);
179  }
180 
184  inline
185  const unop*
186  is_G(const formula* f)
187  {
188  return is_unop(f, unop::G);
189  }
190 
194  inline
195  const unop*
196  is_GF(const formula* f)
197  {
198  if (const unop* op = is_G(f))
199  return is_F(op->child());
200  return 0;
201  }
202 
206  inline
207  const unop*
208  is_FG(const formula* f)
209  {
210  if (const unop* op = is_F(f))
211  return is_G(op->child());
212  return 0;
213  }
214  }
215 }
216 
217 #endif // SPOT_LTLAST_UNOP_HH
Formula visitor.
Definition: visitor.hh:41
A reference-counted LTL formula.
Definition: refformula.hh:37
SPOT_API std::ostream & dump(std::ostream &os, const formula *f)
Dump a formula tree.
opkind kind() const
Return the kind of the top-level operator.
Definition: formula.hh:114
Bounded Unary operators.
An LTL formula.
Definition: formula.hh:72
Reference-counted LTL formulae.
Unary operators.
Definition: unop.hh:40

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jan 21 2014 16:52:01 for spot by doxygen 1.8.5