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

Representation of an call graph. More...

#include <src/dotcallgraph.h>

+ Inheritance diagram for DotCallGraph:
+ Collaboration diagram for DotCallGraph:

Public Member Functions

 DotCallGraph (const MemberDef *md, bool inverse)
 
 ~DotCallGraph () override
 
bool isTrivial () const
 
bool isTooBig () const
 
int numNodes () const
 
QCString writeGraph (TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
 
- Public Member Functions inherited from DotGraph
 DotGraph ()
 
virtual ~DotGraph ()=default
 

Static Public Member Functions

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

Protected Member Functions

QCString getBaseName () const override
 
QCString getMapLabel () const override
 
void computeTheGraph () override
 
- Protected Member Functions inherited from DotGraph
int getNextNodeNumber ()
 returns the node number.
 
int getNextEdgeNumber ()
 returns the edge number.
 
QCString writeGraph (TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
 
virtual QCString absMapName () const
 
virtual QCString getImgAltText () const
 
QCString absBaseName () const
 
QCString absDotName () const
 
QCString imgName () const
 
QCString absImgName () const
 
QCString relImgName () const
 

Private Member Functions

void buildGraph (DotNode *n, const MemberDef *md, int distance)
 
void determineVisibleNodes (DotNodeDeque &queue, int &maxNodes)
 
void determineTruncatedNodes (DotNodeDeque &queue)
 

Private Attributes

DotNodem_startNode
 
DotNodeMap m_usedNodes
 
bool m_inverse
 
QCString m_diskName
 
const Definitionm_scope
 

Additional Inherited Members

- Static Protected Member Functions inherited from DotGraph
static void writeGraphHeader (TextStream &t, const QCString &title=QCString())
 
static void writeGraphFooter (TextStream &t)
 
static void computeGraph (DotNode *root, GraphType gt, GraphOutputFormat format, const QCString &rank, bool renderParents, bool backArrows, const QCString &title, QCString &graphStr)
 
- Protected Attributes inherited from DotGraph
GraphOutputFormat m_graphFormat = GraphOutputFormat::BITMAP
 
EmbeddedOutputFormat m_textFormat = EmbeddedOutputFormat::Html
 
Dir m_dir
 
QCString m_fileName
 
QCString m_relPath
 
bool m_generateImageMap = false
 
int m_graphId = 0
 
QCString m_absPath
 
QCString m_baseName
 
QCString m_theGraph
 
bool m_regenerate = false
 
bool m_doNotAddImageToIndex = false
 
bool m_noDivTag = false
 
bool m_zoomable = true
 
bool m_urlOnly = false
 

Detailed Description

Representation of an call graph.

Definition at line 26 of file dotcallgraph.h.

Constructor & Destructor Documentation

◆ DotCallGraph()

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

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}
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual QCString qualifiedName() const =0
virtual QCString getOutputFileBase() const =0
virtual Definition * getOuterScope() const =0
virtual const QCString & name() const =0
void buildGraph(DotNode *n, const MemberDef *md, int distance)
DotNode * m_startNode
const Definition * m_scope
DotNodeMap m_usedNodes
QCString m_diskName
void determineTruncatedNodes(DotNodeDeque &queue)
void determineVisibleNodes(DotNodeDeque &queue, int &maxNodes)
friend class DotNode
Definition dotgraph.h:36
const std::string & str() const
Definition qcstring.h:526
#define Config_getInt(name)
Definition config.h:34
#define Config_getBool(name)
Definition config.h:33
static QCString getUniqueId(const MemberDef *md)
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
QCString linkToText(SrcLangExt lang, const QCString &link, bool isFileName)
Definition util.cpp:3100

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.

◆ ~DotCallGraph()

DotCallGraph::~DotCallGraph ( )
override

Definition at line 155 of file dotcallgraph.cpp.

156{
158}
static void deleteNodes(DotNode *node)
Definition dotnode.cpp:380

References DotNode::deleteNodes(), and m_startNode.

Member Function Documentation

◆ buildGraph()

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

Definition at line 33 of file dotcallgraph.cpp.

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}
virtual const MemberVector & getReferencedByMembers() const =0
virtual const MemberVector & getReferencesMembers() const =0
void setDistance(int distance)
Definition dotnode.cpp:366
void addParent(DotNode *n)
Definition dotnode.cpp:331
void addChild(DotNode *n, EdgeInfo::Colors edgeColor=EdgeInfo::Purple, EdgeInfo::Styles edgeStyle=EdgeInfo::Solid, const QCString &edgeLab=QCString(), const QCString &edgeURL=QCString(), int edgeLabCol=-1)
Definition dotnode.cpp:314
@ Solid
Definition dotnode.h:36

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().

