Doxygen
dirdef.h
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2020 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef DIRDEF_H
17 #define DIRDEF_H
18 
19 
20 #include <vector>
21 #include <map>
22 
23 #include "qcstring.h"
24 #include "linkedmap.h"
25 #include "definition.h"
26 
27 class FileList;
28 class FileDef;
29 class OutputList;
30 class UsedDir;
31 class FilePair;
32 class FilePairDict;
33 class DirDef;
34 class DirList;
35 
36 bool compareDirDefs(const DirDef *item1, const DirDef *item2);
37 
38 // ------------------
39 
40 /** Class representing a pair of FileDef objects */
41 class FilePair
42 {
43  public:
44  FilePair(const FileDef *src,const FileDef *dst) : m_src(src), m_dst(dst) {}
45  const FileDef *source() const { return m_src; }
46  const FileDef *destination() const { return m_dst; }
47  static QCString key(const FileDef *srcFd,const FileDef *dstFd);
48  private:
49  const FileDef *m_src;
50  const FileDef *m_dst;
51 };
52 
53 // ------------------
54 
55 /** A linked map of file pairs */
56 class FilePairLinkedMap : public LinkedMap<FilePair>
57 {
58 };
59 
60 // ------------------
61 
62 /** Usage information of a directory. */
63 class UsedDir
64 {
65  public:
66  UsedDir(const DirDef *dir);
67  virtual ~UsedDir();
68 
69  /**
70  * Take up dependency between files.
71  * @param[in] srcFd dependent file which depends on dstFd
72  * @param[in] dstFd dependee file on which srcFd depends on
73  * @param[in] srcDirect true iff the source dependency was the direct (not inherited from a sub dir)
74  * @param[in] dstDirect true iff the destination dependency was direct (not inherited from a sub dir)
75  */
76  void addFileDep(const FileDef *srcFd,const FileDef *dstFd, bool srcDirect, bool dstDirect);
77  FilePair *findFilePair(const QCString &name);
78  const FilePairLinkedMap &filePairs() const { return m_filePairs; }
79  const DirDef *dir() const { return m_dir; }
80 
81  /** Returns true iff any of the dependencies between source and destination files are
82  * direct (i.e. not "inherited" from sub directories)
83  */
84  bool hasDirectDeps() const { return m_hasDirectDeps; }
85 
86  /** Returns true iff any of the dependencies from the source file to the destination file are
87  * directly coming from a file in the source directory (i.e. not inherited via sub directories)
88  */
89  bool hasDirectSrcDeps() const { return m_hasDirectSrcDeps; }
90 
91  /** Returns true iff any of the dependencies from the source file to the destination file are
92  * directly targeting a file in the destination directory (i.e. not inherited via sub directories)
93  */
94  bool hasDirectDstDeps() const { return m_hasDirectDstDeps; }
95 
96  void sort();
97 
98  private:
99  const DirDef *m_dir;
101 
102  bool m_hasDirectDeps = false;
103  bool m_hasDirectSrcDeps = false;
104  bool m_hasDirectDstDeps = false;
105 };
106 
107 // ------------------
108 
109 /** A model of a directory symbol. */
110 class DirDef : public DefinitionMutable, public Definition
111 {
112  public:
113  virtual ~DirDef() {}
114 
115  class UsedDirLinkedMap : public LinkedMap<UsedDir> {};
116 
117  // accessors
118  virtual DefType definitionType() const = 0;
119  virtual QCString getOutputFileBase() const = 0;
120  virtual QCString anchor() const = 0;
121  virtual bool isLinkableInProject() const = 0;
122  virtual bool isLinkable() const = 0;
123  virtual QCString displayName(bool=TRUE) const = 0;
124  virtual const QCString shortName() const = 0;
125  virtual void addSubDir(DirDef *subdir) = 0;
126  virtual const FileList &getFiles() const = 0;
127  virtual void addFile(const FileDef *fd) = 0;
128  virtual const DirList &subDirs() const = 0;
129  virtual bool hasSubdirs() const = 0;
130  virtual int level() const = 0;
131  virtual DirDef *parent() const = 0;
132  virtual int dirCount() const = 0;
133  virtual const UsedDirLinkedMap &usedDirs() const = 0;
134  virtual bool isParentOf(const DirDef *dir) const = 0;
135  virtual bool depGraphIsTrivial() const = 0;
136  virtual QCString shortTitle() const = 0;
137  virtual bool hasDetailedDescription() const = 0;
138 
139  // generate output
140  virtual void writeDocumentation(OutputList &ol) = 0;
141  virtual void writeTagFile(TextStream &t) = 0;
142 
143  virtual void setDiskName(const QCString &name) = 0;
144  virtual void setDirCount(int count) = 0;
145  virtual void sort() = 0;
146  virtual void setParent(DirDef *parent) = 0;
147  virtual void setLevel() = 0;
148  virtual void addUsesDependency(const DirDef *usedDir,const FileDef *srcFd,
149  const FileDef *dstFd,bool srcDirect, bool dstDirect) = 0;
150  virtual void computeDependencies() = 0;
151 };
152 
153 // --- Cast functions
154 
156 const DirDef *toDirDef(const Definition *d);
157 
158 /** A usage relation between two directories. */
160 {
161  public:
162  DirRelation(const QCString &name,const DirDef *src,UsedDir *dst)
163  : m_name(name), m_src(src), m_dst(dst) {}
164  const DirDef *source() const { return m_src; }
165  UsedDir *destination() const { return m_dst; }
166  void writeDocumentation(OutputList &ol);
167  QCString getOutputFileBase() const { return m_name; }
168 
169  private:
171  const DirDef *m_src;
173 };
174 
175 /** A linked map of directories */
176 class DirLinkedMap : public LinkedMap<DirDef>
177 {
178 };
179 
180 /** A list of directories. */
181 class DirList : public std::vector<const DirDef*>
182 {
183 };
184 
185 class DirRelationLinkedMap : public LinkedMap<DirRelation>
186 {
187 };
188 
189 // ------------------
190 
191 void buildDirectories();
192 void generateDirDocs(OutputList &ol);
194 
195 #endif
DirRelation::source
const DirDef * source() const
Definition: dirdef.h:164
FilePair::destination
const FileDef * destination() const
Definition: dirdef.h:46
FilePair::key
static QCString key(const FileDef *srcFd, const FileDef *dstFd)
Definition: dirdef.cpp:836
UsedDir::~UsedDir
virtual ~UsedDir()
Definition: dirdef.cpp:756
compareDirDefs
bool compareDirDefs(const DirDef *item1, const DirDef *item2)
Definition: dirdef.cpp:1115
DirDef::definitionType
virtual DefType definitionType() const =0
DirRelation::destination
UsedDir * destination() const
Definition: dirdef.h:165
toDirDef
DirDef * toDirDef(Definition *d)
Definition: dirdef.cpp:1122
UsedDir::m_filePairs
FilePairLinkedMap m_filePairs
Definition: dirdef.h:100
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
DirDef::dirCount
virtual int dirCount() const =0
UsedDir::hasDirectDstDeps
bool hasDirectDstDeps() const
Returns true iff any of the dependencies from the source file to the destination file are directly ta...
Definition: dirdef.h:94
DirList
A list of directories.
Definition: dirdef.h:181
FilePair::FilePair
FilePair(const FileDef *src, const FileDef *dst)
Definition: dirdef.h:44
UsedDir::addFileDep
void addFileDep(const FileDef *srcFd, const FileDef *dstFd, bool srcDirect, bool dstDirect)
Take up dependency between files.
Definition: dirdef.cpp:760
UsedDir::m_hasDirectDstDeps
bool m_hasDirectDstDeps
Definition: dirdef.h:104
DirDef::usedDirs
virtual const UsedDirLinkedMap & usedDirs() const =0
DirDef::addFile
virtual void addFile(const FileDef *fd)=0
DirDef
A model of a directory symbol.
Definition: dirdef.h:110
FilePair::m_src
const FileDef * m_src
Definition: dirdef.h:49
DirDef::sort
virtual void sort()=0
DirDef::isParentOf
virtual bool isParentOf(const DirDef *dir) const =0
UsedDir::m_dir
const DirDef * m_dir
Definition: dirdef.h:99
DirDef::setDiskName
virtual void setDiskName(const QCString &name)=0
DirDef::hasSubdirs
virtual bool hasSubdirs() const =0
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
qcstring.h
linkedmap.h
UsedDir::UsedDir
UsedDir(const DirDef *dir)
Definition: dirdef.cpp:751
DirDef::level
virtual int level() const =0
UsedDir
Usage information of a directory.
Definition: dirdef.h:63
DirLinkedMap
A linked map of directories
Definition: dirdef.h:176
DirRelation::getOutputFileBase
QCString getOutputFileBase() const
Definition: dirdef.h:167
DirDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
OutputList
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
DirDef::writeTagFile
virtual void writeTagFile(TextStream &t)=0
DirDef::shortName
virtual const QCString shortName() const =0
DirDef::addUsesDependency
virtual void addUsesDependency(const DirDef *usedDir, const FileDef *srcFd, const FileDef *dstFd, bool srcDirect, bool dstDirect)=0
DirRelation::m_src
const DirDef * m_src
Definition: dirdef.h:171
DirRelation
A usage relation between two directories.
Definition: dirdef.h:159
DefinitionMutable
Definition: definition.h:308
FilePair::source
const FileDef * source() const
Definition: dirdef.h:45
FileList
Definition: filedef.h:205
UsedDir::m_hasDirectDeps
bool m_hasDirectDeps
Definition: dirdef.h:102
Definition::name
virtual QCString name() const =0
DirDef::isLinkableInProject
virtual bool isLinkableInProject() const =0
DirDef::anchor
virtual QCString anchor() const =0
DirRelation::m_dst
UsedDir * m_dst
Definition: dirdef.h:172
TRUE
#define TRUE
Definition: qcstring.h:36
DirDef::~DirDef
virtual ~DirDef()
Definition: dirdef.h:113
computeDirDependencies
void computeDirDependencies()
Definition: dirdef.cpp:1078
DirDef::hasDetailedDescription
virtual bool hasDetailedDescription() const =0
DirRelation::DirRelation
DirRelation(const QCString &name, const DirDef *src, UsedDir *dst)
Definition: dirdef.h:162
DirRelationLinkedMap
Definition: dirdef.h:185
Definition::DefType
DefType
Definition: definition.h:85
UsedDir::filePairs
const FilePairLinkedMap & filePairs() const
Definition: dirdef.h:78
DirDef::addSubDir
virtual void addSubDir(DirDef *subdir)=0
DirDef::setDirCount
virtual void setDirCount(int count)=0
DirDef::isLinkable
virtual bool isLinkable() const =0
FilePair
Class representing a pair of FileDef objects
Definition: dirdef.h:41
DirDef::UsedDirLinkedMap
Definition: dirdef.h:115
DirDef::shortTitle
virtual QCString shortTitle() const =0
generateDirDocs
void generateDirDocs(OutputList &ol)
Definition: dirdef.cpp:1094
definition.h
DirDef::writeDocumentation
virtual void writeDocumentation(OutputList &ol)=0
UsedDir::dir
const DirDef * dir() const
Definition: dirdef.h:79
UsedDir::findFilePair
FilePair * findFilePair(const QCString &name)
Definition: dirdef.cpp:781
DirDef::depGraphIsTrivial
virtual bool depGraphIsTrivial() const =0
DirDef::computeDependencies
virtual void computeDependencies()=0
DirRelation::writeDocumentation
void writeDocumentation(OutputList &ol)
Definition: dirdef.cpp:872
DirDef::setLevel
virtual void setLevel()=0
DirDef::getFiles
virtual const FileList & getFiles() const =0
FilePairLinkedMap
A linked map of file pairs
Definition: dirdef.h:56
FileDef
A model of a file symbol.
Definition: filedef.h:73
LinkedMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
UsedDir::m_hasDirectSrcDeps
bool m_hasDirectSrcDeps
Definition: dirdef.h:103
buildDirectories
void buildDirectories()
Definition: dirdef.cpp:1005
UsedDir::hasDirectSrcDeps
bool hasDirectSrcDeps() const
Returns true iff any of the dependencies from the source file to the destination file are directly co...
Definition: dirdef.h:89
DirDef::displayName
virtual QCString displayName(bool=TRUE) const =0
UsedDir::hasDirectDeps
bool hasDirectDeps() const
Returns true iff any of the dependencies between source and destination files are direct (i....
Definition: dirdef.h:84
DirDef::setParent
virtual void setParent(DirDef *parent)=0
DirDef::subDirs
virtual const DirList & subDirs() const =0
DirDef::parent
virtual DirDef * parent() const =0
UsedDir::sort
void sort()
Definition: dirdef.cpp:768
FilePair::m_dst
const FileDef * m_dst
Definition: dirdef.h:50
DirRelation::m_name
QCString m_name
Definition: dirdef.h:170
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108