Skip to main content

The DotCallGraph Class Reference

Representation of an call graph. More...

Declaration

class DotCallGraph { ... }

Included Headers

#include <src/dotcallgraph.h>

Base class

classDotGraph

A dot graph. More...

Public Constructors Index

DotCallGraph (const MemberDef *md, bool inverse)

Public Destructor Index

~DotCallGraph () override

Public Member Functions Index

boolisTrivial () const
boolisTooBig () const
intnumNodes () const
QCStringwriteGraph (TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)

Protected Member Functions Index

QCStringgetBaseName () const override
QCStringgetMapLabel () const override
voidcomputeTheGraph () override

Private Member Functions Index

voidbuildGraph (DotNode *n, const MemberDef *md, int distance)
voiddetermineVisibleNodes (DotNodeDeque &queue, int &maxNodes)
voiddetermineTruncatedNodes (DotNodeDeque &queue)

Private Member Attributes Index

DotNode *m_startNode
DotNodeMapm_usedNodes
boolm_inverse
QCStringm_diskName
const Definition *m_scope

Public Static Functions Index

static boolisTrivial (const MemberDef *md, bool inverse)

Description

Representation of an call graph.

Definition at line 26 of file dotcallgraph.h.

Public Constructors

DotCallGraph()

DotCallGraph::DotCallGraph (const MemberDef * md, bool inverse)

Declaration at line 29 of file dotcallgraph.h, definition at line 120 of file dotcallgraph.cpp.

121{
122 m_inverse = inverse;
123 m_diskName = md->getOutputFileBase()+"_"+md->anchor();
124 m_scope = md->getOuterScope();
125 QCString uniqueId = getUniqueId(md);
126 QCString name;
127 if (Config_getBool(HIDE_SCOPE_NAMES))
128 {
129 name = md->name();
130 }
131 else
132 {
133 name = md->qualifiedName();
134 }
135 QCString tooltip = md->briefDescriptionAsTooltip();
136 m_startNode = new DotNode(this,
137 linkToText(md->getLanguage(),name,FALSE),
138 tooltip,
139 uniqueId,
140 TRUE // root node
141 );
142 m_startNode->setDistance(0);
143 m_usedNodes.emplace(uniqueId.str(),m_startNode);
145
146 int maxNodes = Config_getInt(DOT_GRAPH_MAX_NODES);
147 DotNodeDeque openNodeQueue;
148 openNodeQueue.push_back(m_startNode);
149 determineVisibleNodes(openNodeQueue,maxNodes);
150 openNodeQueue.clear();
151 openNodeQueue.push_back(m_startNode);
152 determineTruncatedNodes(openNodeQueue);
153}

References Definition::anchor, Definition::briefDescriptionAsTooltip, buildGraph, Config_getBool, Config_getInt, determineTruncatedNodes, determineVisibleNodes, DotGraph::DotNode, FALSE, Definition::getLanguage, Definition::getOuterScope, Definition::getOutputFileBase, getUniqueId, linkToText, m_diskName, m_inverse, m_scope, m_startNode, m_usedNodes, Definition::name, Definition::qualifiedName, QCString::str and TRUE.

Public Destructor

~DotCallGraph()

DotCallGraph::~DotCallGraph ()

Declaration at line 30 of file dotcallgraph.h, definition at line 155 of file dotcallgraph.cpp.

References DotNode::deleteNodes and m_startNode.

Public Member Functions

isTooBig()

bool DotCallGraph::isTooBig ()

Declaration at line 34 of file dotcallgraph.h, definition at line 202 of file dotcallgraph.cpp.

203{
204 return numNodes()>=Config_getInt(DOT_GRAPH_MAX_NODES);
205}

References Config_getInt and numNodes.

Referenced by MemberDefImpl::_writeCallerGraph and MemberDefImpl::_writeCallGraph.

isTrivial()

bool DotCallGraph::isTrivial ()

Declaration at line 33 of file dotcallgraph.h, definition at line 197 of file dotcallgraph.cpp.

198{
199 return m_startNode->children().empty();
200}

