summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dirdef.cpp58
-rw-r--r--src/dirdef.h101
-rw-r--r--src/dotdirdeps.cpp27
3 files changed, 102 insertions, 84 deletions
diff --git a/src/dirdef.cpp b/src/dirdef.cpp
index b7f508c..52cbe6f 100644
--- a/src/dirdef.cpp
+++ b/src/dirdef.cpp
@@ -1,6 +1,22 @@
-#include "md5.h"
+/******************************************************************************
+ *
+ * Copyright (C) 1997-2020 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ *
+ */
+
+#include <algorithm>
#include "dirdef.h"
+#include "md5.h"
#include "filename.h"
#include "doxygen.h"
#include "util.h"
@@ -15,7 +31,7 @@
#include "docparser.h"
#include "definitionimpl.h"
#include "filedef.h"
-#include <algorithm>
+
//----------------------------------------------------------------------
@@ -40,7 +56,7 @@ class DirDefImpl : public DefinitionMixin<DirDef>
virtual int level() const { return m_level; }
virtual DirDef *parent() const { return m_parent; }
virtual int dirCount() const { return m_dirCount; }
- virtual const UsedDirsContainer *usedDirs() const { return m_usedDirs; }
+ virtual const UsedDirLinkedMap &usedDirs() const { return m_usedDirs; }
virtual bool isParentOf(const DirDef *dir) const;
virtual bool depGraphIsTrivial() const;
virtual QCString shortTitle() const;
@@ -79,7 +95,7 @@ class DirDefImpl : public DefinitionMixin<DirDef>
int m_dirCount;
int m_level;
DirDef *m_parent;
- UsedDirsContainer *m_usedDirs;
+ UsedDirLinkedMap m_usedDirs;
};
DirDef *createDirDef(const char *path)
@@ -117,7 +133,6 @@ DirDefImpl::DirDefImpl(const char *path) : DefinitionMixin(path,1,1,path)
}
m_fileList = new FileList;
- m_usedDirs = new UsedDirsContainer();
m_dirCount = g_dirCount++;
m_level=-1;
m_parent=0;
@@ -126,11 +141,6 @@ DirDefImpl::DirDefImpl(const char *path) : DefinitionMixin(path,1,1,path)
DirDefImpl::~DirDefImpl()
{
delete m_fileList;
- for (const auto &usedDirectory : *m_usedDirs)
- {
- delete usedDirectory.second;
- }
- delete m_usedDirs;
}
bool DirDefImpl::isLinkableInProject() const
@@ -644,12 +654,10 @@ void DirDefImpl::addUsesDependency(DirDef *dir,FileDef *srcFd,
// levels match => add direct dependency
bool added=FALSE;
- UsedDir *usedDir = nullptr;
- const auto usedDirectoryEntry = m_usedDirs->find(dir->getOutputFileBase());
- if (usedDirectoryEntry != m_usedDirs->end()) // dir dependency already present
+ UsedDir *usedDir = m_usedDirs.find(dir->getOutputFileBase());
+ if (usedDir) // dir dependency already present
{
- usedDir = usedDirectoryEntry->second;
- FilePair *usedPair = usedDir->findFilePair(
+ const FilePair *usedPair = usedDir->findFilePair(
srcFd->getOutputFileBase()+dstFd->getOutputFileBase());
if (usedPair==0) // new file dependency
{
@@ -665,9 +673,9 @@ void DirDefImpl::addUsesDependency(DirDef *dir,FileDef *srcFd,
else // new directory dependency
{
//printf(" => new file\n");
- usedDir = new UsedDir(dir,inherited);
- usedDir->addFileDep(srcFd,dstFd);
- m_usedDirs->insert({dir->getOutputFileBase(),usedDir});
+ auto newUsedDir = std::make_unique<UsedDir>(dir,inherited);
+ newUsedDir->addFileDep(srcFd,dstFd);
+ usedDir = m_usedDirs.add(dir->getOutputFileBase(),std::move(newUsedDir));
added=TRUE;
}
if (added)
@@ -722,12 +730,14 @@ void DirDefImpl::computeDependencies()
}
}
}
- if (m_usedDirs)
+
+ std::sort(m_usedDirs.begin(),m_usedDirs.end(),
+ [](const auto &u1,const auto &u2)
+ { return qstricmp(u1->dir()->getOutputFileBase(),u2->dir()->getOutputFileBase())<0; });
+
+ for (const auto& usedDirectory : m_usedDirs)
{
- for(const auto& usedDirectory : *m_usedDirs)
- {
- usedDirectory.second->sort();
- }
+ usedDirectory->sort();
}
}
@@ -743,7 +753,7 @@ bool DirDefImpl::isParentOf(const DirDef *dir) const
bool DirDefImpl::depGraphIsTrivial() const
{
- return m_usedDirs->empty();
+ return m_usedDirs.empty();
}
//----------------------------------------------------------------------
diff --git a/src/dirdef.h b/src/dirdef.h
index e7d0c6d..bbb5fe6 100644
--- a/src/dirdef.h
+++ b/src/dirdef.h
@@ -16,6 +16,7 @@
#ifndef DIRDEF_H
#define DIRDEF_H
+#include "linkedmap.h"
#include "sortdict.h"
#include "definition.h"
@@ -30,7 +31,8 @@ class FileDef;
class OutputList;
class UsedDir;
class FTextStream;
-
+class FilePair;
+class FilePairDict;
class DirDef;
/** A list of directories. */
@@ -38,13 +40,61 @@ typedef std::vector<DirDef*> DirList;
bool compareDirDefs(const DirDef *item1, const DirDef *item2);
+// ------------------
+
+/** Class representing a pair of FileDef objects */
+class FilePair
+{
+ public:
+ FilePair(FileDef *src,FileDef *dst) : m_src(src), m_dst(dst) {}
+ const FileDef *source() const { return m_src; }
+ const FileDef *destination() const { return m_dst; }
+ private:
+ FileDef *m_src;
+ FileDef *m_dst;
+};
+
+// ------------------
+
+/** A sorted dictionary of FilePair objects. */
+class FilePairDict : public SDict<FilePair>
+{
+ public:
+ FilePairDict(uint size) : SDict<FilePair>(size) {}
+ private:
+ int compareValues(const FilePair *item1,const FilePair *item2) const;
+};
+
+// ------------------
+
+/** Usage information of a directory. */
+class UsedDir
+{
+ public:
+ UsedDir(const DirDef *dir,bool inherited);
+ virtual ~UsedDir();
+ void addFileDep(FileDef *srcFd,FileDef *dstFd);
+ FilePair *findFilePair(const char *name);
+ const FilePairDict &filePairs() const { return m_filePairs; }
+ const DirDef *dir() const { return m_dir; }
+ bool inherited() const { return m_inherited; }
+ void sort();
+
+ private:
+ const DirDef *m_dir;
+ FilePairDict m_filePairs;
+ bool m_inherited;
+};
+
+// ------------------
+
/** A model of a directory symbol. */
class DirDef : public DefinitionMutable, public Definition
{
public:
virtual ~DirDef() {}
- using UsedDirsContainer = std::map<QCString, UsedDir * >;
+ class UsedDirLinkedMap : public LinkedMap<UsedDir> {};
// accessors
virtual DefType definitionType() const = 0;
@@ -62,7 +112,7 @@ class DirDef : public DefinitionMutable, public Definition
virtual int level() const = 0;
virtual DirDef *parent() const = 0;
virtual int dirCount() const = 0;
- virtual const UsedDirsContainer* usedDirs() const = 0;
+ virtual const UsedDirLinkedMap &usedDirs() const = 0;
virtual bool isParentOf(const DirDef *dir) const = 0;
virtual bool depGraphIsTrivial() const = 0;
virtual QCString shortTitle() const = 0;
@@ -86,49 +136,6 @@ class DirDef : public DefinitionMutable, public Definition
DirDef *toDirDef(Definition *d);
const DirDef *toDirDef(const Definition *d);
-// ------------------
-
-
-/** Class representing a pair of FileDef objects */
-class FilePair
-{
- public:
- FilePair(FileDef *src,FileDef *dst) : m_src(src), m_dst(dst) {}
- const FileDef *source() const { return m_src; }
- const FileDef *destination() const { return m_dst; }
- private:
- FileDef *m_src;
- FileDef *m_dst;
-};
-
-/** A sorted dictionary of FilePair objects. */
-class FilePairDict : public SDict<FilePair>
-{
- public:
- FilePairDict(uint size) : SDict<FilePair>(size) {}
- private:
- int compareValues(const FilePair *item1,const FilePair *item2) const;
-};
-
-/** Usage information of a directory. */
-class UsedDir
-{
- public:
- UsedDir(const DirDef *dir,bool inherited);
- virtual ~UsedDir();
- void addFileDep(FileDef *srcFd,FileDef *dstFd);
- FilePair *findFilePair(const char *name);
- const FilePairDict &filePairs() const { return m_filePairs; }
- const DirDef *dir() const { return m_dir; }
- bool inherited() const { return m_inherited; }
- void sort();
-
- private:
- const DirDef *m_dir;
- FilePairDict m_filePairs;
- bool m_inherited;
-};
-
/** A usage relation between two directories. */
class DirRelation
{
@@ -157,6 +164,8 @@ class DirSDict : public SDict<DirDef>
}
};
+// ------------------
+
void buildDirectories();
void generateDirDocs(OutputList &ol);
diff --git a/src/dotdirdeps.cpp b/src/dotdirdeps.cpp
index 2a292df..a670d68 100644
--- a/src/dotdirdeps.cpp
+++ b/src/dotdirdeps.cpp
@@ -39,8 +39,8 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
if (dd->parent())
{
t << " subgraph cluster" << dd->parent()->getOutputFileBase() << " {\n";
- t << " graph [ bgcolor=\"#ddddee\", pencolor=\"black\", label=\""
- << dd->parent()->shortName()
+ t << " graph [ bgcolor=\"#ddddee\", pencolor=\"black\", label=\""
+ << dd->parent()->shortName()
<< "\" fontname=\"" << fontName << "\", fontsize=\"" << fontSize << "\", URL=\"";
t << dd->parent()->getOutputFileBase() << Doxygen::htmlFileExtension;
t << "\"]\n";
@@ -49,9 +49,9 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
{
t << " subgraph cluster" << dd->getOutputFileBase() << " {\n";
t << " graph [ bgcolor=\"#eeeeff\", pencolor=\"black\", label=\"\""
- << " URL=\"" << dd->getOutputFileBase() << Doxygen::htmlFileExtension
+ << " URL=\"" << dd->getOutputFileBase() << Doxygen::htmlFileExtension
<< "\"];\n";
- t << " " << dd->getOutputFileBase() << " [shape=plaintext label=\""
+ t << " " << dd->getOutputFileBase() << " [shape=plaintext label=\""
<< dd->shortName() << "\"];\n";
// add nodes for sub directories
@@ -77,9 +77,9 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
}
else
{
- t << " " << dd->getOutputFileBase() << " [shape=box, label=\""
+ t << " " << dd->getOutputFileBase() << " [shape=box, label=\""
<< dd->shortName() << "\", style=\"filled\", fillcolor=\"#eeeeff\","
- << " pencolor=\"black\", URL=\"" << dd->getOutputFileBase()
+ << " pencolor=\"black\", URL=\"" << dd->getOutputFileBase()
<< Doxygen::htmlFileExtension << "\"];\n";
}
if (dd->parent())
@@ -90,10 +90,10 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
// add nodes for other used directories
{
//printf("*** For dir %s\n",shortName().data());
- for (const auto &usedDirectoryEntry : *dd->usedDirs())
+ for (const auto &udir : dd->usedDirs())
// for each used dir (=directly used or a parent of a directly used dir)
{
- const DirDef *usedDir = usedDirectoryEntry.second->dir();
+ const DirDef *usedDir = udir->dir();
const DirDef *dir=dd;
while (dir)
{
@@ -104,11 +104,11 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
// shortName().data(),
// !usedDir->isParentOf(this)
// );
- if (dir!=usedDir && dir->parent()==usedDir->parent() &&
+ if (dir!=usedDir && dir->parent()==usedDir->parent() &&
!usedDir->isParentOf(dd))
// include if both have the same parent (or no parent)
{
- t << " " << usedDir->getOutputFileBase() << " [shape=box label=\""
+ t << " " << usedDir->getOutputFileBase() << " [shape=box label=\""
<< usedDir->shortName() << "\"";
if (usedDir->isCluster())
{
@@ -118,7 +118,7 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
}
t << " color=\"red\"";
}
- t << " URL=\"" << usedDir->getOutputFileBase()
+ t << " URL=\"" << usedDir->getOutputFileBase()
<< Doxygen::htmlFileExtension << "\"];\n";
dirsInGraph.insert(usedDir->getOutputFileBase(),usedDir);
break;
@@ -133,9 +133,8 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
QDictIterator<DirDef> di(dirsInGraph);
for (;(dir=di.current());++di) // foreach dir in the graph
{
- for (const auto &usedDirectoryEntry : *dir->usedDirs())
+ for (const auto &udir : dir->usedDirs())
{
- UsedDir *const udir = usedDirectoryEntry.second;
const DirDef *usedDir=udir->dir();
if ((dir!=dd || !udir->inherited()) && // only show direct dependencies for this dir
(usedDir!=dd || !udir->inherited()) && // only show direct dependencies for this dir
@@ -148,7 +147,7 @@ void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations)
{
// new relation
Doxygen::dirRelations.append(relationName,
- new DirRelation(relationName,dir,udir));
+ new DirRelation(relationName,dir,udir.get()));
}
int nrefs = udir->filePairs().count();
t << " " << dir->getOutputFileBase() << "->"