include/DotConverter.hpp

Go to the documentation of this file.
00001 // DotConverter.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2007 Julien DAVID.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 //
00016 #ifndef DOTCONVERTER
00017 #define DOTCONVERTER
00018 
00019 #include "Converter.hpp"
00020 
00021 namespace regal{
00022   
00023   class DotConverter:public Converter{
00024   private:
00025     char * name;
00026   public:
00027     
00031     void draw_node(char * & name,int posx,int posy,bool initial,bool final){
00032       if(final)
00033         fprintf(output,"\"%s\" [shape = doublecircle];\n",name);
00034       if(initial)
00035         fprintf(output,"\"%s\" [style=filled,color=lightgrey];\n",name);
00036     }
00037     
00038     
00043     void draw_edge(char * & start,char * & end,char * & word){
00044       fprintf(output,"%s -> %s [ label = \"%s\" ]\n",start,end,word);;
00045     }
00046     
00047     
00053     void beginAutomaton(const int & sizeX,const int & sizeY){
00054       fprintf(output,"digraph automaton{\n");
00055       fprintf(output,"graph [label = \"%s\",]\n",name);
00056     }
00057     
00061     void endAutomaton(){
00062       fprintf(output,"}\n\n");
00063     }
00064     
00069     DotConverter(const char *  path){
00070       if((output=fopen(path,"w"))==NULL)
00071         throw new InvalidFileException();
00072       name=(char *)malloc(sizeof(char)*(strlen(path)+1));
00073       sprintf(name,"%s",path);
00074       verbose("Creation of a DotConverter");
00075     }
00076     
00080     ~DotConverter(){
00081       fclose(output);
00082       free(name);
00083       verbose("Destruction of a DotConverter");
00084     }
00085     
00086   };
00087   
00088 }
00089 
00090 #endif

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1