spot  0.9.2
bunop.hh
Go to the documentation of this file.
1 // Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et Développement
2 // de l'Epita (LRDE).
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Spot; see the file COPYING. If not, write to the Free
18 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 // 02111-1307, USA.
20 
23 #ifndef SPOT_LTLAST_BUNOP_HH
24 # define SPOT_LTLAST_BUNOP_HH
25 
26 #include <map>
27 #include <iosfwd>
28 #include "refformula.hh"
29 #include "constant.hh"
30 
31 namespace spot
32 {
33  namespace ltl
34  {
35 
38  class bunop : public ref_formula
39  {
40  public:
41  enum type { Star };
42 
43  static const unsigned unbounded = -1U;
44 
60  static const formula* instance(type op,
61  const formula* child,
62  unsigned min = 0,
63  unsigned max = unbounded);
64 
74  static const formula* sugar_goto(const formula* child,
75  unsigned min = 1,
76  unsigned max = unbounded);
77 
84  static const formula* sugar_equal(const formula* child,
85  unsigned min = 0,
86  unsigned max = unbounded);
87 
88  virtual void accept(visitor& v) const;
89 
91  const formula* child() const;
92 
94  unsigned min() const;
96  unsigned max() const;
97 
101  std::string format() const;
102 
104  type op() const;
106  const char* op_name() const;
107 
109  virtual std::string dump() const;
110 
112  static unsigned instance_count();
113 
115  static std::ostream& dump_instances(std::ostream& os);
116 
122  static const formula* one_star()
123  {
124  if (!one_star_)
126  return one_star_;
127  }
128 
129  protected:
130  typedef std::pair<unsigned, unsigned> pairu;
131  typedef std::pair<type, const formula*> pairo;
132  typedef std::pair<pairo, pairu> pair;
133  typedef std::map<pair, const bunop*> map;
134  static map instances;
135 
136  bunop(type op, const formula* child, unsigned min, unsigned max);
137  virtual ~bunop();
138 
139  private:
141  const formula* child_;
142  unsigned min_;
143  unsigned max_;
144  static const formula* one_star_;
145  };
146 
151  inline
152  const bunop*
153  is_bunop(const formula* f)
154  {
155  if (f->kind() != formula::BUnOp)
156  return 0;
157  return static_cast<const bunop*>(f);
158  }
159 
164  inline
165  const bunop*
167  {
168  if (const bunop* bo = is_bunop(f))
169  if (bo->op() == op)
170  return bo;
171  return 0;
172  }
173 
177  inline
178  const bunop*
179  is_Star(const formula* f)
180  {
181  return is_bunop(f, bunop::Star);
182  }
183 
187  inline
188  const bunop*
190  {
191  if (const bunop* b = is_Star(f))
192  if (b->min() == 0 && b->max() == bunop::unbounded)
193  return b;
194  return 0;
195  }
196 
197  }
198 }
199 #endif // SPOT_LTLAST_BUNOP_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