My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DotManager Class Reference

#include <dot.h>

Public Member Functions

void addRun (DotRunner *run)
 
int addMap (const QCString &file, const QCString &mapFile, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &label)
 
int addFigure (const QCString &file, const QCString &baseName, const QCString &figureName, bool heightCheck)
 
int addSVGConversion (const QCString &file, const QCString &relPath, bool urlOnly, const QCString &context, bool zoomable, int graphId)
 
int addSVGObject (const QCString &file, const QCString &baseName, const QCString &figureNAme, const QCString &relPath)
 
bool run ()
 

Static Public Member Functions

static DotManagerinstance ()
 

Private Member Functions

 DotManager ()
 
virtual ~DotManager ()
 

Private Attributes

QList< DotRunnerm_dotRuns
 
SDict< DotFilePatcherm_dotMaps
 
DotRunnerQueuem_queue
 
QList< DotWorkerThreadm_workers
 

Static Private Attributes

static DotManagerm_theInstance = 0
 

Detailed Description

Singleton that manages dot relation actions

Definition at line 462 of file dot.h.

Constructor & Destructor Documentation

DotManager::DotManager ( )
private

Definition at line 1188 of file dot.cpp.

References Config_getInt, m_dotMaps, m_dotRuns, m_queue, m_workers, and SDict< T >::setAutoDelete().

Referenced by instance().

: m_dotMaps(1009)
{
m_dotRuns.setAutoDelete(TRUE);
int i;
int numThreads = QMIN(32,Config_getInt(DOT_NUM_THREADS));
if (numThreads!=1)
{
if (numThreads==0) numThreads = QMAX(2,QThread::idealThreadCount()+1);
for (i=0;i<numThreads;i++)
{
thread->start();
if (thread->isRunning())
{
m_workers.append(thread);
}
else // no more threads available!
{
delete thread;
}
}
ASSERT(m_workers.count()>0);
}
}
DotManager::~DotManager ( )
privatevirtual

Definition at line 1215 of file dot.cpp.

References m_queue.

{
delete m_queue;
}

Member Function Documentation

int DotManager::addFigure ( const QCString &  file,
const QCString &  baseName,
const QCString &  figureName,
bool  heightCheck 
)

Definition at line 1238 of file dot.cpp.

References DotFilePatcher::addFigure(), SDict< T >::append(), SDict< T >::find(), and m_dotMaps.

Referenced by DotClassGraph::writeGraph(), DotInclDepGraph::writeGraph(), DotCallGraph::writeGraph(), DotDirDeps::writeGraph(), and DotGroupCollaboration::writeGraph().

{
if (map==0)
{
map = new DotFilePatcher(file);
m_dotMaps.append(file,map);
}
return map->addFigure(baseName,figureName,heightCheck);
}
int DotManager::addMap ( const QCString &  file,
const QCString &  mapFile,
const QCString &  relPath,
bool  urlOnly,
const QCString &  context,
const QCString &  label 
)
void DotManager::addRun ( DotRunner run)
int DotManager::addSVGConversion ( const QCString &  file,
const QCString &  relPath,
bool  urlOnly,
const QCString &  context,
bool  zoomable,
int  graphId 
)
int DotManager::addSVGObject ( const QCString &  file,
const QCString &  baseName,
const QCString &  figureNAme,
const QCString &  relPath 
)
DotManager * DotManager::instance ( )
static
bool DotManager::run ( )

Definition at line 1275 of file dot.cpp.

References Config_getBool, Config_getString, SDict< T >::count(), DotRunnerQueue::count(), DotRunnerQueue::enqueue(), DotFilePatcher::file(), m_dotMaps, m_dotRuns, m_queue, m_workers, msg(), portable_sleep(), portable_sysTimerStart(), portable_sysTimerStop(), DotRunner::run(), DotFilePatcher::run(), setDotFontPath(), and unsetDotFontPath().

Referenced by generateOutput().

{
uint numDotRuns = m_dotRuns.count();
uint numDotMaps = m_dotMaps.count();
if (numDotRuns+numDotMaps>1)
{
if (m_workers.count()==0)
{
msg("Generating dot graphs in single threaded mode...\n");
}
else
{
msg("Generating dot graphs using %d parallel threads...\n",QMIN(numDotRuns+numDotMaps,m_workers.count()));
}
}
int i=1;
QListIterator<DotRunner> li(m_dotRuns);
bool setPath=FALSE;
if (Config_getBool(GENERATE_HTML))
{
setPath=TRUE;
}
else if (Config_getBool(GENERATE_LATEX))
{
setPath=TRUE;
}
else if (Config_getBool(GENERATE_RTF))
{
setPath=TRUE;
}
// 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)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
dr->run();
prev++;
}
}
else // use multiple threads to run instances of dot in parallel
{
for (li.toFirst();(dr=li.current());++li)
{
}
// wait for the queue to become empty
while ((i=m_queue->count())>0)
{
i = numDotRuns - i;
while (i>=prev)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
prev++;
}
}
while ((int)numDotRuns>=prev)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
prev++;
}
// signal the workers we are done
for (i=0;i<(int)m_workers.count();i++)
{
m_queue->enqueue(0); // add terminator for each worker
}
// wait for the workers to finish
for (i=0;i<(int)m_workers.count();i++)
{
m_workers.at(i)->wait();
}
// clean up dot files from main thread
for (i=0;i<(int)m_workers.count();i++)
{
m_workers.at(i)->cleanup();
}
}
if (setPath)
{
}
// patch the output file and insert the maps and figures
i=1;
// since patching the svg files may involve patching the header of the SVG
// (for zoomable SVGs), and patching the .html files requires reading that
// header after the SVG is patched, we first process the .svg files and
// then the other files.
for (di.toFirst();(map=di.current());++di)
{
if (map->file().right(4)==".svg")
{
msg("Patching output file %d/%d\n",i,numDotMaps);
if (!map->run()) return FALSE;
i++;
}
}
for (di.toFirst();(map=di.current());++di)
{
if (map->file().right(4)!=".svg")
{
msg("Patching output file %d/%d\n",i,numDotMaps);
if (!map->run()) return FALSE;
i++;
}
}
return TRUE;
}

Member Data Documentation

SDict<DotFilePatcher> DotManager::m_dotMaps
private

Definition at line 482 of file dot.h.

Referenced by addFigure(), addMap(), addSVGConversion(), addSVGObject(), DotManager(), and run().

QList<DotRunner> DotManager::m_dotRuns
private

Definition at line 481 of file dot.h.

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

DotRunnerQueue* DotManager::m_queue
private

Definition at line 484 of file dot.h.

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

DotManager * DotManager::m_theInstance = 0
staticprivate

Definition at line 483 of file dot.h.

Referenced by instance().

QList<DotWorkerThread> DotManager::m_workers
private

Definition at line 485 of file dot.h.

Referenced by DotManager(), and run().


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