pd_debug.cpp
Go to the documentation of this file.
1 /** @file pd_debug.cpp Debug functions */
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013/14 Ramon Barakat, Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 #include "pd_debug.h"
11 
12 namespace faudes {
13 
14 //count number of files
15 int fileCounter = 0;
16 
17 void debug_printf(const std::string& msg, const PushdownGenerator& pd){
18  if (PD_DEBUG_LEVEL > 0)
19  std::cout << msg << std::endl;
20  if (PD_DEBUG_LEVEL > 1)
21  ToFile(pd, msg);
22 }
23 
24 void debug_printf(const std::string& msg, const std::string& tex){
25  if (PD_DEBUG_LEVEL > 0)
26  std::cout << msg << std::endl;
27  if (PD_DEBUG_LEVEL > 1 && tex != "")
28  ToFile(tex, msg);
29 }
30 
31 
32 //***************************************************************
33 // print files options
34 // **************************************************************
35 
36 void ToFile(const PushdownGenerator& p, std::string name, bool printDOT, bool printPNG) {
37  std::stringstream fileName;
38  fileName << "pd." << std::setfill('0') << std::setw(5) << fileCounter << name;
39 
40  try {
41  if ((PD_DEBUG_MAX_TRANS >= p.TransRelSize())) {
42  if(printDOT|| printPNG){
43  std::cout << "print file '" << name << "'...";
44 
45  if(printPNG)
46  p.GraphWrite(fileName.str() + ".png");
47  if(printDOT)
48  p.DotWrite(fileName.str() + ".dot");
49 
50  std::cout << "done." << std::endl;
51  }
52  } else
53  std::cout << "ToFile:Graph get more than " << PD_DEBUG_MAX_TRANS
54  << " Transitions !" << std::endl;
55 
56  } catch (faudes::Exception& exception) {
57  std::cout << "ToFile: Graph error for '" << name << "'" << std::endl;
58  }
59 
60  fileCounter++;
61 }
62 
63 void ToFile(const std::string& tex, std::string name) {
64  std::cout << "print file '" << name << "'...";
65  std::stringstream fileName;
66  fileName << "pd." << std::setfill('0') << std::setw(5) << fileCounter << name << ".tex";
67  std::ofstream out(fileName.str().c_str());
68  out << tex;
69 
70  std::cout << "done." << std::endl;
71 
72  fileCounter++;
73 }
74 
75 
76 }
77 

libFAUDES 2.28c --- 2016.09.30 --- c++ api documentaion by doxygen