summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-01-19 19:39:53 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-01-22 20:45:21 (GMT)
commit74d4e12444105f2d005a79493116c08a26addbf5 (patch)
tree2de628eb01881972f438d572259cc92d6c5b6455 /src
parent84e655b1e4792b232ed72c70c80269d002142a7f (diff)
downloadDoxygen-74d4e12444105f2d005a79493116c08a26addbf5.zip
Doxygen-74d4e12444105f2d005a79493116c08a26addbf5.tar.gz
Doxygen-74d4e12444105f2d005a79493116c08a26addbf5.tar.bz2
Refactoring: modernize PlantumlManager
Diffstat (limited to 'src')
-rw-r--r--src/docbookvisitor.cpp4
-rw-r--r--src/doxygen.cpp2
-rw-r--r--src/htmldocvisitor.cpp6
-rw-r--r--src/latexdocvisitor.cpp4
-rw-r--r--src/plantuml.cpp155
-rw-r--r--src/plantuml.h37
-rw-r--r--src/rtfdocvisitor.cpp4
-rw-r--r--src/vhdldocgen.cpp4
8 files changed, 79 insertions, 137 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp
index 7325b35..e4eb299 100644
--- a/src/docbookvisitor.cpp
+++ b/src/docbookvisitor.cpp
@@ -393,7 +393,7 @@ DB_VIS_C
case DocVerbatim::PlantUML:
{
static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
- QCString baseName = PlantumlManager::instance()->writePlantUMLSource(docbookOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
+ QCString baseName = PlantumlManager::instance().writePlantUMLSource(docbookOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
QCString shortName = baseName;
int i;
if ((i=shortName.findRev('/'))!=-1)
@@ -1632,7 +1632,7 @@ DB_VIS_C
shortName=shortName.right((int)shortName.length()-i-1);
}
QCString outDir = Config_getString(DOCBOOK_OUTPUT);
- PlantumlManager::instance()->generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_BITMAP);
+ PlantumlManager::instance().generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_BITMAP);
visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height());
visitCaption(s->children());
visitPostEnd(m_t, s->hasCaption());
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 483426f..34468be 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -11793,7 +11793,7 @@ void generateOutput()
warn_flush();
g_s.begin("Running plantuml with JAVA...\n");
- PlantumlManager::instance()->run();
+ PlantumlManager::instance().run();
g_s.end();
warn_flush();
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index a10abfe..6d761eb 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -627,7 +627,7 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
{
format = PlantumlManager::PUML_SVG;
}
- QCString baseName = PlantumlManager::instance()->writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format);
+ QCString baseName = PlantumlManager::instance().writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format);
m_t << "<div class=\"plantumlgraph\">" << endl;
writePlantUMLFile(baseName,s->relPath(),s->context());
visitPreCaption(m_t, s);
@@ -2351,7 +2351,7 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
QCString imgExt = getDotImageExtension();
if (imgExt=="svg")
{
- PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG);
+ PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG);
//m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />" << endl;
//m_t << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>";
//m_t << "</iframe>" << endl;
@@ -2359,7 +2359,7 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
}
else
{
- PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
+ PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl;
}
}
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index 1d666ab..f2f9e41 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -428,7 +428,7 @@ void LatexDocVisitor::visit(DocVerbatim *s)
case DocVerbatim::PlantUML:
{
QCString latexOutput = Config_getString(LATEX_OUTPUT);
- QCString baseName = PlantumlManager::instance()->writePlantUMLSource(latexOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_EPS);
+ QCString baseName = PlantumlManager::instance().writePlantUMLSource(latexOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_EPS);
writePlantUMLFile(baseName, s);
}
@@ -1946,7 +1946,7 @@ void LatexDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s
shortName=shortName.right(shortName.length()-i-1);
}
QCString outDir = Config_getString(LATEX_OUTPUT);
- PlantumlManager::instance()->generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_EPS);
+ PlantumlManager::instance().generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_EPS);
visitPreStart(m_t, s->hasCaption(), shortName, s->width(), s->height());
visitCaption(this, s->children());
visitPostEnd(m_t, s->hasCaption());
diff --git a/src/plantuml.cpp b/src/plantuml.cpp
index d020da0..51debca 100644
--- a/src/plantuml.cpp
+++ b/src/plantuml.cpp
@@ -18,14 +18,10 @@
#include "portable.h"
#include "config.h"
#include "doxygen.h"
-#include "index.h"
#include "message.h"
#include "debug.h"
-#include <qdir.h>
-#include <qdict.h>
-#include <qlist.h>
-
+#include <qfileinfo.h>
QCString PlantumlManager::writePlantUMLSource(const QCString &outDirArg,const QCString &fileName,const QCString &content,OutputFormat format)
{
@@ -84,7 +80,7 @@ QCString PlantumlManager::writePlantUMLSource(const QCString &outDirArg,const QC
uint pos = qcOutDir.findRev("/");
QCString generateType(qcOutDir.right(qcOutDir.length() - (pos + 1)) );
Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
- PlantumlManager::instance()->insert(generateType,puName,outDir,format,text);
+ PlantumlManager::instance().insert(generateType.str(),puName.str(),outDir,format,text);
Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
return baseName;
@@ -122,71 +118,26 @@ void PlantumlManager::generatePlantUMLOutput(const char *baseName,const char *ou
//--------------------------------------------------------------------
-PlantumlManager *PlantumlManager::m_theInstance = 0;
-PlantumlManager *PlantumlManager::instance()
+PlantumlManager &PlantumlManager::instance()
{
- if (!m_theInstance)
- {
- m_theInstance = new PlantumlManager;
- QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
- QFileInfo fi(outputFilename);
- if (fi.exists())
- {
- m_theInstance->m_cachedPlantumlAllContent = fileToString(outputFilename);
- }
- else
- {
- m_theInstance->m_cachedPlantumlAllContent = "";
- }
- Debug::print(Debug::Plantuml,0,"*** instance() : m_cachedPlantumlAllContent = [%s]\n",qPrint(m_theInstance->m_cachedPlantumlAllContent));
- m_theInstance->m_pngPlantumlContent.clear();
- m_theInstance->m_svgPlantumlContent.clear();
- m_theInstance->m_epsPlantumlContent.clear();
- }
- return m_theInstance;
+ static PlantumlManager theInstance;
+ return theInstance;
}
PlantumlManager::PlantumlManager()
{
-}
-
-PlantumlManager::~PlantumlManager()
-{
- {
- QDictIterator< QList<QCString> > it( m_pngPlantumlFiles); // See QDictIterator
- QList<QCString> *list;
- for (it.toFirst();(list=it.current());++it)
- {
- (*list).clear();
- }
- m_pngPlantumlFiles.clear();
- m_pngPlantumlContent.clear();
- }
- {
- QDictIterator< QList<QCString> > it( m_epsPlantumlFiles); // See QDictIterator
- QList<QCString> *list;
- for (it.toFirst();(list=it.current());++it)
- {
- (*list).clear();
- }
- m_epsPlantumlFiles.clear();
- m_epsPlantumlContent.clear();
- }
+ QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
+ QFileInfo fi(outputFilename);
+ if (fi.exists())
{
- QDictIterator< QList<QCString> > it( m_svgPlantumlFiles); // See QDictIterator
- QList<QCString> *list;
- for (it.toFirst();(list=it.current());++it)
- {
- (*list).clear();
- }
- m_svgPlantumlFiles.clear();
- m_svgPlantumlContent.clear();
+ m_cachedPlantumlAllContent = fileToString(outputFilename);
}
+ Debug::print(Debug::Plantuml,0,"*** instance() : m_cachedPlantumlAllContent = [%s]\n",qPrint(m_cachedPlantumlAllContent));
}
-static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
- const QDict< PlantumlContent > &plantumlContent,
+static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles,
+ const PlantumlManager::ContentMap &plantumlContent,
PlantumlManager::OutputFormat format)
{
/* example : running: java -Djava.awt.headless=true
@@ -254,26 +205,25 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
}
{
- QDictIterator< PlantumlContent > it( plantumlContent); // See QDictIterator
- PlantumlContent *nb;
- for (it.toFirst();(nb=it.current());++it)
+ for (const auto &kv : plantumlContent)
{
- QCString pumlArguments(pumlArgs);
- msg("Generating PlantUML %s Files in %s\n",qPrint(pumlType),qPrint(it.currentKey()));
+ const PlantumlContent &nb = kv.second;
+ QCString pumlArguments = pumlArgs;
+ msg("Generating PlantUML %s Files in %s\n",qPrint(pumlType),kv.first.c_str());
pumlArguments+="-o \"";
- pumlArguments+=nb->outDir.data();
+ pumlArguments+=nb.outDir;
pumlArguments+="\" ";
pumlArguments+="-charset UTF-8 -t";
pumlArguments+=pumlType;
pumlArguments+=" ";
QCString puFileName("");
- puFileName+=nb->outDir.data();
+ puFileName+=nb.outDir;
puFileName+="/";
pumlOutDir=puFileName;
puFileName+="inline_umlgraph_";
puFileName+=pumlType;
- puFileName+=it.currentKey();
+ puFileName+=kv.first.c_str();
puFileName+=".pu";
pumlArguments+="\"";
@@ -285,7 +235,7 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
{
err("Could not open file %s for writing\n",puFileName.data());
}
- file.writeBlock( nb->content, nb->content.length() );
+ file.writeBlock( nb.content, nb.content.length() );
file.close();
Debug::print(Debug::Plantuml,0,"*** %s Running Plantuml arguments:%s\n","PlantumlManager::runPlantumlContent",qPrint(pumlArguments));
@@ -305,16 +255,15 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
{
Debug::print(Debug::Plantuml,0,"*** %s Running epstopdf\n","PlantumlManager::runPlantumlContent");
- QList<QCString> *list = plantumlFiles[it.currentKey()];
- if (list)
+ auto files_kv = plantumlFiles.find(kv.first);
+ if (files_kv!=plantumlFiles.end())
{
- QListIterator<QCString> li(*list);
- QCString *str_p;
- for (li.toFirst();(str_p=li.current());++li)
+ for (const auto &str : files_kv->second)
{
const int maxCmdLine = 40960;
QCString epstopdfArgs(maxCmdLine);
- epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",qPrint(pumlOutDir),qPrint(*str_p),qPrint(pumlOutDir),qPrint(*str_p));
+ epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
+ pumlOutDir.data(),str.c_str(), pumlOutDir.data(),str.c_str());
Portable::sysTimerStart();
if ((exitCode=Portable::system("epstopdf",epstopdfArgs))!=0)
{
@@ -345,66 +294,56 @@ void PlantumlManager::run()
file.close();
}
-static void print(const QDict< QList <QCString> > &plantumlFiles)
+static void print(const PlantumlManager::FilesMap &plantumlFiles)
{
if (Debug::isFlagSet(Debug::Plantuml))
{
- QDictIterator< QList<QCString> > it( plantumlFiles); // See QDictIterator
- QList<QCString> *list;
- for (it.toFirst();(list=it.current());++it)
+ for (const auto &kv : plantumlFiles)
{
- Debug::print(Debug::Plantuml,0,"*** %s PlantumlFiles key:%s size:%d\n","PlantumlManager::print Files",qPrint(it.currentKey()),(*list).count());
- QListIterator<QCString> li(*list);
- QCString *nb;
- for (li.toFirst();(nb=li.current());++li)
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlFiles key:%s size:%zu\n","PlantumlManager::print Files",kv.first.c_str(),kv.second.size());
+ for (const auto &s : kv.second)
{
- Debug::print(Debug::Plantuml,0,"*** %s list:%s\n","PlantumlManager::print",qPrint(*nb));
+ Debug::print(Debug::Plantuml,0,"*** %s list:%s\n","PlantumlManager::print",s.c_str());
}
}
}
}
-static void print(const QDict<PlantumlContent> &plantumlContent)
+static void print(const PlantumlManager::ContentMap &plantumlContent)
{
if (Debug::isFlagSet(Debug::Plantuml))
{
- QDictIterator< PlantumlContent > it( plantumlContent); // See QDictIterator
- PlantumlContent *nb;
- for (it.toFirst();(nb=it.current());++it)
+ for (const auto &kv : plantumlContent)
{
- Debug::print(Debug::Plantuml,0,"*** %s PlantumlContent key:%s\n","PlantumlManager::print Content",qPrint(it.currentKey()));
- Debug::print(Debug::Plantuml,0,"*** %s Content :%s\n","PlantumlManager::print",qPrint(nb->content));
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlContent key:%s\n","PlantumlManager::print Content",kv.first.c_str());
+ Debug::print(Debug::Plantuml,0,"*** %s Content :%s\n","PlantumlManager::print",kv.second.content.data());
}
}
}
-static void addPlantumlFiles(QDict< QList<QCString> > &plantumlFiles,
- const QCString &key , const QCString &value)
+static void addPlantumlFiles(PlantumlManager::FilesMap &plantumlFiles,
+ const std::string &key, const std::string &value)
{
- QList<QCString> *list = plantumlFiles.find(key);
- if (list==0)
+ auto kv = plantumlFiles.find(key);
+ if (kv==plantumlFiles.end())
{
- list = new QList<QCString>;
- plantumlFiles.insert(key,list);
+ kv = plantumlFiles.insert(std::make_pair(key,StringVector())).first;
}
- list->append(new QCString(value));
+ kv->second.push_back(value);
}
-static void addPlantumlContent(QDict< PlantumlContent > &plantumlContent,
- const QCString &key, const QCString &outDir, const QCString &puContent)
+static void addPlantumlContent(PlantumlManager::ContentMap &plantumlContent,
+ const std::string &key, const QCString &outDir, const QCString &puContent)
{
- PlantumlContent* content = plantumlContent.find(key);
- if (content == 0)
+ auto kv = plantumlContent.find(key);
+ if (kv==plantumlContent.end())
{
- content = new PlantumlContent("",outDir);
- plantumlContent.insert(key,content);
+ kv = plantumlContent.insert(std::make_pair(key,PlantumlContent("",outDir))).first;
}
- (content->content)+=puContent;
+ kv->second.content+=puContent;
}
-
-
-void PlantumlManager::insert(const QCString &key, const QCString &value,
+void PlantumlManager::insert(const std::string &key, const std::string &value,
const QCString &outDir,OutputFormat format,const QCString &puContent)
{
int find;
diff --git a/src/plantuml.h b/src/plantuml.h
index f2e9dec..b553fa8 100644
--- a/src/plantuml.h
+++ b/src/plantuml.h
@@ -3,8 +3,8 @@
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -16,8 +16,10 @@
#ifndef PLANTUML_H
#define PLANTUML_H
-#include <qdict.h>
-#include <qlist.h>
+#include <map>
+#include <string>
+#include "containers.h"
+#include <qcstring.h>
#define CACHE_FILENAME "inline_umlgraph_cache_all.pu"
#define DIVIDE_COUNT 4
@@ -43,7 +45,7 @@ class PlantumlManager
/** Plant UML output image formats */
enum OutputFormat { PUML_BITMAP, PUML_EPS, PUML_SVG };
- static PlantumlManager *instance();
+ static PlantumlManager &instance();
/** Run plant UML tool for all images */
void run();
@@ -64,23 +66,24 @@ class PlantumlManager
*/
void generatePlantUMLOutput(const char *baseName,const char *outDir,OutputFormat format);
+ using FilesMap = std::map< std::string, StringVector >;
+ using ContentMap = std::map< std::string, PlantumlContent >;
private:
PlantumlManager();
- ~PlantumlManager();
- void insert(const QCString &key,
- const QCString &value,
+ void insert(const std::string &key,
+ const std::string &value,
const QCString &outDir,
OutputFormat format,
const QCString &puContent);
- static PlantumlManager *m_theInstance;
- QDict< QList<QCString> > m_pngPlantumlFiles;
- QDict< QList<QCString> > m_svgPlantumlFiles;
- QDict< QList<QCString> > m_epsPlantumlFiles;
- QDict< PlantumlContent > m_pngPlantumlContent; // use circular queue for using multi-processor (multi threading)
- QDict< PlantumlContent > m_svgPlantumlContent;
- QDict< PlantumlContent > m_epsPlantumlContent;
- QCString m_cachedPlantumlAllContent; // read from CACHE_FILENAME file
- QCString m_currentPlantumlAllContent; // processing plantuml then write it into CACHE_FILENAME to reuse the next time as cache information
+
+ FilesMap m_pngPlantumlFiles;
+ FilesMap m_svgPlantumlFiles;
+ FilesMap m_epsPlantumlFiles;
+ ContentMap m_pngPlantumlContent; // use circular queue for using multi-processor (multi threading)
+ ContentMap m_svgPlantumlContent;
+ ContentMap m_epsPlantumlContent;
+ QCString m_cachedPlantumlAllContent; // read from CACHE_FILENAME file
+ QCString m_currentPlantumlAllContent; // processing plantuml then write it into CACHE_FILENAME to reuse the next time as cache information
};
#endif
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp
index 1fcaaa7..1f7c609 100644
--- a/src/rtfdocvisitor.cpp
+++ b/src/rtfdocvisitor.cpp
@@ -378,7 +378,7 @@ void RTFDocVisitor::visit(DocVerbatim *s)
case DocVerbatim::PlantUML:
{
static QCString rtfOutput = Config_getString(RTF_OUTPUT);
- QCString baseName = PlantumlManager::instance()->writePlantUMLSource(rtfOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
+ QCString baseName = PlantumlManager::instance().writePlantUMLSource(rtfOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
writePlantUMLFile(baseName, s->hasCaption());
visitCaption(this, s->children());
@@ -1851,6 +1851,6 @@ void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
baseName=baseName.right(baseName.length()-i-1);
}
QCString outDir = Config_getString(RTF_OUTPUT);
- PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
+ PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
includePicturePreRTF(baseName + ".png", true, hasCaption);
}
diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp
index dcbbae0..7455988 100644
--- a/src/vhdldocgen.cpp
+++ b/src/vhdldocgen.cpp
@@ -3409,8 +3409,8 @@ void FlowChart::printUmlTree()
QCString htmlOutDir = Config_getString(HTML_OUTPUT);
QCString n=convertNameToFileName();
- n=PlantumlManager::instance()->writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG);
- PlantumlManager::instance()->generatePlantUMLOutput(n,htmlOutDir,PlantumlManager::PUML_SVG);
+ n=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG);
+ PlantumlManager::instance().generatePlantUMLOutput(n,htmlOutDir,PlantumlManager::PUML_SVG);
}
QCString FlowChart::convertNameToFileName()