spot  1.99.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
multop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire
3 // de 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 "formula.hh"
28 #include <vector>
29 #include <map>
30 #include <iosfwd>
31 
32 namespace spot
33 {
34  namespace ltl
35  {
36 
39  class SPOT_API multop final: public formula
40  {
41  public:
42  enum type { Or, OrRat, And, AndRat, AndNLM, Concat, Fusion };
43 
45  typedef std::vector<const formula*> vec;
46 
58  static const formula*
59  instance(type op, const formula* first, const formula* second);
60 
122  static const formula* instance(type op, vec* v);
123 
124  virtual void accept(visitor& v) const;
125 
127  unsigned size() const
128  {
129  return children_->size();
130  }
131 
135  const formula* nth(unsigned n) const
136  {
137  return (*children_)[n];
138  }
139 
145  const formula* all_but(unsigned n) const;
146 
151  unsigned boolean_count() const;
152 
162  const formula* boolean_operands(unsigned* width = 0) const;
163 
165  type op() const
166  {
167  return op_;
168  }
169 
171  const char* op_name() const;
172 
174  virtual std::string dump() const;
175 
177  static unsigned instance_count();
178 
180  static std::ostream& dump_instances(std::ostream& os);
181 
182  protected:
183  typedef std::pair<type, vec*> key;
185  struct paircmp
186  {
187  bool
188  operator()(const key& p1, const key& p2) const
189  {
190  if (p1.first != p2.first)
191  return p1.first < p2.first;
192  return *p1.second < *p2.second;
193  }
194  };
195  typedef std::map<key, const multop*, paircmp> map;
196  static map instances;
197 
198  multop(type op, vec* v);
199  virtual ~multop();
200 
201  private:
202  type op_;
203  vec* children_;
204  };
205 
206 
211  inline
212  const multop*
213  is_multop(const formula* f)
214  {
215  if (f->kind() != formula::MultOp)
216  return 0;
217  return static_cast<const multop*>(f);
218  }
219 
224  inline
225  const multop*
226  is_multop(const formula* f, multop::type op)
227  {
228  if (const multop* mo = is_multop(f))
229  if (mo->op() == op)
230  return mo;
231  return 0;
232  }
233 
238  inline
239  const multop*
240  is_multop(const formula* f, multop::type op1, multop::type op2)
241  {
242  if (const multop* mo = is_multop(f))
243  if (mo->op() == op1 || mo->op() == op2)
244  return mo;
245  return 0;
246  }
247 
251  inline
252  const multop*
253  is_And(const formula* f)
254  {
255  return is_multop(f, multop::And);
256  }
257 
261  inline
262  const multop*
263  is_AndRat(const formula* f)
264  {
265  return is_multop(f, multop::AndRat);
266  }
267 
271  inline
272  const multop*
273  is_AndNLM(const formula* f)
274  {
275  return is_multop(f, multop::AndNLM);
276  }
277 
281  inline
282  const multop*
283  is_Or(const formula* f)
284  {
285  return is_multop(f, multop::Or);
286  }
287 
291  inline
292  const multop*
293  is_OrRat(const formula* f)
294  {
295  return is_multop(f, multop::OrRat);
296  }
297 
301  inline
302  const multop*
303  is_Concat(const formula* f)
304  {
305  return is_multop(f, multop::Concat);
306  }
307 
311  inline
312  const multop*
313  is_Fusion(const formula* f)
314  {
315  return is_multop(f, multop::Fusion);
316  }
317  }
318 }
Definition: public.hh:31
Comparison functor used internally by ltl::multop.
Definition: multop.hh:185
Multi-operand operators.
Definition: multop.hh:39
LTL formula interface.
Formula visitor.
Definition: visitor.hh:40
std::vector< const formula * > vec
List of formulae.
Definition: multop.hh:45
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:125
unsigned size() const
Get the number of children.
Definition: multop.hh:127
An LTL formula.
Definition: formula.hh:71
type op() const
Get the type of this operator.
Definition: multop.hh:165
const formula * nth(unsigned n) const
Get the nth child.
Definition: multop.hh:135

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