spot  1.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
multop.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_MULTOP_HH
26 # define SPOT_LTLAST_MULTOP_HH
27 
28 #include "refformula.hh"
29 #include <vector>
30 #include <map>
31 #include <iosfwd>
32 
33 namespace spot
34 {
35  namespace ltl
36  {
37 
40  class SPOT_API multop : public ref_formula
41  {
42  public:
43  enum type { Or, OrRat, And, AndRat, AndNLM, Concat, Fusion };
44 
46  typedef std::vector<const formula*> vec;
47 
59  static const formula*
60  instance(type op, const formula* first, const formula* second);
61 
123  static const formula* instance(type op, vec* v);
124 
125  virtual void accept(visitor& v) const;
126 
128  unsigned size() const;
132  const formula* nth(unsigned n) const;
133 
139  const formula* all_but(unsigned n) const;
140 
145  unsigned boolean_count() const;
146 
156  const formula* boolean_operands(unsigned* width = 0) const;
157 
159  type op() const;
161  const char* op_name() const;
162 
164  virtual std::string dump() const;
165 
167  static unsigned instance_count();
168 
170  static std::ostream& dump_instances(std::ostream& os);
171 
172  protected:
173  typedef std::pair<type, vec*> pair;
175  struct paircmp
176  {
177  bool
178  operator()(const pair& p1, const pair& p2) const
179  {
180  if (p1.first != p2.first)
181  return p1.first < p2.first;
182  return *p1.second < *p2.second;
183  }
184  };
185  typedef std::map<pair, const multop*, paircmp> map;
186  static map instances;
187 
188  multop(type op, vec* v);
189  virtual ~multop();
190 
191  private:
192  type op_;
193  vec* children_;
194  };
195 
196 
201  inline
202  const multop*
203  is_multop(const formula* f)
204  {
205  if (f->kind() != formula::MultOp)
206  return 0;
207  return static_cast<const multop*>(f);
208  }
209 
214  inline
215  const multop*
216  is_multop(const formula* f, multop::type op)
217  {
218  if (const multop* mo = is_multop(f))
219  if (mo->op() == op)
220  return mo;
221  return 0;
222  }
223 
228  inline
229  const multop*
230  is_multop(const formula* f, multop::type op1, multop::type op2)
231  {
232  if (const multop* mo = is_multop(f))
233  if (mo->op() == op1 || mo->op() == op2)
234  return mo;
235  return 0;
236  }
237 
241  inline
242  const multop*
243  is_And(const formula* f)
244  {
245  return is_multop(f, multop::And);
246  }
247 
251  inline
252  const multop*
253  is_AndRat(const formula* f)
254  {
255  return is_multop(f, multop::AndRat);
256  }
257 
261  inline
262  const multop*
263  is_AndNLM(const formula* f)
264  {
265  return is_multop(f, multop::AndNLM);
266  }
267 
271  inline
272  const multop*
273  is_Or(const formula* f)
274  {
275  return is_multop(f, multop::Or);
276  }
277 
281  inline
282  const multop*
283  is_OrRat(const formula* f)
284  {
285  return is_multop(f, multop::OrRat);
286  }
287 
291  inline
292  const multop*
293  is_Concat(const formula* f)
294  {
295  return is_multop(f, multop::Concat);
296  }
297 
301  inline
302  const multop*
303  is_Fusion(const formula* f)
304  {
305  return is_multop(f, multop::Fusion);
306  }
307  }
308 }
309 
310 #endif // SPOT_LTLAST_MULTOP_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Dec 11 2013 10:35:46 for spot by doxygen 1.8.4