Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

iointerface.h

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; -*-
00002 
00003 /* libutap - Uppaal Timed Automata Parser.
00004    Copyright (C) 2002-2003 Uppsala University and Aalborg University.
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public License
00008    as published by the Free Software Foundation; either version 2.1 of
00009    the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful, but
00012    WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with this library; if not, write to the Free Software
00018    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00019    USA
00020 */
00021 
00035 #ifndef UTAP_IOINTERFACE_HH
00036 #define UTAP_IOINTERFACE_HH
00037 
00038 #include "utap/system.h"
00039 #include "utap/statement.h"
00040 
00041 /* Usually already included in includes above: */
00042 #include <list>
00043 #include <set>
00044 #include <map>
00045 
00046 /* Header-specific includes: */
00047 #include <stack>
00048 
00049 namespace UTAP {
00056     class IOInterface: public StatementVisitor
00057     {
00058     protected:
00059         struct less_str { // must be somewhere in utilities, replace if found
00060             bool operator()(const char* s1, const char* s2){
00061                 return (strcmp(s1,s2)<0);
00062             }
00063         };
00064         typedef std::set<const char*, less_str> strs_t;// string set
00065         struct iota_t; // info on TA process
00066         typedef std::map<const iota_t*, strs_t> iota2strs_t;//TA->string set
00067         typedef std::map<const char*, strs_t> str2strs_t;//string->string set
00068 
00069         typedef struct iota_t { // input/output info on timed automaton
00070             const char* name; // name of the process (timed automaton)
00071             strs_t inChans, outChans; // input/output channels used by TA
00072             str2strs_t rdVars, wtVars; // variables with accessing channels
00073             iota2strs_t outEdges; // index of outChans sorted by destination TA
00074             iota_t(const char* _name): name(_name) {}
00075         };
00076         typedef std::map<const char*, std::set<iota_t*>, less_str> str2tas_t;
00077         const char* title; // title of the TA system
00078         std::list<iota_t> automata; // list of all automata in the system
00079         str2tas_t receivers, transmiters;// TAs by vars/chans they access
00080         strs_t procs, channels, variables;
00081         iota_t* cTA; // current automaton in traversal
00082         instance_t* cP; // current process in traversal
00083         const char* cChan; // channel on current transition in traversal
00084         bool inp, out, sync, paramsExpanded;// current expression state
00085         std::stack<std::pair<bool, bool> > ioStack;// remember I/O state
00086 
00087         bool checkParams(const symbol_t &s);// maps parameter to global symbol
00088         void addChan(const symbol_t &, strs_t &, str2tas_t&);
00089         void addVar(const symbol_t &, str2strs_t&, str2tas_t&);
00090         void visitProcess(instance_t &);
00091         void visitExpression(const expression_t &);
00092         void pushIO(){
00093             ioStack.push(std::make_pair<bool, bool>(inp, out));
00094         }
00095         void popIO() {
00096             inp = ioStack.top().first;
00097             out = ioStack.top().second;
00098             ioStack.pop();
00099         }
00100 
00101     public:
00105         IOInterface(const char* _title, TimedAutomataSystem& ta);
00110         virtual ~IOInterface() {}
00111 
00115         void printForTron(std::ostream &os);
00116 
00123         void printForDot(std::ostream &os, bool ranked, bool erd, bool cEdged);
00124 
00130         int32_t visitEmptyStatement(EmptyStatement *stat);
00131         int32_t visitExprStatement(ExprStatement *stat);
00132         int32_t visitForStatement(ForStatement *stat);
00133         int32_t visitIterationStatement(IterationStatement *stat);
00134         int32_t visitWhileStatement(WhileStatement *stat);
00135         int32_t visitDoWhileStatement(DoWhileStatement *stat);
00136         int32_t visitBlockStatement(BlockStatement *stat);
00137         int32_t visitSwitchStatement(SwitchStatement *stat);
00138         int32_t visitCaseStatement(CaseStatement *stat);
00139         int32_t visitDefaultStatement(DefaultStatement *stat);
00140         int32_t visitIfStatement(IfStatement *stat);
00141         int32_t visitBreakStatement(BreakStatement *stat);
00142         int32_t visitContinueStatement(ContinueStatement *stat);
00143         int32_t visitReturnStatement(ReturnStatement *stat);
00144     };
00145 }
00146 
00147 #endif

Generated on Sat Apr 29 21:02:14 2006 for libutap by  doxygen 1.4.2