Doxygen
DotManager类 参考

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

#include <dot.h>

+ DotManager 的协作图:

Public 成员函数

DotRunnercreateRunner (const QCString &absDotName, const QCString &md5Hash)
 
DotFilePatchercreateFilePatcher (const QCString &fileName)
 
bool run () const
 

静态 Public 成员函数

static DotManagerinstance ()
 
static void deleteInstance ()
 

Private 成员函数

 DotManager ()
 
virtual ~DotManager ()
 

Private 属性

std::map< std::string, std::unique_ptr< DotRunner > > m_runners
 
std::map< std::string, DotFilePatcherm_filePatchers
 
DotRunnerQueuem_queue
 
std::vector< std::unique_ptr< DotWorkerThread > > m_workers
 

静态 Private 属性

static DotManagerm_theInstance = 0
 

详细描述

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

在文件 dot.h31 行定义.

构造及析构函数说明

◆ DotManager()

DotManager::DotManager ( )
private

在文件 dot.cpp92 行定义.

93 {
94  m_queue = new DotRunnerQueue;
95  int i;
96  int dotNumThreads = Config_getInt(DOT_NUM_THREADS);
97  if (dotNumThreads!=1)
98  {
99  for (i=0;i<dotNumThreads;i++)
100  {
101  std::unique_ptr<DotWorkerThread> thread = std::make_unique<DotWorkerThread>(m_queue);
102  thread->start();
103  if (thread->isRunning())
104  {
105  m_workers.push_back(std::move(thread));
106  }
107  else // no more threads available!
108  {
109  }
110  }
111  ASSERT(m_workers.size()>0);
112  }
113 }

引用了 ASSERT, Config_getInt, m_queue , 以及 m_workers.

被这些函数引用 instance().

◆ ~DotManager()

DotManager::~DotManager ( )
privatevirtual

在文件 dot.cpp115 行定义.

116 {
117  delete m_queue;
118 }

引用了 m_queue.

成员函数说明

◆ createFilePatcher()

DotFilePatcher * DotManager::createFilePatcher ( const QCString fileName)

在文件 dot.cpp143 行定义.

144 {
145  auto patcher = m_filePatchers.find(fileName.str());
146 
147  if (patcher != m_filePatchers.end()) return &(patcher->second);
148 
149  auto rv = m_filePatchers.emplace(std::make_pair(fileName.str(), fileName));
150  assert(rv.second);
151  return &(rv.first->second);
152 }

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

◆ createRunner()

DotRunner * DotManager::createRunner ( const QCString absDotName,
const QCString md5Hash 
)

在文件 dot.cpp120 行定义.

121 {
122  DotRunner* rv = nullptr;
123  auto const runit = m_runners.find(absDotName.str());
124  if (runit == m_runners.end())
125  {
126  auto insobj = std::make_unique<DotRunner>(absDotName, md5Hash);
127  rv = insobj.get();
128  m_runners.emplace(absDotName.str(), std::move(insobj));
129  }
130  else
131  {
132  // we have a match
133  if (md5Hash != runit->second->getMd5Hash())
134  {
135  err("md5 hash does not match for two different runs of %s !\n", qPrint(absDotName));
136  }
137  rv = runit->second.get();
138  }
139  assert(rv);
140  return rv;
141 }

引用了 err(), m_runners, qPrint() , 以及 QCString::str().

被这些函数引用 DotGraph::prepareDotFile().

◆ deleteInstance()

void DotManager::deleteInstance ( )
static

在文件 dot.cpp86 行定义.

87 {
88  delete m_theInstance;
89  m_theInstance=0;
90 }

引用了 m_theInstance.

被这些函数引用 cleanUpDoxygen().

◆ instance()

DotManager * DotManager::instance ( )
static

在文件 dot.cpp77 行定义.

78 {
79  if (!m_theInstance)
80  {
82  }
83  return m_theInstance;
84 }

引用了 DotManager() , 以及 m_theInstance.

被这些函数引用 DotGraph::generateCode(), generateOutput(), DotGraph::prepareDotFile() , 以及 DotLegendGraph::writeGraph().

◆ run()

bool DotManager::run ( ) const

在文件 dot.cpp154 行定义.

