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_UNOP_HH 00027 # define SPOT_LTLAST_UNOP_HH 00028 00029 #include <map> 00030 #include <iosfwd> 00031 #include "refformula.hh" 00032 #include "bunop.hh" 00033 00034 namespace spot 00035 { 00036 namespace ltl 00037 { 00038 00041 class unop : public ref_formula 00042 { 00043 public: 00044 enum type { 00045 // LTL 00046 Not, X, F, G, 00047 // ELTL 00048 Finish, 00049 // Closure 00050 Closure, NegClosure, NegClosureMarked 00051 }; 00052 00090 static const formula* instance(type op, const formula* child); 00091 00092 virtual void accept(visitor& v) const; 00093 00095 const formula* child() const; 00096 00098 type op() const; 00100 const char* op_name() const; 00101 00103 virtual std::string dump() const; 00104 00106 static unsigned instance_count(); 00107 00109 static std::ostream& dump_instances(std::ostream& os); 00110 00111 protected: 00112 typedef std::pair<type, const formula*> pair; 00113 typedef std::map<pair, const unop*> map; 00114 static map instances; 00115 00116 unop(type op, const formula* child); 00117 virtual ~unop(); 00118 00119 private: 00120 type op_; 00121 const formula* child_; 00122 }; 00123 00124 00129 inline 00130 const unop* 00131 is_unop(const formula* f) 00132 { 00133 if (f->kind() != formula::UnOp) 00134 return 0; 00135 return static_cast<const unop*>(f); 00136 } 00137 00142 inline 00143 const unop* 00144 is_unop(const formula* f, unop::type op) 00145 { 00146 if (const unop* uo = is_unop(f)) 00147 if (uo->op() == op) 00148 return uo; 00149 return 0; 00150 } 00151 00155 inline 00156 const unop* 00157 is_Not(const formula* f) 00158 { 00159 return is_unop(f, unop::Not); 00160 } 00161 00165 inline 00166 const unop* 00167 is_X(const formula* f) 00168 { 00169 return is_unop(f, unop::X); 00170 } 00171 00175 inline 00176 const unop* 00177 is_F(const formula* f) 00178 { 00179 return is_unop(f, unop::F); 00180 } 00181 00185 inline 00186 const unop* 00187 is_G(const formula* f) 00188 { 00189 return is_unop(f, unop::G); 00190 } 00191 00195 inline 00196 const unop* 00197 is_GF(const formula* f) 00198 { 00199 if (const unop* op = is_G(f)) 00200 return is_F(op->child()); 00201 return 0; 00202 } 00203 00207 inline 00208 const unop* 00209 is_FG(const formula* f) 00210 { 00211 if (const unop* op = is_F(f)) 00212 return is_G(op->child()); 00213 return 0; 00214 } 00215 } 00216 } 00217 00218 #endif // SPOT_LTLAST_UNOP_HH