Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/classdef.h

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: classdef.h,v 1.39 2001/03/19 19:27:39 root Exp $
4 *
5 * Copyright (C) 1997-2011 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 CLASSDEF_H
19#define CLASSDEF_H
20
21#include "qtbc.h"
22#include <qlist.h>
23#include <qdict.h>
24#include <qstrlist.h>
25
26#include "util.h"
27#include "memberlist.h"
28#include "definition.h"
29#include "sortdict.h"
30
31class MemberDict;
32class ClassList;
33class ClassSDict;
34class OutputList;
35class FileDef;
36class BaseClassList;
37class NamespaceDef;
38class MemberDef;
39class ExampleSDict;
40class MemberNameInfoSDict;
41class UsesClassDict;
42class MemberGroupSDict;
43class QTextStream;
44class PackageDef;
45class GroupDef;
46class StringDict;
47struct IncludeInfo;
48class ClassDefImpl;
49
50/*! \brief This class contains all information about a compound.
51 *
52 * A compound can be a class, struct, union, interface, or exception.
53 * \note This class should be renamed to CompoundDef
54 */
55class ClassDef : public Definition
56{
57 public:
58 /*! The various compound types */
59 enum CompoundType { Class, //=Entry::CLASS_SEC,
60 Struct, //=Entry::STRUCT_SEC,
61 Union, //=Entry::UNION_SEC,
62 Interface, //=Entry::INTERFACE_SEC,
63 Protocol, //=Entry::PROTOCOL_SEC,
64 Category, //=Entry::CATEGORY_SEC,
65 Exception //=Entry::EXCEPTION_SEC
66 };
67
68 /*! Creates a new compound definition.
69 * \param fileName full path and file name in which this compound was
70 * found.
71 * \param startLine line number where the definition of this compound
72 * starts.
73 * \param name the name of this compound (including scope)
74 * \param ct the kind of Compound
75 * \param ref the tag file from which this compound is extracted
76 * or 0 if the compound doesn't come from a tag file
77 * \param fName the file name as found in the tag file.
78 * This overwrites the file that doxygen normally
79 * generates based on the compound type & name.
80 * \param isSymbol If TRUE this class name is added as a publicly
81 * visible (and referencable) symbol.
82 */
83 ClassDef(const char *fileName,int startLine,
84 const char *name,CompoundType ct,
85 const char *ref=0,const char *fName=0,
86 bool isSymbol=TRUE);
87 /*! Destroys a compound definition. */
88 ~ClassDef();
89
90 //-----------------------------------------------------------------------------------
91 // --- getters
92 //-----------------------------------------------------------------------------------
93
94 /*! Used for RTTI, this is a class */
95 DefType definitionType() const { return TypeClass; }
96
97 /*! Returns the unique base name (without extension) of the class's file on disk */
98 QCString getOutputFileBase() const;
99 QCString getXmlOutputFileBase() const;
100 QCString getInstanceOutputFileBase() const;
101 QCString getFileBase() const;
102
103 /*! Returns the base name for the source code file */
104 QCString getSourceFileBase() const;
105
106 /*! If this class originated from a tagfile, this will return the tag file reference */
107 QCString getReference() const;
108
109 /*! Returns TRUE if this class is imported via a tag file */
110 bool isReference() const;
111
112 /*! Returns TRUE if this is a local class definition, see EXTRACT_LOCAL_CLASSES */
113 bool isLocal() const;
114
115 /*! returns the classes nested into this class */
116 ClassSDict *getInnerClasses();
117
118 /*! returns TRUE if this class has documentation */
119 bool hasDocumentation() const;
120
121 /*! Returns the name as it is appears in the documentation */
122 QCString displayName() const;
123
124 /*! Returns the type of compound this is, i.e. class/struct/union/.. */
125 CompoundType compoundType() const;
126
127 /*! Returns the type of compound as a string */
128 QCString compoundTypeString() const;
129
130 /*! Returns the list of base classes from which this class directly
131 * inherits.
132 */
133 BaseClassList *baseClasses() const;
134
135 /*! Returns the list of sub classes that directly derive from this class
136 */
137 BaseClassList *subClasses() const;
138
139 /*! Returns a dictionary of all members. This includes any inherited
140 * members. Members are sorted alphabetically.
141 */
142 MemberNameInfoSDict *memberNameInfoSDict() const;
143
144 /*! Return the protection level (Public,Protected,Private) in which
145 * this compound was found.
146 */
147 Protection protection() const;
148
149 /*! returns TRUE iff a link is possible to this item within this project.
150 */
151 bool isLinkableInProject() const;
152
153 /*! return TRUE iff a link to this class is possible (either within
154 * this project, or as a cross-reference to another project).
155 */
156 bool isLinkable() const;
157
158 /*! the class is visible in a class diagram, or class hierarchy */
159 bool isVisibleInHierarchy();
160
161 /*! Returns the template arguments of this class
162 * Will return 0 if not applicable.
163 */
164 ArgumentList *templateArguments() const;
165
166 /*! Returns the namespace this compound is in, or 0 if it has a global
167 * scope.
168 */
169 NamespaceDef *getNamespaceDef() const;
170
171 /*! Returns the file in which this compound's definition can be found.
172 * Should not return 0 (but it might be a good idea to check anyway).
173 */
174 FileDef *getFileDef() const;
175
176 /*! Returns the Java package this class is in or 0 if not applicable.
177 */
178
179 MemberDef *getMemberByName(const QCString &) const;
180
181 /*! Returns TRUE iff \a bcd is a direct or indirect base class of this
182 * class. This function will recusively traverse all branches of the
183 * inheritance tree.
184 */
185 bool isBaseClass(ClassDef *bcd,bool followInstances,int level=0);
186
187 /*! returns TRUE iff \a md is a member of this class or of the
188 * the public/protected members of a base class
189 */
190 bool isAccessibleMember(MemberDef *md);
191
192 /*! Returns a sorted dictionary with all template instances found for
193 * this template class. Returns 0 if not a template or no instances.
194 */
195 QDict<ClassDef> *getTemplateInstances() const;
196
197 /*! Returns the template master of which this class is an instance.
198 * Returns 0 if not applicable.
199 */
200 ClassDef *templateMaster() const;
201
202 /*! Returns TRUE if this class is a template */
203 bool isTemplate() const;
204
205 IncludeInfo *includeInfo() const;
206
207 UsesClassDict *usedImplementationClasses() const;
208
209 UsesClassDict *usedByImplementationClasses() const;
210
211 UsesClassDict *usedInterfaceClasses() const;
212
213 bool isTemplateArgument() const;
214
215 /*! Returns the definition of a nested compound if
216 * available, or 0 otherwise.
217 * @param name The name of the nested compound
218 */
219 virtual Definition *findInnerCompound(const char *name);
220
221 /*! Returns the template parameter lists that form the template
222 * declaration of this class.
223 *
224 * Example: <code>template<class T> class TC {};</code>
225 * will return a list with one ArgumentList containing one argument
226 * with type="class" and name="T".
227 */
228 void getTemplateParameterLists(QList<ArgumentList> &lists) const;
229
230 QCString qualifiedNameWithTemplateParameters(
231 QList<ArgumentList> *actualParams=0) const;
232
233 /*! Returns TRUE if there is at least one pure virtual member in this
234 * class.
235 */
236 bool isAbstract() const;
237
238 /*! Returns TRUE if this class is implemented in Objective-C */
239 bool isObjectiveC() const;
240
241 /*! Returns TRUE if this class is implemented in C# */
242 bool isCSharp() const;
243
244 /*! Returns the class of which this is a category (Objective-C only) */
245 ClassDef *categoryOf() const;
246
247 /*! Returns the name of the class including outer classes, but not
248 * including namespaces.
249 */
250 QCString className() const;
251
252 /*! Returns the members in the list identified by \a lt */
253 MemberList *getMemberList(MemberList::ListType lt);
254
255 /*! Returns the list containing the list of members sorted per type */
256 const QList<MemberList> &getMemberLists() const;
257
258 /*! Returns the member groups defined for this class */
259 MemberGroupSDict *getMemberGroupSDict() const;
260
261 QDict<int> *getTemplateBaseClassNames() const;
262
263 ClassDef *getVariableInstance(const char *templSpec);
264
265 bool isUsedOnly() const;
266
267 QCString anchor() const;
268 bool isEmbeddedInGroupDocs() const;
269
270 //-----------------------------------------------------------------------------------
271 // --- setters ----
272 //-----------------------------------------------------------------------------------
273
274 void insertBaseClass(ClassDef *,const char *name,Protection p,Specifier s,const char *t=0);
275 void insertSubClass(ClassDef *,Protection p,Specifier s,const char *t=0);
276 void setIncludeFile(FileDef *fd,const char *incName,bool local,bool force);
277 void insertMember(MemberDef *);
278 void insertUsedFile(const char *);
279 bool addExample(const char *anchor,const char *name, const char *file);
280 void mergeCategory(ClassDef *category);
281 void setNamespace(NamespaceDef *nd);
282 void setFileDef(FileDef *fd);
283 void setSubGrouping(bool enabled);
284 void setProtection(Protection p);
285 void setGroupDefForAllMembers(GroupDef *g,Grouping::GroupPri_t pri,const QCString &fileName,int startLine,bool hasDocs);
286 void addInnerCompound(Definition *d);
287 ClassDef *insertTemplateInstance(const QCString &fileName,int startLine,
288 const QCString &templSpec,bool &freshInstance);
289 void addUsedClass(ClassDef *cd,const char *accessName);
290 void addUsedByClass(ClassDef *cd,const char *accessName);
291 void setIsStatic(bool b);
292 void setLanguage(SrcLangExt lang);
293 void setCompoundType(CompoundType t);
294 void setClassName(const char *name);
295
296 void setTemplateArguments(ArgumentList *al);
297 void setTemplateBaseClassNames(QDict<int> *templateNames);
298 void setTemplateMaster(ClassDef *tm);
299 void setTypeConstraints(ArgumentList *al);
300 void addMembersToTemplateInstance(ClassDef *cd,const char *templSpec);
301 void makeTemplateArgument(bool b=TRUE);
302 void setCategoryOf(ClassDef *cd);
303 void setUsedOnly(bool b);
304
305 //-----------------------------------------------------------------------------------
306 // --- actions ----
307 //-----------------------------------------------------------------------------------
308
309 void findSectionsInDocumentation();
310 void addMembersToMemberGroup();
311 void addListReferences();
312 void computeAnchors();
313 void mergeMembers();
314 void sortMemberLists();
315 void distributeMemberGroupDocumentation();
316 void writeDocumentation(OutputList &ol);
317 void writeDocumentationForInnerClasses(OutputList &ol);
318 void writeMemberPages(OutputList &ol);
319 void writeMemberList(OutputList &ol);
320 void writeDeclaration(OutputList &ol,MemberDef *md,bool inGroup);
321 void writeQuickMemberLinks(OutputList &ol,MemberDef *md) const;
322 void writeSummaryLinks(OutputList &ol);
323 void reclassifyMember(MemberDef *md,MemberDef::MemberType t);
324 void writeInlineDocumentation(OutputList &ol);
325 void writeDeclarationLink(OutputList &ol,bool &found,
326 const char *header,bool localNames);
327
328 bool visited;
329
330 protected:
331 void addUsedInterfaceClasses(MemberDef *md,const char *typeStr);
332 bool hasExamples();
333 bool hasNonReferenceSuperClass();
334 void showUsedFiles(OutputList &ol);
335
336 private:
337 void writeTagFileMarker(OutputList &ol);
338 void writeDocumentationContents(OutputList &ol,const QCString &pageTitle);
339 void internalInsertMember(MemberDef *md,Protection prot,bool addToAllList);
340 QCString getMemberListFileName() const;
341 void addMemberToList(MemberList::ListType lt,MemberDef *md,bool isBrief);
342 MemberList *createMemberList(MemberList::ListType lt);
343 void writeMemberDeclarations(OutputList &ol,MemberList::ListType lt,const QCString &title,
344 const char *subTitle=0,bool showInline=FALSE);
345 void writeMemberDocumentation(OutputList &ol,MemberList::ListType lt,const QCString &title,bool showInline=FALSE);
346 void writePlainMemberDeclaration(OutputList &ol,MemberList::ListType lt,bool inGroup);
347 void writeBriefDescription(OutputList &ol,bool exampleFlag);
348 void writeDetailedDescription(OutputList &ol,const QCString &pageType,bool exampleFlag,
349 const QCString &title,const QCString &anchor=QCString());
350 void writeIncludeFiles(OutputList &ol);
351 void writeAllMembersLink(OutputList &ol);
352 void writeInheritanceGraph(OutputList &ol);
353 void writeCollaborationGraph(OutputList &ol);
354 void writeMemberGroups(OutputList &ol,bool showInline=FALSE);
355 void writeNestedClasses(OutputList &ol,const QCString &title);
356 void startMemberDeclarations(OutputList &ol);
357 void endMemberDeclarations(OutputList &ol);
358 void startMemberDocumentation(OutputList &ol);
359 void endMemberDocumentation(OutputList &ol);
360 void writeAuthorSection(OutputList &ol);
361 void writeMoreLink(OutputList &ol,const QCString &anchor);
362 void writeDetailedDocumentationBody(OutputList &ol);
363
364 ClassDefImpl *m_impl;
365
366};
367
368/*! \brief Class that contains information about a usage relation.
369 */
370struct UsesClassDef
371{
372 UsesClassDef(ClassDef *cd) : classDef(cd)
373 {
374 accessors = new QDict<void>(17);
375 containment = TRUE;
376 }
377 ~UsesClassDef()
378 {
379 delete accessors;
380 }
381 void addAccessor(const char *s)
382 {
383 if (accessors->find(s)==0)
384 {
385 accessors->insert(s,(void *)666);
386 }
387 }
388 /*! Class definition that this relation uses. */
389 ClassDef *classDef;
390
391 /*! Dictionary of member variable names that form the edge labels of the
392 * usage relation.
393 */
394 QDict<void> *accessors;
395
396 /*! Template arguments used for the base class */
397 QCString templSpecifiers;
398
399 bool containment;
400};
401
402/*! \brief Dictionary of usage relations.
403 */
404class UsesClassDict : public QDict<UsesClassDef>
405{
406 public:
407 UsesClassDict(int size) : QDict<UsesClassDef>(size) {}
408 ~UsesClassDict() {}
409};
410
411/*! \brief Iterator class to iterate over a dictionary of usage relations.
412 */
413class UsesClassDictIterator : public QDictIterator<UsesClassDef>
414{
415 public:
416 UsesClassDictIterator(const QDict<UsesClassDef> &d)
417 : QDictIterator<UsesClassDef>(d) {}
418 ~UsesClassDictIterator() {}
419};
420
421/*! \brief Class that contains information about an inheritance relation.
422 */
423struct BaseClassDef
424{
425 BaseClassDef(ClassDef *cd,const char *n,Protection p,
426 Specifier v,const char *t) :
427 classDef(cd), usedName(n), prot(p), virt(v), templSpecifiers(t) {}
428
429 /*! Class definition that this relation inherits from. */
430 ClassDef *classDef;
431
432 /*! name used in the inheritance list
433 * (may be a typedef name instead of the class name)
434 */
435 QCString usedName;
436
437 /*! Protection level of the inheritance relation:
438 * Public, Protected, or Private
439 */
440 Protection prot;
441
442 /*! Virtualness of the inheritance relation:
443 * Normal, or Virtual
444 */
445 Specifier virt;
446
447 /*! Template arguments used for the base class */
448 QCString templSpecifiers;
449};
450
451/*! \brief list of base classes
452 *
453 * The classes are alphabetically sorted on name if inSort() is used.
454 */
455class BaseClassList : public QList<BaseClassDef>
456{
457 public:
458 ~BaseClassList() {}
459 int compareItems(GCI item1,GCI item2)
460 {
461 ClassDef *c1=((BaseClassDef *)item1)->classDef;
462 ClassDef *c2=((BaseClassDef *)item2)->classDef;
463 if (c1==0 || c2==0)
464 return FALSE;
465 else
466 return stricmp(c1->name(),c2->name());
467 }
468};
469
470/*! \brief Iterator for a list of base classes
471 */
472class BaseClassListIterator : public QListIterator<BaseClassDef>
473{
474 public:
475 BaseClassListIterator(const BaseClassList &bcl) :
476 QListIterator<BaseClassDef>(bcl) {}
477};
478
479#endif
480

Archive Download this file

Revision: 1322