Doxygen
Loading...
Searching...
No Matches
DotManager Class Reference

Singleton that manages dot invocations and patching files for embedding image maps. More...

#include <src/dot.h>

Collaboration diagram for DotManager:

Public Member Functions

void addJob (const DotJob &newJob)
DotFilePatchercreateFilePatcher (const QCString &fileName)
bool run ()

Static Public Member Functions

static DotManagerinstance ()

Private Member Functions

 DotManager ()
virtual ~DotManager ()

Private Attributes

DotRunner m_runner
std::map< std::string, DotFilePatcherm_filePatchers
DotJobs m_jobs

Detailed Description

Singleton that manages dot invocations and patching files for embedding image maps.

Definition at line 33 of file dot.h.

Constructor & Destructor Documentation

◆ DotManager()

DotManager::DotManager ( )
private

Definition at line 84 of file dot.cpp.

85{
86}
std::map< std::string, DotFilePatcher > m_filePatchers
Definition dot.h:47

References m_filePatchers.

Referenced by instance().

◆ ~DotManager()

DotManager::~DotManager ( )
privatevirtual

Definition at line 88 of file dot.cpp.

89{
90}

Member Function Documentation

◆ addJob()

void DotManager::addJob ( const DotJob & newJob)

Definition at line 92 of file dot.cpp.

93{
94 std::lock_guard<std::mutex> lock(g_dotManagerMutex);
95 for (const auto &job : m_jobs)
96 {
97 if (job.absPath == newJob.absPath && job.relDotName == newJob.relDotName && job.format == newJob.format) return; // already queued
98 if (job.absPath == newJob.absPath && job.relDotName == newJob.relDotName && job.md5Hash != newJob.md5Hash)
99 {
100 err("md5 hash does not match for two different runs of {}{} !\n", newJob.absPath, newJob.relDotName);
101 return;
102 }
103 }
104 m_jobs.push_back(newJob);
105}
DotJobs m_jobs
Definition dot.h:48
static std::mutex g_dotManagerMutex
Definition dot.cpp:40
#define err(fmt,...)
Definition message.h:127
QCString md5Hash
Definition dotjob.h:30
QCString format
Definition dotjob.h:29
QCString relDotName
Definition dotjob.h:28
QCString absPath
Definition dotjob.h:27

References DotJob::absPath, err, DotJob::format, g_dotManagerMutex, m_jobs, DotJob::md5Hash, and DotJob::relDotName.

Referenced by DotGraph::prepareDotFile().

◆ createFilePatcher()

DotFilePatcher * DotManager::createFilePatcher ( const QCString & fileName)

Definition at line 107 of file dot.cpp.

108{
109 std::lock_guard<std::mutex> lock(g_dotManagerMutex);
110 auto patcher = m_filePatchers.find(fileName.str());
111
112 if (patcher != m_filePatchers.end()) return &(patcher->second);
113
114 auto rv = m_filePatchers.emplace(fileName.str(), fileName);
115 assert(rv.second);
116 return &(rv.first->second);
117}
const std::string & str() const
Definition qcstring.h:552

References g_dotManagerMutex, m_filePatchers, and QCString::str().

◆ instance()

DotManager * DotManager::instance ( )
static

Definition at line 78 of file dot.cpp.

79{
80 static DotManager theInstance;
81 return &theInstance;
82}
DotManager()
Definition dot.cpp:84

References DotManager().

Referenced by DotGraph::generateCode(), generateOutput(), DotGraph::prepareDotFile(), and DotLegendGraph::writeGraph().

◆ run()

bool DotManager::run ( )

Definition at line 119 of file dot.cpp.

120{
121 size_t numFilePatchers = m_filePatchers.size();
122 if (m_jobs.size()+numFilePatchers > 0)
123 {
124 if (Config_getInt(DOT_NUM_THREADS)<=1)
125 {
126 msg("Generating {:d} dot graphs in single threaded mode with batch size {:d}...\n",
127 m_jobs.size(),Config_getInt(DOT_BATCH_SIZE));
128 }
129 else
130 {
131 msg("Generating {:d} dot graphs using {:d} parallel threads with batch size {:d}...\n",
132 m_jobs.size(),Config_getInt(DOT_NUM_THREADS),Config_getInt(DOT_BATCH_SIZE));
133 }
134 }
135
136 bool setPath=FALSE;
137 if (Config_getBool(GENERATE_HTML))
138 {
139 setDotFontPath(Config_getString(HTML_OUTPUT));
140 setPath=TRUE;
141 }
142 else if (Config_getBool(GENERATE_LATEX))
143 {
144 setDotFontPath(Config_getString(LATEX_OUTPUT));
145 setPath=TRUE;
146 }
147 else if (Config_getBool(GENERATE_RTF))
148 {
149 setDotFontPath(Config_getString(RTF_OUTPUT));
150 setPath=TRUE;
151 }
152 else if (Config_getBool(GENERATE_DOCBOOK))
153 {
154 setDotFontPath(Config_getString(DOCBOOK_OUTPUT));
155 setPath=TRUE;
156 }
157
158 bool ok = m_runner.run(m_jobs);
159
160 if (setPath)
161 {
163 }
164
165 if (!ok) return FALSE;
166
167 // patch the output file and insert the maps and figures
168 size_t i=1;
169 // since patching the svg files may involve patching the header of the SVG
170 // (for zoomable SVGs), and patching the .html files requires reading that
171 // header after the SVG is patched, we first process the .svg files and
172 // then the other files.
173 for (auto & fp : m_filePatchers)
174 {
175 if (fp.second.isSVGFile())
176 {
177 msg("Patching output file {}/{}\n",i,numFilePatchers);
178 if (!fp.second.run()) return FALSE;
179 i++;
180 }
181 }
182 for (auto& fp : m_filePatchers)
183 {
184 if (!fp.second.isSVGFile())
185 {
186 msg("Patching output file {}/{}\n",i,numFilePatchers);
187 if (!fp.second.run()) return FALSE;
188 i++;
189 }
190 }
191 return TRUE;
192}
DotRunner m_runner
Definition dot.h:46
#define Config_getInt(name)
Definition config.h:34
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
static void setDotFontPath(const QCString &path)
Definition dot.cpp:42
static void unsetDotFontPath()
Definition dot.cpp:63
#define msg(fmt,...)
Definition message.h:94
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References Config_getBool, Config_getInt, Config_getString, FALSE, m_filePatchers, m_jobs, m_runner, msg, setDotFontPath(), TRUE, and unsetDotFontPath().

Referenced by generateOutput().

Member Data Documentation

◆ m_filePatchers

std::map<std::string, DotFilePatcher> DotManager::m_filePatchers
private

Definition at line 47 of file dot.h.

Referenced by createFilePatcher(), DotManager(), and run().

◆ m_jobs

DotJobs DotManager::m_jobs
private

Definition at line 48 of file dot.h.

Referenced by addJob(), and run().

◆ m_runner

DotRunner DotManager::m_runner
private

Definition at line 46 of file dot.h.

Referenced by run().


The documentation for this class was generated from the following files: