summaryrefslogtreecommitdiffstats
path: root/src/classdef.h
blob: 8fe0f21bae54999a3aaef0c870a77dcf7247c584 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/******************************************************************************
 *
 * $Id$
 *
 * Copyright (C) 1997-1999 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * All output generated with Doxygen is not covered by this license.
 *
 */

#ifndef CLASSDEF_H
#define CLASSDEF_H

#include <qstring.h>
#include <qfileinf.h>
#include <qlist.h>
#include <qdict.h>
#include <qtstream.h>
#include <qstrlist.h>

#include "membername.h"
#include "memberlist.h"
#include "memberdef.h"
#include "example.h"
#include "entry.h"
#include "definition.h"

typedef QDict<MemberDef> MemberDict;
class ClassList;
class OutputList;
class FileDef;
class BaseClassList;
class MemberInfoList;
class MemberInfoDict;
class NamespaceDef;

class ClassDef : public Definition
{
  public:
    
    enum CompoundType { Class=Entry::CLASS_SEC, 
                        Struct=Entry::STRUCT_SEC, 
                        Union=Entry::UNION_SEC 
                      };
    
    ClassDef(const char *name,int ct,const char *ref=0,const char *fName=0);
   ~ClassDef();
    QString classFile() const { return fileName; }
    int compoundType() const { return compType; } 
    const char *memberListFileName() const { return memListFileName; }
    void insertBaseClass(ClassDef *,Protection p,Specifier s,const char *t=0);
    BaseClassList *baseClasses() { return inherits; }
    void insertSuperClass(ClassDef *,Protection p,Specifier s,const char *t=0);
    BaseClassList *superClasses() { return inheritedBy; }
    void setIncludeFile(FileDef *fd) { incFile=fd; }
    FileDef *includeFile() const { return incFile; }
    void setIncludeName(const char *n_) { incName=n_; }
    MemberNameInfoList *memberNameInfoList() { return allMemberNameInfoList; }
    MemberNameInfoDict *memberNameInfoDict() { return allMemberNameInfoDict; }
    bool isReference() { return !reference.isNull(); }
    const char *getReference() const { return reference; }
    void insertMember(const MemberDef *);
    void insertUsedFile(const char *);
    void computeAnchors();
    void setAnchor(MemberDef *);
    void dumpMembers();
    void writeDocumentation(OutputList &ol);
    void writeMemberList(OutputList &ol);
    void writeIncludeFile(OutputList &ol);
    bool addExample(const char *anchor,const char *name, const char *file);
    bool hasExamples();
    void writeExample(OutputList &ol);
    void setProtection(Protection p) { prot=p; }
    Protection protection() const { return prot; }
    bool isVisible() 
      { return !name().isEmpty() && name().at(0)!='@' &&
               (prot!=Private || extractPrivateFlag) &&
               hasDocumentation();
      }
    bool hasNonReferenceSuperClass();
    bool isVisibleExt() 
      { return (allExtFlag || hasNonReferenceSuperClass()) &&
               !name().isEmpty() && name().at(0)!='@' &&
               (prot!=Private || extractPrivateFlag) &&
               (hasDocumentation() || !hideClassFlag || !reference.isNull());
      }
    
    // template argument functions
    ArgumentList *templateArguments() const { return tempArgs; }
    void setTemplateArguments(ArgumentList *al);
    QString getTemplateNameString();
    void setNamespace(NamespaceDef *nd) { nspace = nd; }
    NamespaceDef *getNamespace() { return nspace; }
    
    bool visited;
   
  private: 
    //QString name;                       // name of the class
    QString fileName;                   // HTML containing the class docs
    //QString doc;                        // general class documentation
    FileDef *incFile;                   // header file to refer to
    QString incName;                    // alternative include file name
    //QString brief;                      // brief class discription
    QString memListFileName;            
    BaseClassList *inherits;
    BaseClassList *inheritedBy;
    NamespaceDef  *nspace;              // the namespace this class is in
    MemberList pubMembers;
    MemberList proMembers;
    MemberList priMembers;
    MemberList pubStaticMembers;
    MemberList proStaticMembers;
    MemberList priStaticMembers;
    MemberList pubSlots;
    MemberList proSlots;
    MemberList priSlots;
    MemberList related;
    MemberList signals;
    MemberList friends;
    MemberNameInfoList *allMemberNameInfoList;
    MemberNameInfoDict *allMemberNameInfoDict;
    ArgumentList     *tempArgs;
    QStrList          files;
    QString           reference;
    ExampleList      *exampleList;
    ExampleDict      *exampleDict;
    int               compType;
    Protection        prot;
};


struct BaseClassDef
{
  BaseClassDef(ClassDef *cd,Protection p,Specifier v,const char *t) : 
        classDef(cd), prot(p), virt(v), templSpecifiers(t) {}
  ClassDef *classDef;
  Protection prot;
  Specifier  virt;
  QString templSpecifiers;
};

class BaseClassList : public QList<BaseClassDef>
{
  public:
    int compareItems(GCI item1,GCI item2)
    {
      ClassDef *c1=((BaseClassDef *)item1)->classDef;
      ClassDef *c2=((BaseClassDef *)item2)->classDef;
      if (c1==0 || c2==0) 
        return FALSE;
      else
        return strcmp(c1->name(),c2->name());
    }
};

class BaseClassListIterator : public QListIterator<BaseClassDef>
{
  public:
    BaseClassListIterator(const BaseClassList &bcl) : 
      QListIterator<BaseClassDef>(bcl) {}
};

#endif