spot  1.2.6
 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, 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 #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
129  {
130  return children_->size();
131  }
132 
136  const formula* nth(unsigned n) const
137  {
138  return (*children_)[n];
139  }
140 
146  const formula* all_but(unsigned n) const;
147 
152  unsigned boolean_count() const;
153 
163  const formula* boolean_operands(unsigned* width = 0) const;
164 
166  type op() const
167  {
168  return op_;
169  }
170 
172  const char* op_name() const;
173 
175  virtual std::string dump() const;
176 
178  static unsigned instance_count();
179 
181  static std::ostream& dump_instances(std::ostream& os);
182 
183  protected:
184  typedef std::pair<type, vec*> pair;
186  struct paircmp
187  {
188  bool
189  operator()(const pair& p1, const pair& p2) const
190  {
191  if (p1.first != p2.first)
192  return p1.first < p2.first;
193  return *p1.second < *p2.second;
194  }
195  };
196  typedef std::map<pair, const multop*, paircmp> map;
197  static map instances;
198 
199  multop(type op, vec* v);
200  virtual ~multop();
201 
202  private:
203  type op_;
204  vec* children_;
205  };
206 
207 
212  inline
213  const multop*
214  is_multop(const formula* f)
215  {
216  if (f->kind() != formula::MultOp)
217  return 0;
218  return static_cast<const multop*>(f);
219  }
220 
225  inline
226  const multop*
227  is_multop(const formula* f, multop::type op)
228  {
229  if (const multop* mo = is_multop(f))
230  if (mo->op() == op)
231  return mo;
232  return 0;
233  }
234 
239  inline
240  const multop*
241  is_multop(const formula* f, multop::type op1, multop::type op2)
242  {
243  if (const multop* mo = is_multop(f))
244  if (mo->op() == op1 || mo->op() == op2)
245  return mo;
246  return 0;
247  }
248 
252  inline
253  const multop*
254  is_And(const formula* f)
255  {
256  return is_multop(f, multop::And);
257  }
258 
262  inline
263  const multop*
264  is_AndRat(const formula* f)
265  {
266  return is_multop(f, multop::AndRat);
267  }
268 
272  inline
273  const multop*
274  is_AndNLM(const formula* f)
275  {
276  return is_multop(f, multop::AndNLM);
277  }
278 
282  inline
283  const multop*
284  is_Or(const formula* f)
285  {
286  return is_multop(f, multop::Or);
287  }
288 
292  inline
293  const multop*
294  is_OrRat(const formula* f)
295  {
296  return is_multop(f, multop::OrRat);
297  }
298 
302  inline
303  const multop*
304  is_Concat(const formula* f)
305  {
306  return is_multop(f, multop::Concat);
307  }
308 
312  inline
313  const multop*
314  is_Fusion(const formula* f)
315  {
316  return is_multop(f, multop::Fusion);
317  }
318  }
319 }
320 
321 #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 Sat Dec 6 2014 12:28:43 for spot by doxygen 1.8.4