Reference m_startNode.

Referenced by MemberDefImpl::_hasVisibleCallerGraph, MemberDefImpl::_hasVisibleCallGraph, MemberDefImpl::_writeCallerGraph and MemberDefImpl::_writeCallGraph.

numNodes()

int DotCallGraph::numNodes ()

Declaration at line 35 of file dotcallgraph.h, definition at line 207 of file dotcallgraph.cpp.

208{
209 return static_cast<int>(m_startNode->children().size());
210}

Reference m_startNode.

Referenced by MemberDefImpl::_writeCallerGraph, MemberDefImpl::_writeCallGraph and isTooBig.

writeGraph()

QCString DotCallGraph::writeGraph (TextStream & t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString & path, const QCString & fileName, const QCString & relPath, bool writeImageMap=TRUE, int graphId=-1)

Declaration at line 36 of file dotcallgraph.h, definition at line 183 of file dotcallgraph.cpp.

184 TextStream &out,
185 GraphOutputFormat graphFormat,
186 EmbeddedOutputFormat textFormat,
187 const QCString &path,
188 const QCString &fileName,
189 const QCString &relPath,bool generateImageMap,
190 int graphId)
191{
193
194 return DotGraph::writeGraph(out, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
195}

References Html, DotGraph::m_doNotAddImageToIndex and DotGraph::writeGraph.

Referenced by DocbookGenerator::endCallGraph, HtmlGenerator::endCallGraph, LatexGenerator::endCallGraph and RTFGenerator::endCallGraph.

Protected Member Functions

computeTheGraph()

void DotCallGraph::computeTheGraph ()
protected virtual

Declaration at line 45 of file dotcallgraph.h, definition at line 165 of file dotcallgraph.cpp.

166{
171 m_inverse ? "RL" : "LR",
172 FALSE,
174 m_startNode->label(),
176}

References CallGraph, DotGraph::computeGraph, FALSE, DotGraph::m_graphFormat, m_inverse, m_startNode and DotGraph::m_theGraph.

getBaseName()

QCString DotCallGraph::getBaseName ()
protected virtual

Declaration at line 43 of file dotcallgraph.h, definition at line 160 of file dotcallgraph.cpp.

161{
162 return m_diskName + (m_inverse ? "_icgraph" : "_cgraph");
163}

References m_diskName and m_inverse.

getMapLabel()

QCString DotCallGraph::getMapLabel ()
protected virtual

Declaration at line 44 of file dotcallgraph.h, definition at line 178 of file dotcallgraph.cpp.

179{
180 return m_baseName;
181}

Reference DotGraph::m_baseName.

Private Member Functions

buildGraph()

void DotCallGraph::buildGraph (DotNode * n, const MemberDef * md, int distance)

Declaration at line 48 of file dotcallgraph.h, definition at line 33 of file dotcallgraph.cpp.

33void DotCallGraph::buildGraph(DotNode *n,const MemberDef *md,int distance)
34{
35 auto refs = m_inverse ? md->getReferencedByMembers() : md->getReferencesMembers();
36 for (const auto &rmd : refs)
37 {
38 if (rmd->isCallable())
39 {
40 QCString uniqueId = getUniqueId(rmd);
41 auto it = m_usedNodes.find(uniqueId.str());
42 if (it!=m_usedNodes.end()) // file is already a node in the graph
43 {
44 DotNode *bn = it->second;
46 bn->addParent(n);
47 bn->setDistance(distance);
48 }
49 else
50 {
51 QCString name;
52 if (Config_getBool(HIDE_SCOPE_NAMES))
53 {
54 name = rmd->getOuterScope()==m_scope ?
55 rmd->name() : rmd->qualifiedName();
56 }
57 else
58 {
59 name = rmd->qualifiedName();
60 }
61 QCString tooltip = rmd->briefDescriptionAsTooltip();
62 DotNode *bn = new DotNode(
63 this,
64 linkToText(rmd->getLanguage(),name,FALSE),
65 tooltip,
66 uniqueId,
67 0 //distance
68 );
70 bn->addParent(n);
71 bn->setDistance(distance);
72 m_usedNodes.emplace(uniqueId.str(),bn);
73
74 buildGraph(bn,rmd,distance+1);
75 }
76 }
77 }
78}

References DotNode::addChild, DotNode::addParent, EdgeInfo::Blue, buildGraph, Config_getBool, DotGraph::DotNode, FALSE, Definition::getReferencedByMembers, Definition::getReferencesMembers, getUniqueId, linkToText, m_inverse, m_scope, m_usedNodes, DotNode::setDistance, EdgeInfo::Solid and QCString::str.

Referenced by buildGraph and DotCallGraph.

determineTruncatedNodes()

void DotCallGraph::determineTruncatedNodes (DotNodeDeque & queue)

Declaration at line 50 of file dotcallgraph.h, definition at line 99 of file dotcallgraph.cpp.

100{
101 while (!queue.empty())
102 {
103 DotNode *n = queue.front();
104 queue.pop_front();
105 if (n->isVisible() && n->isTruncated()==DotNode::Unknown)
106 {
107 bool truncated = FALSE;
108 for (const auto &dn : n->children())
109 {
110 if (!dn->isVisible())
111 truncated = TRUE;
112 else
113 queue.push_back(dn);
114 }
115 n->markAsTruncated(truncated);
116 }
117 }
118}

References DotNode::children, DotGraph::DotNode, FALSE, DotNode::isTruncated, DotNode::isVisible, DotNode::markAsTruncated, TRUE and DotNode::Unknown.

Referenced by DotCallGraph.

determineVisibleNodes()

void DotCallGraph::determineVisibleNodes (DotNodeDeque & queue, int & maxNodes)

Declaration at line 49 of file dotcallgraph.h, definition at line 80 of file dotcallgraph.cpp.

81{
82 while (!queue.empty() && maxNodes>0)
83 {
84 DotNode *n = queue.front();
85 queue.pop_front();
86 if (!n->isVisible() && n->distance()<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed
87 {
88 n->markAsVisible();
89 maxNodes--;
90 // add direct children
91 for (const auto &dn : n->children())
92 {
93 queue.push_back(dn);
94 }
95 }
96 }
97}

References DotNode::children, Config_getInt, DotNode::distance, DotGraph::DotNode, DotNode::isVisible and DotNode::markAsVisible.

Referenced by DotCallGraph.

Private Member Attributes

m_diskName

QCString DotCallGraph::m_diskName

Definition at line 54 of file dotcallgraph.h.

Referenced by DotCallGraph and getBaseName.

m_inverse

bool DotCallGraph::m_inverse

Definition at line 53 of file dotcallgraph.h.

Referenced by buildGraph, computeTheGraph, DotCallGraph and getBaseName.

m_scope

const Definition* DotCallGraph::m_scope

Definition at line 55 of file dotcallgraph.h.

Referenced by buildGraph and DotCallGraph.

m_startNode

DotNode* DotCallGraph::m_startNode

Definition at line 51 of file dotcallgraph.h.

Referenced by computeTheGraph, DotCallGraph, isTrivial, numNodes and ~DotCallGraph.

m_usedNodes

DotNodeMap DotCallGraph::m_usedNodes

Definition at line 52 of file dotcallgraph.h.

Referenced by buildGraph and DotCallGraph.

Public Static Functions

isTrivial()

bool DotCallGraph::isTrivial (const MemberDef * md, bool inverse)
static

Declaration at line 40 of file dotcallgraph.h, definition at line 212 of file dotcallgraph.cpp.

212bool DotCallGraph::isTrivial(const MemberDef *md,bool inverse)
213{
214 auto refs = inverse ? md->getReferencedByMembers() : md->getReferencesMembers();
215 for (const auto &rmd : refs)
216 {
217 if (rmd->isCallable())
218 {
219 return FALSE;
220 }
221 }
222 return TRUE;
223}

References FALSE, Definition::getReferencedByMembers, Definition::getReferencesMembers and TRUE.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.