spot  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bunop.hh
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche
3 // et Développement de l'Epita (LRDE).
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
22 #ifndef SPOT_LTLAST_BUNOP_HH
23 # define SPOT_LTLAST_BUNOP_HH
24 
25 #include "refformula.hh"
26 #include <map>
27 #include <iosfwd>
28 #include "constant.hh"
29 
30 namespace spot
31 {
32  namespace ltl
33  {
34 
37  class SPOT_API bunop : public ref_formula
38  {
39  public:
40  enum type { Star };
41 
42  static const unsigned unbounded = -1U;
43 
59  static const formula* instance(type op,
60  const formula* child,
61  unsigned min = 0,
62  unsigned max = unbounded);
63 
73  static const formula* sugar_goto(const formula* child,
74  unsigned min = 1,
75  unsigned max = unbounded);
76 
83  static const formula* sugar_equal(const formula* child,
84  unsigned min = 0,
85  unsigned max = unbounded);
86 
87  virtual void accept(visitor& v) const;
88 
90  const formula* child() const
91  {
92  return child_;
93  }
94 
96  unsigned min() const
97  {
98  return min_;
99  }
100 
102  unsigned max() const
103  {
104  return max_;
105  }
106 
110  std::string format() const;
111 
113  type op() const
114  {
115  return op_;
116  }
117 
119  const char* op_name() const;
120 
122  virtual std::string dump() const;
123 
125  static unsigned instance_count();
126 
128  static std::ostream& dump_instances(std::ostream& os);
129 
135  static const formula* one_star()
136  {
137  if (!one_star_)
138  one_star_ = instance(Star, constant::true_instance());
139  return one_star_;
140  }
141 
142  protected:
143  typedef std::pair<unsigned, unsigned> pairu;
144  typedef std::pair<type, const formula*> pairo;
145  typedef std::pair<pairo, pairu> pair;
146  typedef std::map<pair, const bunop*> map;
147  static map instances;
148 
149  bunop(type op, const formula* child, unsigned min, unsigned max);
150  virtual ~bunop();
151 
152  private:
153  type op_;
154  const formula* child_;
155  unsigned min_;
156  unsigned max_;
157  static const formula* one_star_;
158  };
159 
164  inline
165  const bunop*
166  is_bunop(const formula* f)
167  {
168  if (f->kind() != formula::BUnOp)
169  return 0;
170  return static_cast<const bunop*>(f);
171  }
172 
177  inline
178  const bunop*
179  is_bunop(const formula* f, bunop::type op)
180  {
181  if (const bunop* bo = is_bunop(f))
182  if (bo->op() == op)
183  return bo;
184  return 0;
185  }
186 
190  inline
191  const bunop*
192  is_Star(const formula* f)
193  {
194  return is_bunop(f, bunop::Star);
195  }
196 
200  inline
201  const bunop*
202  is_KleenStar(const formula* f)
203  {
204  if (const bunop* b = is_Star(f))
205  if (b->min() == 0 && b->max() == bunop::unbounded)
206  return b;
207  return 0;
208  }
209 
210  }
211 }
212 #endif // SPOT_LTLAST_BUNOP_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Thu May 15 2014 11:04:11 for spot by doxygen 1.8.4