155 {
156  size_t numDotRuns = m_runners.size();
157  size_t numFilePatchers = m_filePatchers.size();
158  if (numDotRuns+numFilePatchers>1)
159  {
160  if (m_workers.size()==0)
161  {
162  msg("Generating dot graphs in single threaded mode...\n");
163  }
164  else
165  {
166  msg("Generating dot graphs using %zu parallel threads...\n",std::min(numDotRuns+numFilePatchers,m_workers.size()));
167  }
168  }
169  size_t i=1;
170 
171  bool setPath=FALSE;
172  if (Config_getBool(GENERATE_HTML))
173  {
174  setDotFontPath(Config_getString(HTML_OUTPUT));
175  setPath=TRUE;
176  }
177  else if (Config_getBool(GENERATE_LATEX))
178  {
179  setDotFontPath(Config_getString(LATEX_OUTPUT));
180  setPath=TRUE;
181  }
182  else if (Config_getBool(GENERATE_RTF))
183  {
184  setDotFontPath(Config_getString(RTF_OUTPUT));
185  setPath=TRUE;
186  }
187  else if (Config_getBool(GENERATE_DOCBOOK))
188  {
189  setDotFontPath(Config_getString(DOCBOOK_OUTPUT));
190  setPath=TRUE;
191  }
193  // fill work queue with dot operations
194  size_t prev=1;
195  if (m_workers.size()==0) // no threads to work with
196  {
197  for (auto & dr : m_runners)
198  {
199  msg("Running dot for graph %zu/%zu\n",prev,numDotRuns);
200  dr.second->run();
201  prev++;
202  }
203  }
204  else // use multiple threads to run instances of dot in parallel
205  {
206  for (auto & dr: m_runners)
207  {
208  m_queue->enqueue(dr.second.get());
209  }
210  // wait for the queue to become empty
211  while ((i=m_queue->size())>0)
212  {
213  i = numDotRuns - i;
214  while (i>=prev)
215  {
216  msg("Running dot for graph %zu/%zu\n",prev,numDotRuns);
217  prev++;
218  }
219  Portable::sleep(100);
220  }
221  while (numDotRuns>=prev)
222  {
223  msg("Running dot for graph %zu/%zu\n",prev,numDotRuns);
224  prev++;
225  }
226  // signal the workers we are done
227  for (i=0;i<m_workers.size();i++)
228  {
229  m_queue->enqueue(0); // add terminator for each worker
230  }
231  // wait for the workers to finish
232  for (i=0;i<m_workers.size();i++)
233  {
234  m_workers.at(i)->wait();
235  }
236  }
238  if (setPath)
239  {
241  }
242 
243  // patch the output file and insert the maps and figures
244  i=1;
245  // since patching the svg files may involve patching the header of the SVG
246  // (for zoomable SVGs), and patching the .html files requires reading that
247  // header after the SVG is patched, we first process the .svg files and
248  // then the other files.
249  for (auto & fp : m_filePatchers)
250  {
251  if (fp.second.isSVGFile())
252  {
253  msg("Patching output file %zu/%zu\n",i,numFilePatchers);
254  if (!fp.second.run()) return FALSE;
255  i++;
256  }
257  }
258  for (auto& fp : m_filePatchers)
259  {
260  if (!fp.second.isSVGFile())
261  {
262  msg("Patching output file %zu/%zu\n",i,numFilePatchers);
263  if (!fp.second.run()) return FALSE;
264  i++;
265  }
266  }
267  return TRUE;
268 }

引用了 Config_getBool, Config_getString, DotRunnerQueue::enqueue(), FALSE, m_filePatchers, m_queue, m_runners, m_workers, msg(), setDotFontPath(), DotRunnerQueue::size(), Portable::sleep(), Portable::sysTimerStart(), Portable::sysTimerStop(), TRUE , 以及 unsetDotFontPath().

被这些函数引用 generateOutput().

类成员变量说明

◆ m_filePatchers

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

在文件 dot.h45 行定义.

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

◆ m_queue

DotRunnerQueue* DotManager::m_queue
private

在文件 dot.h47 行定义.

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

◆ m_runners

std::map<std::string, std::unique_ptr<DotRunner> > DotManager::m_runners
private

在文件 dot.h44 行定义.

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

◆ m_theInstance

DotManager * DotManager::m_theInstance = 0
staticprivate

在文件 dot.h46 行定义.

被这些函数引用 deleteInstance() , 以及 instance().

◆ m_workers

std::vector< std::unique_ptr<DotWorkerThread> > DotManager::m_workers
private

在文件 dot.h48 行定义.

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


该类的文档由以下文件生成:
DotRunner
Helper class to run dot from doxygen from multiple threads.
Definition: dotrunner.h:30
DotManager::m_queue
DotRunnerQueue * m_queue
Definition: dot.h:47
DotRunnerQueue::size
size_t size() const
Definition: dotrunner.cpp:277
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
DotManager::m_workers
std::vector< std::unique_ptr< DotWorkerThread > > m_workers
Definition: dot.h:48
Config_getInt
#define Config_getInt(name)
Definition: config.h:34
DotManager::DotManager
DotManager()
Definition: dot.cpp:92
Portable::sysTimerStart
void sysTimerStart()
Definition: portable.cpp:470
DotRunnerQueue::enqueue
void enqueue(DotRunner *runner)
Definition: dotrunner.cpp:258
DotRunnerQueue
Queue of dot jobs to run.
Definition: dotrunner.h:73
TRUE
#define TRUE
Definition: qcstring.h:36
DotManager::m_filePatchers
std::map< std::string, DotFilePatcher > m_filePatchers
Definition: dot.h:45
DotManager::m_theInstance
static DotManager * m_theInstance
Definition: dot.h:46
setDotFontPath
static void setDotFontPath(const QCString &path)
Definition: dot.cpp:39
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
msg
void msg(const char *fmt,...)
Definition: message.cpp:53
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
Portable::sysTimerStop
void sysTimerStop()
Definition: portable.cpp:475
ASSERT
#define ASSERT(x)
Definition: qcstring.h:44
DotManager::m_runners
std::map< std::string, std::unique_ptr< DotRunner > > m_runners
Definition: dot.h:44
Portable::sleep
void sleep(int ms)
Definition: portable.cpp:487
unsetDotFontPath
static void unsetDotFontPath()
Definition: dot.cpp:60
FALSE
#define FALSE
Definition: qcstring.h:33