Doxygen
DotRunner类 参考

Helper class to run dot from doxygen from multiple threads. 更多...

#include <dotrunner.h>

+ DotRunner 的协作图:

struct  DotJob
 

Public 成员函数

 DotRunner (const QCString &absDotName, const QCString &md5Hash=QCString())
 Creates a runner for a dot file. 更多...
 
void addJob (const QCString &format, const QCString &output, const QCString &srcFile, int srcLine)
 Adds an additional job to the run. 更多...
 
void preventCleanUp ()
 Prevent cleanup of the dot file (for user provided dot files) 更多...
 
bool run ()
 Runs dot for all jobs added. 更多...
 
QCString getMd5Hash ()
 

静态 Public 成员函数

static bool readBoundingBox (const QCString &fileName, int *width, int *height, bool isEps)
 

Private 属性

QCString m_file
 
QCString m_md5Hash
 
QCString m_dotExe
 
bool m_cleanUp
 
std::vector< DotJobm_jobs
 

详细描述

Helper class to run dot from doxygen from multiple threads.


在文件 dotrunner.h30 行定义.

构造及析构函数说明

◆ DotRunner()

DotRunner::DotRunner ( const QCString absDotName,
const QCString md5Hash = QCString() 
)

Creates a runner for a dot file.

在文件 dotrunner.cpp141 行定义.

142  : m_file(absDotName)
143  , m_md5Hash(md5Hash)
144  , m_dotExe(Config_getString(DOT_PATH)+"dot")
145  , m_cleanUp(Config_getBool(DOT_CLEANUP))
146 {
147 }

成员函数说明

◆ addJob()

void DotRunner::addJob ( const QCString format,
const QCString output,
const QCString srcFile,
int  srcLine 
)

Adds an additional job to the run.

Performing multiple jobs one file can be faster.

在文件 dotrunner.cpp150 行定义.

152 {
153 
154  for (auto& s: m_jobs)
155  {
156  if (s.format != format) continue;
157  if (s.output != output) continue;
158  // we have this job already
159  return;
160  }
161  auto args = QCString("-T") + format + " -o \"" + output + "\"";
162  m_jobs.emplace_back(format.str(), output, args, srcFile, srcLine);
163 }

引用了 m_jobs , 以及 QCString::str().

被这些函数引用 DotGraph::prepareDotFile(), writeDotGraphFromFile() , 以及 writeDotImageMapFromFile().

◆ getMd5Hash()

QCString DotRunner::getMd5Hash ( )
inline

在文件 dotrunner.h72 行定义.

