spot  0.9.2
multop.hh
Go to the documentation of this file.
1 // Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
2 // Développement de l'Epita (LRDE).
3 // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris
4 // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
5 // Université Pierre et Marie Curie.
6 //
7 // This file is part of Spot, a model checking library.
8 //
9 // Spot is free software; you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Spot is distributed in the hope that it will be useful, but WITHOUT
15 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 // License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Spot; see the file COPYING. If not, write to the Free
21 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 // 02111-1307, USA.
23 
26 #ifndef SPOT_LTLAST_MULTOP_HH
27 # define SPOT_LTLAST_MULTOP_HH
28 
29 #include <vector>
30 #include <map>
31 #include <iosfwd>
32 #include "refformula.hh"
33 
34 namespace spot
35 {
36  namespace ltl
37  {
38 
41  class multop : public ref_formula
42  {
43  public:
45 
47  typedef std::vector<const formula*> vec;
48 
60  static const formula*
61  instance(type op, const formula* first, const formula* second);
62 
124  static const formula* instance(type op, vec* v);
125 
126  virtual void accept(visitor& v) const;
127 
129  unsigned size() const;
133  const formula* nth(unsigned n) const;
134 
140  const formula* all_but(unsigned n) const;
141 
143  type op() const;
145  const char* op_name() const;
146 
148  virtual std::string dump() const;
149 
151  static unsigned instance_count();
152 
154  static std::ostream& dump_instances(std::ostream& os);
155 
156  protected:
157  typedef std::pair<type, vec*> pair;
159  struct paircmp
160  {
161  bool
162  operator () (const pair& p1, const pair& p2) const
163  {
164  if (p1.first != p2.first)
165  return p1.first < p2.first;
166  return *p1.second < *p2.second;
167  }
168  };
169  typedef std::map<pair, const multop*, paircmp> map;
170  static map instances;
171 
172  multop(type op, vec* v);
173  virtual ~multop();
174 
175  private:
178  };
179 
180 
185  inline
186  const multop*
187  is_multop(const formula* f)
188  {
189  if (f->kind() != formula::MultOp)
190  return 0;
191  return static_cast<const multop*>(f);
192  }
193 
198  inline
199  const multop*
201  {
202  if (const multop* mo = is_multop(f))
203  if (mo->op() == op)
204  return mo;
205  return 0;
206  }
207 
212  inline
213  const multop*
215  {
216  if (const multop* mo = is_multop(f))
217  if (mo->op() == op1 || mo->op() == op2)
218  return mo;
219  return 0;
220  }
221 
225  inline
226  const multop*
227  is_And(const formula* f)
228  {
229  return is_multop(f, multop::And);
230  }
231 
235  inline
236  const multop*
237  is_AndRat(const formula* f)
238  {
239  return is_multop(f, multop::AndRat);
240  }
241 
245  inline
246  const multop*
247  is_AndNLM(const formula* f)
248  {
249  return is_multop(f, multop::AndNLM);
250  }
251 
255  inline
256  const multop*
257  is_Or(const formula* f)
258  {
259  return is_multop(f, multop::Or);
260  }
261 
265  inline
266  const multop*
267  is_OrRat(const formula* f)
268  {
269  return is_multop(f, multop::OrRat);
270  }
271 
275  inline
276  const multop*
277  is_Concat(const formula* f)
278  {
279  return is_multop(f, multop::Concat);
280  }
281 
285  inline
286  const multop*
287  is_Fusion(const formula* f)
288  {
289  return is_multop(f, multop::Fusion);
290  }
291  }
292 }
293 
294 #endif // SPOT_LTLAST_MULTOP_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Jul 2 2012 17:35:47 for spot by doxygen 1.8.1.1