My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
classdef.h
Go to the documentation of this file.
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 CLASSDEF_H
19 #define CLASSDEF_H
20 
21 #include <qlist.h>
22 #include <qdict.h>
23 #include <qptrdict.h>
24 
25 #include "definition.h"
26 
27 struct Argument;
28 class MemberDef;
29 class MemberList;
30 class MemberDict;
31 class ClassList;
32 class ClassSDict;
33 class OutputList;
34 class FileDef;
35 class FileList;
36 class BaseClassList;
37 class NamespaceDef;
38 class MemberDef;
39 class ExampleSDict;
41 class UsesClassDict;
43 class MemberGroupSDict;
44 class QTextStream;
45 class PackageDef;
46 class GroupDef;
47 class StringDict;
48 struct IncludeInfo;
49 class ClassDefImpl;
50 class ArgumentList;
51 class FTextStream;
52 
59 class ClassDef : public Definition
60 {
61  public:
63  enum CompoundType { Class, //=Entry::CLASS_SEC,
64  Struct, //=Entry::STRUCT_SEC,
65  Union, //=Entry::UNION_SEC,
66  Interface, //=Entry::INTERFACE_SEC,
67  Protocol, //=Entry::PROTOCOL_SEC,
68  Category, //=Entry::CATEGORY_SEC,
69  Exception, //=Entry::EXCEPTION_SEC
70  Service, //=Entry::CLASS_SEC
71  Singleton, //=Entry::CLASS_SEC
72  };
73 
94  ClassDef(const char *fileName,int startLine,int startColumn,
95  const char *name,CompoundType ct,
96  const char *ref=0,const char *fName=0,
97  bool isSymbol=TRUE,bool isJavaEnum=FALSE);
99  ~ClassDef();
100 
101  //-----------------------------------------------------------------------------------
102  // --- getters
103  //-----------------------------------------------------------------------------------
104 
106  DefType definitionType() const { return TypeClass; }
107 
109  QCString getOutputFileBase() const;
110  QCString getInstanceOutputFileBase() const;
111 
113  QCString getSourceFileBase() const;
114 
116  QCString getReference() const;
117 
119  bool isReference() const;
120 
122  bool isLocal() const;
123 
126 
128  bool hasDocumentation() const;
129 
131  bool hasDetailedDescription() const;
132 
134  QCString collaborationGraphFileName() const;
135 
137  QCString inheritanceGraphFileName() const;
138 
140  QCString displayName(bool includeScope=TRUE) const;
141 
143  CompoundType compoundType() const;
144 
146  QCString compoundTypeString() const;
147 
151  BaseClassList *baseClasses() const;
152 
155  BaseClassList *subClasses() const;
156 
161 
165  Protection protection() const;
166 
169  bool isLinkableInProject() const;
170 
174  bool isLinkable() const;
175 
177  bool isVisibleInHierarchy();
178 
180  bool visibleInParentsDeclList() const;
181 
186 
190  NamespaceDef *getNamespaceDef() const;
191 
195  FileDef *getFileDef() const;
196 
200  MemberDef *getMemberByName(const QCString &) const;
201 
206  bool isBaseClass(ClassDef *bcd,bool followInstances,int level=0);
207 
211  bool isSubClass(ClassDef *bcd,int level=0);
212 
216  bool isAccessibleMember(MemberDef *md);
217 
221  QDict<ClassDef> *getTemplateInstances() const;
222 
226  ClassDef *templateMaster() const;
227 
229  bool isTemplate() const;
230 
231  IncludeInfo *includeInfo() const;
232 
234 
236 
238 
240 
241  bool isTemplateArgument() const;
242 
247  virtual Definition *findInnerCompound(const char *name);
248 
256  void getTemplateParameterLists(QList<ArgumentList> &lists) const;
257 
259  QList<ArgumentList> *actualParams=0,int *actualParamIndex=0) const;
260 
264  bool isAbstract() const;
265 
267  bool isObjectiveC() const;
268 
270  bool isCSharp() const;
271 
273  bool isFinal() const;
274 
276  bool isSealed() const;
277 
279  bool isPublished() const;
280 
282  bool isExtension() const;
283 
285  bool isForwardDeclared() const;
286 
288  ClassDef *categoryOf() const;
289 
293  QCString className() const;
294 
297 
299  const QList<MemberList> &getMemberLists() const;
300 
303 
304  QDict<int> *getTemplateBaseClassNames() const;
305 
306  ClassDef *getVariableInstance(const char *templSpec);
307 
308  bool isUsedOnly() const;
309 
310  QCString anchor() const;
311  bool isEmbeddedInOuterScope() const;
312 
313  bool isSimple() const;
314 
315  const ClassList *taggedInnerClasses() const;
316  ClassDef *tagLessReference() const;
317 
318  MemberDef *isSmartPointer() const;
319 
320  bool isJavaEnum() const;
321 
322  bool isGeneric() const;
323  bool isAnonymous() const;
324  const ClassSDict *innerClasses() const;
325  QCString title() const;
326 
327  QCString generatedFromFiles() const;
328  const FileList &usedFiles() const;
329 
330  const ArgumentList *typeConstraints() const;
331  const ExampleSDict *exampleList() const;
332  bool hasExamples() const;
333  QCString getMemberListFileName() const;
334  bool subGrouping() const;
335 
336 
337  //-----------------------------------------------------------------------------------
338  // --- setters ----
339  //-----------------------------------------------------------------------------------
340 
341  void insertBaseClass(ClassDef *,const char *name,Protection p,Specifier s,const char *t=0);
342  void insertSubClass(ClassDef *,Protection p,Specifier s,const char *t=0);
343  void setIncludeFile(FileDef *fd,const char *incName,bool local,bool force);
344  void insertMember(MemberDef *);
345  void insertUsedFile(FileDef *);
346  bool addExample(const char *anchor,const char *name, const char *file);
347  void mergeCategory(ClassDef *category);
348  void setNamespace(NamespaceDef *nd);
349  void setFileDef(FileDef *fd);
350  void setSubGrouping(bool enabled);
351  void setProtection(Protection p);
352  void setGroupDefForAllMembers(GroupDef *g,Grouping::GroupPri_t pri,const QCString &fileName,int startLine,bool hasDocs);
353  void addInnerCompound(Definition *d);
354  ClassDef *insertTemplateInstance(const QCString &fileName,int startLine,int startColumn,
355  const QCString &templSpec,bool &freshInstance);
356  void addUsedClass(ClassDef *cd,const char *accessName,Protection prot);
357  void addUsedByClass(ClassDef *cd,const char *accessName,Protection prot);
358  void setIsStatic(bool b);
360  void setClassName(const char *name);
361  void setClassSpecifier(uint64 spec);
362 
364  void setTemplateBaseClassNames(QDict<int> *templateNames);
365  void setTemplateMaster(ClassDef *tm);
367  void addMembersToTemplateInstance(ClassDef *cd,const char *templSpec);
368  void makeTemplateArgument(bool b=TRUE);
369  void setCategoryOf(ClassDef *cd);
370  void setUsedOnly(bool b);
371 
372  void addTaggedInnerClass(ClassDef *cd);
373  void setTagLessReference(ClassDef *cd);
374  void setName(const char *name);
375 
376  //-----------------------------------------------------------------------------------
377  // --- actions ----
378  //-----------------------------------------------------------------------------------
379 
382  void addListReferences();
383  void addTypeConstraints();
384  void computeAnchors();
385  void mergeMembers();
386  void sortMemberLists();
388  void writeDocumentation(OutputList &ol);
390  void writeMemberPages(OutputList &ol);
391  void writeMemberList(OutputList &ol);
392  void writeDeclaration(OutputList &ol,MemberDef *md,bool inGroup,
393  ClassDef *inheritedFrom,const char *inheritId);
394  void writeQuickMemberLinks(OutputList &ol,MemberDef *md) const;
395  void writeSummaryLinks(OutputList &ol);
398  void writeDeclarationLink(OutputList &ol,bool &found,
399  const char *header,bool localNames);
402  ClassDef *inheritedFrom,const QCString &inheritId);
403  int countMembersIncludingGrouped(MemberListType lt,ClassDef *inheritedFrom,bool additional);
404  int countInheritanceNodes();
405  void writeTagFile(FTextStream &);
406 
407  bool visited;
408 
409  protected:
410  void addUsedInterfaceClasses(MemberDef *md,const char *typeStr);
412  void showUsedFiles(OutputList &ol);
413 
414  private:
415  void writeDocumentationContents(OutputList &ol,const QCString &pageTitle);
416  void internalInsertMember(MemberDef *md,Protection prot,bool addToAllList);
417  void addMemberToList(MemberListType lt,MemberDef *md,bool isBrief);
419  void writeInheritedMemberDeclarations(OutputList &ol,MemberListType lt,int lt2,const QCString &title,ClassDef *inheritedFrom,bool invert,bool showAlways,QPtrDict<void> *visitedClasses);
420  void writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title,
421  const char *subTitle=0,bool showInline=FALSE,ClassDef *inheritedFrom=0,int lt2=-1,bool invert=FALSE,bool showAlways=FALSE,QPtrDict<void> *visitedClasses=0);
422  void writeMemberDocumentation(OutputList &ol,MemberListType lt,const QCString &title,bool showInline=FALSE);
424  void writePlainMemberDeclaration(OutputList &ol,MemberListType lt,bool inGroup,ClassDef *inheritedFrom,const char *inheritId);
425  void writeBriefDescription(OutputList &ol,bool exampleFlag);
426  void writeDetailedDescription(OutputList &ol,const QCString &pageType,bool exampleFlag,
427  const QCString &title,const QCString &anchor=QCString());
428  void writeIncludeFiles(OutputList &ol);
429  //void writeAllMembersLink(OutputList &ol);
432  void writeMemberGroups(OutputList &ol,bool showInline=FALSE);
433  void writeNestedClasses(OutputList &ol,const QCString &title);
434  void writeInlineClasses(OutputList &ol);
439  void writeAuthorSection(OutputList &ol);
440  void writeMoreLink(OutputList &ol,const QCString &anchor);
442 
445  void addClassAttributes(OutputList &ol);
446  int countMemberDeclarations(MemberListType lt,ClassDef *inheritedFrom,
447  int lt2,bool invert,bool showAlways,QPtrDict<void> *visitedClasses);
449  ClassDef *inheritedFrom,bool invert,bool showAlways,
450  QPtrDict<void> *visitedClasses);
452  QCString &title,QCString &subtitle);
453  QCString includeStatement() const;
454  void addTypeConstraint(const QCString &typeConstraint,const QCString &type);
455 
457 };
458 
459 //------------------------------------------------------------------------
460 
464 {
466  {
467  accessors = new QDict<void>(17);
468  containment = TRUE;
469  }
471  {
472  delete accessors;
473  }
474  void addAccessor(const char *s)
475  {
476  if (accessors->find(s)==0)
477  {
478  accessors->insert(s,(void *)666);
479  }
480  }
483 
487  QDict<void> *accessors;
488 
490  QCString templSpecifiers;
491 
493 };
494 
497 class UsesClassDict : public QDict<UsesClassDef>
498 {
499  public:
500  UsesClassDict(int size) : QDict<UsesClassDef>(size) {}
502 };
503 
506 class UsesClassDictIterator : public QDictIterator<UsesClassDef>
507 {
508  public:
509  UsesClassDictIterator(const QDict<UsesClassDef> &d)
510  : QDictIterator<UsesClassDef>(d) {}
512 };
513 
514 //------------------------------------------------------------------------
515 
519 {
520  BaseClassDef(ClassDef *cd,const char *n,Protection p,
521  Specifier v,const char *t) :
522  classDef(cd), usedName(n), prot(p), virt(v), templSpecifiers(t) {}
523 
526 
530  QCString usedName;
531 
536 
541 
543  QCString templSpecifiers;
544 };
545 
550 class BaseClassList : public QList<BaseClassDef>
551 {
552  public:
554  int compareValues(const BaseClassDef *item1,const BaseClassDef *item2) const
555  {
556  const ClassDef *c1=item1->classDef;
557  const ClassDef *c2=item2->classDef;
558  if (c1==0 || c2==0)
559  return FALSE;
560  else
561  return qstricmp(c1->name(),c2->name());
562  }
563 };
564 
567 class BaseClassListIterator : public QListIterator<BaseClassDef>
568 {
569  public:
571  QListIterator<BaseClassDef>(bcl) {}
572 };
573 
574 //------------------------------------------------------------------------
575 
576 
580 {
582  {
583  accessors = new QDict<void>(17);
584  }
586  {
587  delete accessors;
588  }
589  void addAccessor(const char *s)
590  {
591  if (accessors->find(s)==0)
592  {
593  accessors->insert(s,(void *)666);
594  }
595  }
598 
602  QDict<void> *accessors;
603 };
604 
607 class ConstraintClassDict : public QDict<ConstraintClassDef>
608 {
609  public:
610  ConstraintClassDict(int size) : QDict<ConstraintClassDef>(size) {}
612 };
613 
616 class ConstraintClassDictIterator : public QDictIterator<ConstraintClassDef>
617 {
618  public:
619  ConstraintClassDictIterator(const QDict<ConstraintClassDef> &d)
620  : QDictIterator<ConstraintClassDef>(d) {}
622 };
623 
624 //------------------------------------------------------------------------
625 
626 #endif