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 
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 
56 class FilePairLinkedMap : public LinkedMap<FilePair>
57 {
58 };
59 
60 // ------------------
61 
63 class UsedDir
64 {
65  public:
66  UsedDir(const DirDef *dir);
67  virtual ~UsedDir();
68 
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 
84  bool hasDirectDeps() const { return m_hasDirectDeps; }
85 
89  bool hasDirectSrcDeps() const { return m_hasDirectSrcDeps; }
90 
94  bool hasDirectDstDeps() const { return m_hasDirectDstDeps; }
95 
96  void sort();
97 
98  private:
99  const DirDef *m_dir;
100  FilePairLinkedMap m_filePairs;
101 
102  bool m_hasDirectDeps = false;
103  bool m_hasDirectSrcDeps = false;
104  bool m_hasDirectDstDeps = false;
105 };
106 
107 // ------------------
108 
110 class DirDef : public DefinitionMutable, public Definition
111 {
112  public:
113  class UsedDirLinkedMap : public LinkedMap<UsedDir> {};
114 
115  // accessors
116  virtual DefType definitionType() const = 0;
117  virtual QCString getOutputFileBase() const = 0;
118  virtual QCString anchor() const = 0;
119  virtual bool isLinkableInProject() const = 0;
120  virtual bool isLinkable() const = 0;
121  virtual QCString displayName(bool=TRUE) const = 0;
122  virtual const QCString shortName() const = 0;
123  virtual void addSubDir(DirDef *subdir) = 0;
124  virtual const FileList &getFiles() const = 0;
125  virtual void addFile(const FileDef *fd) = 0;
126  virtual const DirList &subDirs() const = 0;
127  virtual bool hasSubdirs() const = 0;
128  virtual int level() const = 0;
129  virtual DirDef *parent() const = 0;
130  virtual int dirCount() const = 0;
131  virtual const UsedDirLinkedMap &usedDirs() const = 0;
132  virtual bool isParentOf(const DirDef *dir) const = 0;
133  virtual bool depGraphIsTrivial() const = 0;
134  virtual QCString shortTitle() const = 0;
135  virtual bool hasDetailedDescription() const = 0;
136 
137  // generate output
138  virtual void writeDocumentation(OutputList &ol) = 0;
139  virtual void writeTagFile(TextStream &t) = 0;
140 
141  virtual void setDiskName(const QCString &name) = 0;
142  virtual void setDirCount(int count) = 0;
143  virtual void sort() = 0;
144  virtual void setParent(DirDef *parent) = 0;
145  virtual void setLevel() = 0;
146  virtual void addUsesDependency(const DirDef *usedDir,const FileDef *srcFd,
147  const FileDef *dstFd,bool srcDirect, bool dstDirect) = 0;
148  virtual void computeDependencies() = 0;
149 };
150 
151 // --- Cast functions
152 
153 DirDef *toDirDef(Definition *d);
154 const DirDef *toDirDef(const Definition *d);
155 
158 {
159  public:
160  DirRelation(const QCString &name,const DirDef *src,UsedDir *dst)
161  : m_name(name), m_src(src), m_dst(dst) {}
162  const DirDef *source() const { return m_src; }
163  UsedDir *destination() const { return m_dst; }
164  void writeDocumentation(OutputList &ol);
165  QCString getOutputFileBase() const { return m_name; }
166 
167  private:
168  QCString m_name;
169  const DirDef *m_src;
170  UsedDir *m_dst;
171 };
172 
174 class DirLinkedMap : public LinkedMap<DirDef>
175 {
176 };
177 
179 class DirList : public std::vector<const DirDef*>
180 {
181 };
182 
183 class DirRelationLinkedMap : public LinkedMap<DirRelation>
184 {
185 };
186 
187 // ------------------
188 
189 void buildDirectories();
190 void generateDirDocs(OutputList &ol);
191 void computeDirDependencies();
192 
193 #endif
A linked map of directories.
Definition: dirdef.h:174
bool hasDirectDeps() const
Returns true iff any of the dependencies between source and destination files are direct (i...
Definition: dirdef.h:84
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
Text streaming class that buffers data.
Definition: textstream.h:34
A model of a file symbol.
Definition: filedef.h:72
A usage relation between two directories.
Definition: dirdef.h:157
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
Class representing a pair of FileDef objects.
Definition: dirdef.h:41
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
Usage information of a directory.
Definition: dirdef.h:63
A list of directories.
Definition: dirdef.h:179
Definition: definition.h:303
Definition: dirdef.h:183
A model of a directory symbol.
Definition: dirdef.h:110
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
Definition: filedef.h:202
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:37
Definition: dirdef.h:113
DefType
Definition: definition.h:80
This is an alternative implementation of QCString.
Definition: qcstring.h:108
A linked map of file pairs.
Definition: dirdef.h:56