74 {

◆ preventCleanUp()

void DotRunner::preventCleanUp ( )
inline

Prevent cleanup of the dot file (for user provided dot files)

在文件 dotrunner.h67 行定义.

被这些函数引用 writeDotGraphFromFile() , 以及 writeDotImageMapFromFile().

◆ readBoundingBox()

bool DotRunner::readBoundingBox ( const QCString fileName,
int *  width,
int *  height,
bool  isEps 
)
static

在文件 dotrunner.cpp107 行定义.

108 {
109  const char *bb = isEps ? "%%PageBoundingBox:" : "/MediaBox [";
110  int bblen = (int)strlen(bb);
111  FILE *f = Portable::fopen(fileName,"rb");
112  if (!f)
113  {
114  //printf("readBoundingBox: could not open %s\n",fileName);
115  return FALSE;
116  }
117  const int maxLineLen=1024;
118  char buf[maxLineLen];
119  while (fgets(buf,maxLineLen,f)!=NULL)
120  {
121  const char *p = strstr(buf,bb);
122  if (p) // found PageBoundingBox or /MediaBox string
123  {
124  int x,y;
125  fclose(f);
126  if (sscanf(p+bblen,"%d %d %d %d",&x,&y,width,height)!=4)
127  {
128  //printf("readBoundingBox sscanf fail\n");
129  return FALSE;
130  }
131  return TRUE;
132  }
133  }
134  err("Failed to extract bounding box from generated diagram file %s\n",qPrint(fileName));
135  fclose(f);
136  return FALSE;
137 }

引用了 err(), FALSE, Portable::fclose(), Portable::fopen(), qPrint() , 以及 TRUE.

被这些函数引用 run() , 以及 DotFilePatcher::writeVecGfxFigure().

◆ run()

bool DotRunner::run ( )

Runs dot for all jobs added.

在文件 dotrunner.cpp172 行定义.

173 {
174  int exitCode=0;
175 
176  QCString dotArgs;
177 
178  QCString srcFile;
179  int srcLine=-1;
180 
181  // create output
182  if (Config_getBool(DOT_MULTI_TARGETS))
183  {
184  dotArgs=QCString("\"")+m_file+"\"";
185  for (auto& s: m_jobs)
186  {
187  dotArgs+=' ';
188  dotArgs+=s.args;
189  }
190  if (!m_jobs.empty())
191  {
192  srcFile = m_jobs.front().srcFile;
193  srcLine = m_jobs.front().srcLine;
194  }
195  if ((exitCode=Portable::system(m_dotExe,dotArgs,FALSE))!=0) goto error;
196  }
197  else
198  {
199  for (auto& s : m_jobs)
200  {
201  srcFile = s.srcFile;
202  srcLine = s.srcLine;
203  dotArgs=QCString("\"")+m_file+"\" "+s.args;
204  if ((exitCode=Portable::system(m_dotExe,dotArgs,FALSE))!=0) goto error;
205  }
206  }
207 
208  // check output
209  // As there should be only one pdf file be generated, we don't need code for regenerating multiple pdf files in one call
210  for (auto& s : m_jobs)
211  {
212  if (s.format.left(3)=="pdf")
213  {
214  int width=0,height=0;
215  if (!readBoundingBox(s.output,&width,&height,FALSE)) goto error;
216  if ((width > MAX_LATEX_GRAPH_SIZE) || (height > MAX_LATEX_GRAPH_SIZE))
217  {
218  if (!resetPDFSize(width,height,getBaseNameOfOutput(s.output))) goto error;
219  dotArgs=QCString("\"")+m_file+"\" "+s.args;
220  if ((exitCode=Portable::system(m_dotExe,dotArgs,FALSE))!=0) goto error;
221  }
222  }
223 
224  if (s.format.left(3)=="png")
225  {
226  checkPngResult(s.output);
227  }
228  }
229 
230  // remove .dot files
231  if (m_cleanUp)
232  {
233  //printf("removing dot file %s\n",qPrint(m_file));
235  }
236 
237  // create checksum file
238  if (!m_md5Hash.isEmpty())
239  {
240  QCString md5Name = getBaseNameOfOutput(m_file) + ".md5";
241  FILE *f = Portable::fopen(md5Name,"w");
242  if (f)
243  {
244  fwrite(m_md5Hash.data(),1,32,f);
245  fclose(f);
246  }
247  }
248  return TRUE;
249 error:
250  err_full(srcFile,srcLine,"Problems running dot: exit code=%d, command='%s', arguments='%s'\n",
251  exitCode,qPrint(m_dotExe),qPrint(dotArgs));
252  return FALSE;
253 }

引用了 checkPngResult(), Config_getBool, QCString::data(), err_full(), FALSE, Portable::fclose(), Portable::fopen(), getBaseNameOfOutput(), QCString::isEmpty(), m_cleanUp, m_dotExe, m_file, m_jobs, m_md5Hash, MAX_LATEX_GRAPH_SIZE, qPrint(), readBoundingBox(), resetPDFSize(), Portable::system(), TRUE , 以及 Portable::unlink().

被这些函数引用 DotWorkerThread::run(), writeDotGraphFromFile() , 以及 writeDotImageMapFromFile().

类成员变量说明

◆ m_cleanUp

bool DotRunner::m_cleanUp
private

在文件 dotrunner.h80 行定义.

被这些函数引用 run().

◆ m_dotExe

QCString DotRunner::m_dotExe
private

在文件 dotrunner.h79 行定义.

被这些函数引用 run().

◆ m_file

QCString DotRunner::m_file
private

在文件 dotrunner.h77 行定义.

被这些函数引用 run().

◆ m_jobs

std::vector<DotJob> DotRunner::m_jobs
private

在文件 dotrunner.h81 行定义.

被这些函数引用 addJob() , 以及 run().

◆ m_md5Hash

QCString DotRunner::m_md5Hash
private

在文件 dotrunner.h78 行定义.

被这些函数引用 run().


该类的文档由以下文件生成:
Portable::fopen
FILE * fopen(const QCString &fileName, const QCString &mode)
Definition: portable.cpp:322
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
DotRunner::m_cleanUp
bool m_cleanUp
Definition: dotrunner.h:80
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
MAX_LATEX_GRAPH_SIZE
#define MAX_LATEX_GRAPH_SIZE
Definition: dotrunner.cpp:30
DotRunner::readBoundingBox
static bool readBoundingBox(const QCString &fileName, int *width, int *height, bool isEps)
Definition: dotrunner.cpp:107
DotRunner::m_file
QCString m_file
Definition: dotrunner.h:77
Portable::fclose
int fclose(FILE *f)
Definition: portable.cpp:342
DotRunner::m_md5Hash
QCString m_md5Hash
Definition: dotrunner.h:78
TRUE
#define TRUE
Definition: qcstring.h:36
Portable::system
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition: portable.cpp:42
resetPDFSize
static bool resetPDFSize(const int width, const int height, const QCString &base)
Definition: dotrunner.cpp:65
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
DotRunner::m_jobs
std::vector< DotJob > m_jobs
Definition: dotrunner.h:81
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
err_full
void err_full(const QCString &file, int line, const char *fmt,...)
Definition: message.cpp:212
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
DotRunner::m_dotExe
QCString m_dotExe
Definition: dotrunner.h:79
Portable::unlink
void unlink(const QCString &fileName)
Definition: portable.cpp:525
getBaseNameOfOutput
QCString getBaseNameOfOutput(const QCString &output)
Definition: dotrunner.cpp:165
checkPngResult
static void checkPngResult(const QCString &imgName)
Definition: dotrunner.cpp:36
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108