ISLEman
dirdef.h
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #ifndef DIRDEF_H
19 #define DIRDEF_H
20 
21 #include "sortdict.h"
22 #include "definition.h"
23 
24 #include <qlist.h>
25 
26 class FileList;
27 class ClassSDict;
28 class QStrList;
29 class FileDef;
30 class OutputList;
31 class UsedDir;
32 class FTextStream;
33 
34 class DirDef;
35 
37 class DirList : public QList<DirDef>
38 {
39  public:
40  int compareValues(const DirDef *item1,const DirDef *item2) const;
41 };
42 
44 class DirDef : public Definition
45 {
46  public:
47  DirDef(const char *path);
48  virtual ~DirDef();
49 
50  // accessors
51  DefType definitionType() const { return TypeDir; }
52  QCString getOutputFileBase() const;
53  QCString anchor() const { return QCString(); }
54  bool isLinkableInProject() const;
55  bool isLinkable() const;
56  QCString displayName(bool=TRUE) const { return m_dispName; }
57  const QCString &shortName() const { return m_shortName; }
58  void addSubDir(DirDef *subdir);
59  FileList * getFiles() const { return m_fileList; }
60  void addFile(FileDef *fd);
61  const DirList &subDirs() const { return m_subdirs; }
62  bool isCluster() const { return m_subdirs.count()>0; }
63  int level() const { return m_level; }
64  DirDef *parent() const { return m_parent; }
65  int dirCount() const { return m_dirCount; }
66  const QDict<UsedDir> *usedDirs() const { return m_usedDirs; }
67  bool isParentOf(DirDef *dir) const;
68  bool depGraphIsTrivial() const;
69  QCString shortTitle() const;
70  bool hasDetailedDescription() const;
71 
72  // generate output
73  void writeDocumentation(OutputList &ol);
74  void writeTagFile(FTextStream &t);
75 
76  static DirDef *mergeDirectoryInTree(const QCString &path);
77  bool visited;
78  void setDiskName(const QCString &name) { m_diskName = name; }
79  void sort();
80 
81  private:
82  friend void computeDirDependencies();
83 
84  void writeDetailedDescription(OutputList &ol,const QCString &title);
85  void writeBriefDescription(OutputList &ol);
86  void writeDirectoryGraph(OutputList &ol);
87  void writeSubDirList(OutputList &ol);
88  void writeFileList(OutputList &ol);
89  void startMemberDeclarations(OutputList &ol);
90  void endMemberDeclarations(OutputList &ol);
91 
92  void setLevel();
93  static DirDef *createNewDir(const char *path);
94  static bool matchPath(const QCString &path,QStrList &l);
95  void addUsesDependency(DirDef *usedDir,FileDef *srcFd,
96  FileDef *dstFd,bool inherited);
97  void computeDependencies();
98 
99  DirList m_subdirs;
100  QCString m_dispName;
101  QCString m_shortName;
102  QCString m_diskName;
103  FileList *m_fileList; // list of files in the group
104  int m_dirCount;
105  int m_level;
106  DirDef *m_parent;
107  QDict<UsedDir> *m_usedDirs;
108 };
109 
111 class FilePair
112 {
113  public:
114  FilePair(FileDef *src,FileDef *dst) : m_src(src), m_dst(dst) {}
115  const FileDef *source() const { return m_src; }
116  const FileDef *destination() const { return m_dst; }
117  private:
118  FileDef *m_src;
119  FileDef *m_dst;
120 };
121 
123 class FilePairDict : public SDict<FilePair>
124 {
125  public:
126  FilePairDict(int size) : SDict<FilePair>(size) {}
127  private:
128  int compareValues(const FilePair *item1,const FilePair *item2) const;
129 };
130 
132 class UsedDir
133 {
134  public:
135  UsedDir(DirDef *dir,bool inherited);
136  virtual ~UsedDir();
137  void addFileDep(FileDef *srcFd,FileDef *dstFd);
138  FilePair *findFilePair(const char *name);
139  const FilePairDict &filePairs() const { return m_filePairs; }
140  const DirDef *dir() const { return m_dir; }
141  bool inherited() const { return m_inherited; }
142  void sort();
143 
144  private:
145  DirDef *m_dir;
146  FilePairDict m_filePairs;
147  bool m_inherited;
148 };
149 
152 {
153  public:
154  DirRelation(const QCString &name,DirDef *src,UsedDir *dst)
155  : m_name(name), m_src(src), m_dst(dst) {}
156  DirDef *source() const { return m_src; }
157  UsedDir *destination() const { return m_dst; }
158  void writeDocumentation(OutputList &ol);
159  QCString getOutputFileBase() const { return m_name; }
160 
161  private:
162  QCString m_name;
163  DirDef *m_src;
164  UsedDir *m_dst;
165 };
166 
167 inline int DirList::compareValues(const DirDef *item1,const DirDef *item2) const
168 {
169  return qstricmp(item1->shortName(),item2->shortName());
170 }
171 
173 class DirSDict : public SDict<DirDef>
174 {
175  public:
176  DirSDict(int size) : SDict<DirDef>(size) {}
177  int compareValues(const DirDef *item1,const DirDef *item2) const
178  {
179  return qstricmp(item1->shortName(),item2->shortName());
180  }
181 };
182 
183 
184 void buildDirectories();
185 void generateDirDocs(OutputList &ol);
186 void computeDirDependencies();
187 void writeDirDependencyGraph(const char *file);
188 
189 #endif
Definition: qstrlist.h:57
The common base class of all entity definitions found in the sources.
Definition: definition.h:92
A model of a file symbol.
Definition: filedef.h:64
A usage relation between two directories.
Definition: dirdef.h:151
DefType definitionType() const
Definition: dirdef.h:51
A sorted dictionary of DirDef objects.
Definition: dirdef.h:173
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
A sorted dictionary of ClassDef objects.
Definition: classlist.h:56
Class representing a pair of FileDef objects.
Definition: dirdef.h:111
Usage information of a directory.
Definition: dirdef.h:132
Ordered dictionary of elements of type T.
Definition: sortdict.h:73
A list of directories.
Definition: dirdef.h:37
DefType
Definition: definition.h:71
A model of a directory symbol.
Definition: dirdef.h:44
uint count() const
Definition: qlist.h:66
QCString displayName(bool=TRUE) const
Definition: dirdef.h:56
Class representing a list of FileDef objects.
Definition: filedef.h:240
A sorted dictionary of FilePair objects.
Definition: dirdef.h:123
Class representing a list of output generators that are written to in parallel.
Definition: outputlist.h:54
int compareValues(const DirDef *item1, const DirDef *item2) const
Definition: dirdef.h:177
QCString anchor() const
Definition: dirdef.h:53
This is an alternative implementation of QCString.
Definition: qcstring.h:131
Definition: qlist.h:54