◆ computeTheGraph()

void DotCallGraph::computeTheGraph ( )
overrideprotectedvirtual

Implements DotGraph.

Definition at line 165 of file dotcallgraph.cpp.

166{
171 m_inverse ? "RL" : "LR",
172 FALSE,
173 m_inverse,
174 m_startNode->label(),
175 m_theGraph);
176}
static void computeGraph(DotNode *root, GraphType gt, GraphOutputFormat format, const QCString &rank, bool renderParents, bool backArrows, const QCString &title, QCString &graphStr)
Definition dotgraph.cpp:306
GraphOutputFormat m_graphFormat
Definition dotgraph.h:85
QCString m_theGraph
Definition dotgraph.h:95
@ CallGraph
Definition dotgraph.h:31

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

◆ determineTruncatedNodes()

void DotCallGraph::determineTruncatedNodes ( DotNodeDeque & queue)
private

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}
DotNode & markAsTruncated(bool b=TRUE)
Definition dotnode.h:121
bool isVisible() const
Definition dotnode.h:104
@ Unknown
Definition dotnode.h:76
const DotNodeRefVector & children() const
Definition dotnode.h:122
TruncState isTruncated() const
Definition dotnode.h:105

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 )
private

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}
int distance() const
Definition dotnode.h:106
void markAsVisible(bool b=TRUE)
Definition dotnode.h:120

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

Referenced by DotCallGraph().

◆ getBaseName()

QCString DotCallGraph::getBaseName ( ) const
overrideprotectedvirtual

Implements DotGraph.

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 ( ) const
overrideprotectedvirtual

Implements DotGraph.

Definition at line 178 of file dotcallgraph.cpp.

179{
180 return m_baseName;
181}
QCString m_baseName
Definition dotgraph.h:94

References DotGraph::m_baseName.

◆ isTooBig()

bool DotCallGraph::isTooBig ( ) const

Definition at line 202 of file dotcallgraph.cpp.

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

References Config_getInt, and numNodes().

Referenced by MemberDefImpl::_writeCallerGraph(), and MemberDefImpl::_writeCallGraph().

◆ isTrivial() [1/2]

bool DotCallGraph::isTrivial ( ) const

◆ isTrivial() [2/2]

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

Definition at line 212 of file dotcallgraph.cpp.

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.

◆ numNodes()

int DotCallGraph::numNodes ( ) const

Definition at line 207 of file dotcallgraph.cpp.

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

References 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 )

Definition at line 183 of file dotcallgraph.cpp.

191{
193
194 return DotGraph::writeGraph(out, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
195}
bool m_doNotAddImageToIndex
Definition dotgraph.h:97
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
Definition dotgraph.cpp:115

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

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

Member Data Documentation

◆ m_diskName

QCString DotCallGraph::m_diskName
private

Definition at line 54 of file dotcallgraph.h.

Referenced by DotCallGraph(), and getBaseName().

◆ m_inverse

bool DotCallGraph::m_inverse
private

Definition at line 53 of file dotcallgraph.h.

Referenced by buildGraph(), computeTheGraph(), DotCallGraph(), and getBaseName().

◆ m_scope

const Definition* DotCallGraph::m_scope
private

Definition at line 55 of file dotcallgraph.h.

Referenced by buildGraph(), and DotCallGraph().

◆ m_startNode

DotNode* DotCallGraph::m_startNode
private

Definition at line 51 of file dotcallgraph.h.

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

◆ m_usedNodes

DotNodeMap DotCallGraph::m_usedNodes
private

Definition at line 52 of file dotcallgraph.h.

Referenced by buildGraph(), and DotCallGraph().


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