spot
0.9.1
|
00001 // Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et 00002 // Développement de l'Epita (LRDE). 00003 // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 00004 // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), 00005 // Université Pierre et Marie Curie. 00006 // 00007 // This file is part of Spot, a model checking library. 00008 // 00009 // Spot is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Spot is distributed in the hope that it will be useful, but WITHOUT 00015 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00016 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00017 // License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Spot; see the file COPYING. If not, write to the Free 00021 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00022 // 02111-1307, USA. 00023 00026 #ifndef SPOT_LTLAST_MULTOP_HH 00027 # define SPOT_LTLAST_MULTOP_HH 00028 00029 #include <vector> 00030 #include <map> 00031 #include <iosfwd> 00032 #include "refformula.hh" 00033 00034 namespace spot 00035 { 00036 namespace ltl 00037 { 00038 00041 class multop : public ref_formula 00042 { 00043 public: 00044 enum type { Or, OrRat, And, AndRat, AndNLM, Concat, Fusion }; 00045 00047 typedef std::vector<const formula*> vec; 00048 00060 static const formula* 00061 instance(type op, const formula* first, const formula* second); 00062 00124 static const formula* instance(type op, vec* v); 00125 00126 virtual void accept(visitor& v) const; 00127 00129 unsigned size() const; 00133 const formula* nth(unsigned n) const; 00134 00140 const formula* all_but(unsigned n) const; 00141 00143 type op() const; 00145 const char* op_name() const; 00146 00148 virtual std::string dump() const; 00149 00151 static unsigned instance_count(); 00152 00154 static std::ostream& dump_instances(std::ostream& os); 00155 00156 protected: 00157 typedef std::pair<type, vec*> pair; 00159 struct paircmp 00160 { 00161 bool 00162 operator () (const pair& p1, const pair& p2) const 00163 { 00164 if (p1.first != p2.first) 00165 return p1.first < p2.first; 00166 return *p1.second < *p2.second; 00167 } 00168 }; 00169 typedef std::map<pair, const multop*, paircmp> map; 00170 static map instances; 00171 00172 multop(type op, vec* v); 00173 virtual ~multop(); 00174 00175 private: 00176 type op_; 00177 vec* children_; 00178 }; 00179 00180 00185 inline 00186 const multop* 00187 is_multop(const formula* f) 00188 { 00189 if (f->kind() != formula::MultOp) 00190 return 0; 00191 return static_cast<const multop*>(f); 00192 } 00193 00198 inline 00199 const multop* 00200 is_multop(const formula* f, multop::type op) 00201 { 00202 if (const multop* mo = is_multop(f)) 00203 if (mo->op() == op) 00204 return mo; 00205 return 0; 00206 } 00207 00212 inline 00213 const multop* 00214 is_multop(const formula* f, multop::type op1, multop::type op2) 00215 { 00216 if (const multop* mo = is_multop(f)) 00217 if (mo->op() == op1 || mo->op() == op2) 00218 return mo; 00219 return 0; 00220 } 00221 00225 inline 00226 const multop* 00227 is_And(const formula* f) 00228 { 00229 return is_multop(f, multop::And); 00230 } 00231 00235 inline 00236 const multop* 00237 is_AndRat(const formula* f) 00238 { 00239 return is_multop(f, multop::AndRat); 00240 } 00241 00245 inline 00246 const multop* 00247 is_AndNLM(const formula* f) 00248 { 00249 return is_multop(f, multop::AndNLM); 00250 } 00251 00255 inline 00256 const multop* 00257 is_Or(const formula* f) 00258 { 00259 return is_multop(f, multop::Or); 00260 } 00261 00265 inline 00266 const multop* 00267 is_OrRat(const formula* f) 00268 { 00269 return is_multop(f, multop::OrRat); 00270 } 00271 00275 inline 00276 const multop* 00277 is_Concat(const formula* f) 00278 { 00279 return is_multop(f, multop::Concat); 00280 } 00281 00285 inline 00286 const multop* 00287 is_Fusion(const formula* f) 00288 { 00289 return is_multop(f, multop::Fusion); 00290 } 00291 } 00292 } 00293 00294 #endif // SPOT_LTLAST_MULTOP_HH