summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dot.cpp35
-rw-r--r--src/dot.h6
-rw-r--r--src/dotgraph.cpp4
-rw-r--r--src/dotrunner.cpp16
-rw-r--r--src/dotrunner.h6
5 files changed, 34 insertions, 33 deletions
diff --git a/src/dot.cpp b/src/dot.cpp
index f26bee4..2e07a78 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -83,9 +83,8 @@ DotManager *DotManager::instance()
return m_theInstance;
}
-DotManager::DotManager() : m_runners(1009), m_filePatchers(1009)
+DotManager::DotManager() : m_runners(), m_filePatchers(1009)
{
- m_runners.setAutoDelete(TRUE);
m_filePatchers.setAutoDelete(TRUE);
m_queue = new DotRunnerQueue;
int i;
@@ -114,23 +113,25 @@ DotManager::~DotManager()
delete m_queue;
}
-DotRunner* DotManager::createRunner(const QCString& absDotName, const QCString& md5Hash)
+DotRunner* DotManager::createRunner(const std::string &absDotName, const std::string& md5Hash)
{
- DotRunner * run = m_runners.find(absDotName);
- if (run == 0)
+ DotRunner* rv = nullptr;
+ auto const runit = m_runners.find(absDotName);
+ if (runit == m_runners.end())
{
- run = new DotRunner(absDotName, md5Hash);
- m_runners.insert(absDotName, run);
+ auto insobj = std::make_unique<DotRunner>(absDotName, md5Hash);
+ rv = insobj.get();
+ m_runners.emplace(absDotName, std::move(insobj));
}
else
{
// we have a match
- if (md5Hash != QCString(run->getMd5Hash().data()))
+ if (md5Hash != runit->second->getMd5Hash())
{
err("md5 hash does not match for two different runs of %s !\n", absDotName.data());
}
}
- return run;
+ return rv;
}
DotFilePatcher *DotManager::createFilePatcher(const QCString &fileName)
@@ -146,7 +147,7 @@ DotFilePatcher *DotManager::createFilePatcher(const QCString &fileName)
bool DotManager::run() const
{
- uint numDotRuns = m_runners.count();
+ uint numDotRuns = m_runners.size();
uint numFilePatchers = m_filePatchers.count();
if (numDotRuns+numFilePatchers>1)
{
@@ -160,7 +161,6 @@ bool DotManager::run() const
}
}
int i=1;
- QDictIterator<DotRunner> li(m_runners);
bool setPath=FALSE;
if (Config_getBool(GENERATE_HTML))
@@ -185,22 +185,21 @@ bool DotManager::run() const
}
Portable::sysTimerStart();
// fill work queue with dot operations
- DotRunner *dr;
int prev=1;
if (m_workers.count()==0) // no threads to work with
{
- for (li.toFirst();(dr=li.current());++li)
+ for (auto & dr : m_runners)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
- dr->run();
+ dr.second->run();
prev++;
}
}
else // use multiple threads to run instances of dot in parallel
{
- for (li.toFirst();(dr=li.current());++li)
+ for (auto & dr: m_runners)
{
- m_queue->enqueue(dr);
+ m_queue->enqueue(dr.second.get());
}
// wait for the queue to become empty
while ((i=m_queue->count())>0)
@@ -280,7 +279,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir,
QCString absImgName = d.absPath().utf8()+"/"+imgName;
QCString absOutFile = d.absPath().utf8()+"/"+outFile;
- DotRunner dotRun(inFile, QCString());
+ DotRunner dotRun(inFile);
if (format==GOF_BITMAP)
{
dotRun.addJob(Config_getEnum(DOT_IMAGE_FORMAT),absImgName);
@@ -333,7 +332,7 @@ void writeDotImageMapFromFile(FTextStream &t,
QCString imgName = baseName+"."+imgExt;
QCString absOutFile = d.absPath().utf8()+"/"+mapName;
- DotRunner dotRun(inFile, QCString());
+ DotRunner dotRun(inFile.data());
dotRun.addJob(MAP_CMD,absOutFile);
dotRun.preventCleanUp();
if (!dotRun.run())
diff --git a/src/dot.h b/src/dot.h
index 60f7f26..8f36f30 100644
--- a/src/dot.h
+++ b/src/dot.h
@@ -17,8 +17,8 @@
#define DOT_H
#include <qlist.h>
-#include <qdict.h>
#include <qcstring.h>
+#include <map>
#include "sortdict.h"
@@ -35,7 +35,7 @@ class DotManager
{
public:
static DotManager *instance();
- DotRunner* createRunner(const QCString& absDotName, const QCString& md5Hash);
+ DotRunner* createRunner(const std::string& absDotName, const std::string& md5Hash);
DotFilePatcher *createFilePatcher(const QCString &fileName);
bool run() const;
@@ -43,7 +43,7 @@ class DotManager
DotManager();
virtual ~DotManager();
- QDict<DotRunner> m_runners;
+ std::map<std::string, std::unique_ptr<DotRunner>> m_runners;
SDict<DotFilePatcher> m_filePatchers;
static DotManager *m_theInstance;
DotRunnerQueue *m_queue;
diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp
index 0bfa712..cdf4f6c 100644
--- a/src/dotgraph.cpp
+++ b/src/dotgraph.cpp
@@ -186,14 +186,14 @@ bool DotGraph::prepareDotFile()
if (m_graphFormat == GOF_BITMAP)
{
// run dot to create a bitmap image
- DotRunner * dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
+ DotRunner * dotRun = DotManager::instance()->createRunner(absDotName().data(), sigStr.data());
dotRun->addJob(Config_getEnum(DOT_IMAGE_FORMAT), absImgName());
if (m_generateImageMap) dotRun->addJob(MAP_CMD, absMapName());
}
else if (m_graphFormat == GOF_EPS)
{
// run dot to create a .eps image
- DotRunner *dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
+ DotRunner *dotRun = DotManager::instance()->createRunner(absDotName().data(), sigStr.data());
if (Config_getBool(USE_PDFLATEX))
{
dotRun->addJob("pdf",absImgName());
diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp
index d6dd1fe..90cc5eb 100644
--- a/src/dotrunner.cpp
+++ b/src/dotrunner.cpp
@@ -15,6 +15,7 @@
#include "dotrunner.h"
+#include "qstring.h"
#include "util.h"
#include "portable.h"
#include "dot.h"
@@ -145,7 +146,7 @@ bool DotRunner::readBoundingBox(const char *fileName,int *width,int *height,bool
//---------------------------------------------------------------------------------
-DotRunner::DotRunner(const QCString& absDotName, const QCString& md5Hash)
+DotRunner::DotRunner(const std::string& absDotName, const std::string& md5Hash)
: m_file(absDotName.data())
, m_md5Hash(md5Hash.data())
, m_dotExe(Config_getString(DOT_PATH)+"dot")
@@ -153,17 +154,18 @@ DotRunner::DotRunner(const QCString& absDotName, const QCString& md5Hash)
{
}
-void DotRunner::addJob(const char *format,const char *output)
+
+void DotRunner::addJob(const char *format, const char *output)
{
for (auto& s: m_jobs)
{
- if (qstrcmp(s.format.data(), format) != 0) continue;
- if (qstrcmp(s.output.data(), output) != 0) continue;
+ if (s.format != format) continue;
+ if (s.output != output) continue;
// we have this job already
return;
}
- QCString args = QCString("-T")+format+" -o \""+output+"\"";
+ auto args = std::string ("-T") + format + " -o \"" + output + "\"";
m_jobs.emplace_back(format, output, args);
}
@@ -204,7 +206,7 @@ bool DotRunner::run()
// As there should be only one pdf file be generated, we don't need code for regenerating multiple pdf files in one call
for (auto& s : m_jobs)
{
- if (qstrncmp(s.format.data(), "pdf", 3) == 0)
+ if (s.format.compare(0, 3, "pdf") == 0)
{
int width=0,height=0;
if (!readBoundingBox(s.output.data(),&width,&height,FALSE)) goto error;
@@ -216,7 +218,7 @@ bool DotRunner::run()
}
}
- if (qstrncmp(s.format.data(), "png", 3) == 0)
+ if (s.format.compare(0, 3, "png") == 0)
{
checkPngResult(s.output.data());
}
diff --git a/src/dotrunner.h b/src/dotrunner.h
index fb653dc..89eabf8 100644
--- a/src/dotrunner.h
+++ b/src/dotrunner.h
@@ -16,7 +16,7 @@
#ifndef DOTRUNNER_H
#define DOTRUNNER_H
-#include <qstring.h>
+#include <qglobal.h> //uint
#include <string>
#include <thread>
#include <list>
@@ -41,7 +41,7 @@ class DotRunner
};
/** Creates a runner for a dot \a file. */
- DotRunner(const QCString& absDotName, const QCString& md5Hash);
+ DotRunner(const std::string& absDotName, const std::string& md5Hash = std::string());
/** Adds an additional job to the run.
* Performing multiple jobs one file can be faster.
@@ -49,7 +49,7 @@ class DotRunner
void addJob(const char *format,const char *output);
/** Prevent cleanup of the dot file (for user provided dot files) */
- void preventCleanUp() { m_cleanUp = FALSE; }
+ void preventCleanUp() { m_cleanUp = false; }
/** Runs dot for all jobs added. */
bool run();