summaryrefslogtreecommitdiffstats
path: root/src/memberdef.h
blob: 2cce60d2d9f5207c8c644a246cc57d89f6d054c1 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/******************************************************************************
 *
 * $Id$
 *
 * Copyright (C) 1997-2000 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 MEMBERDEF_H
#define MEMBERDEF_H

#include "qtbc.h"
#include <qlist.h>
#include <qdict.h>

#include "entry.h"
#include "definition.h"

class ClassDef;
class NamespaceDef;
class GroupDef;
class FileDef;
class MemberList;
class MemberGroup;
class ExampleList;
class ExampleDict;
class OutputList;
class GroupDef;

class MemberDef : public Definition
{
  public:
    
    enum MemberType { 
      Define,
      Function, 
      Variable, 
      Typedef, 
      Enumeration, 
      EnumValue,
      Prototype,
      Signal,
      Slot,
      Friend
    };

    enum
    {
      maxInitLines = 30 // maximum number of lines shown for member
                        // initialization 
    };
    
    MemberDef(const char *type,const char *name,const char *args,
              const char *excp,Protection prot,Specifier virt,bool stat,
              bool related,MemberType t,const ArgumentList *tal,
              const ArgumentList *al);
   ~MemberDef(); 
    
    void writeLink(OutputList &ol,
                   ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
                   MemberGroup *mg);
    void writeDeclaration(OutputList &ol,
                   ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
                   int prevGroupId,bool inGroup); 
    void writeDocumentation(MemberList *ml,OutputList &ol,
                            const char *scopeName/*,MemberType m*/);
    void warnIfUndocumented();
    
    QCString getOutputFileBase() const;
    const char *declaration() const      { return decl; }
    const char *definition() const       { return def; }
    const char *typeString() const       { return type; }
    const char *argsString() const       { return args; }
    const char *excpString() const       { return exception; }     
    const char *anchor() const           { return anc; }
    const QCString &initializer() const  { return init; }
    int initializerLines() const         { return initLines; }
    ClassDef *memberClass()              { return classDef; }
    Protection protection() const        { return prot; }
    Specifier virtualness() const        { return virt; }
    MemberType memberType() const        { return mtype; }
    GroupDef *groupDef() const           { return group; }
    FileDef *getFileDef()                { return fileDef; }
    FileDef *getFileDec()                { return fileDec; }
    bool isRelated() const               { return related; }
    bool isStatic() const                { return stat; }
    bool isInline() const                { return inLine; }
    void setMemberType(MemberType t)     { mtype=t; }
    void setDefinition(const char *d)    { def=d; }
    void setDefFile(const char *f)       { defFile=f; }
    void setDefLine(int l)               { defLine=l; }
    void setFileDef(FileDef *fd)         { fileDef=fd; }
    void setFileDec(FileDef *fd)         { fileDec=fd; }
    void setAnchor(const char *a)        { anc=a; }
    void setProtection(Protection p)     { prot=p; }
    void setInline(bool in)              { inLine=in; }
    void setInitializer(const char *i)   { init=i; 
                                           init=init.stripWhiteSpace();
                                           initLines=init.contains('\n');
                                         }
    void setMemberClass(ClassDef *cd)    { classDef=cd; }
    void makeRelated()                   { related=TRUE; } 
    void setGroupDef(GroupDef *gd)       { group=gd; }
    bool hasDocumentation()  // overrides hasDocumentation in definition.h
      { return Definition::hasDocumentation(); }

    bool isLinkableInProject();
    bool isLinkable();
    
    bool detailsAreVisible() const;
    // relation to other members
    void setReimplements(MemberDef *md) { redefines=md; }
    void insertReimplementedBy(MemberDef *md);
    MemberDef  *reimplements()    { return redefines; }
    MemberList *reimplementedBy() { return redefinedBy; }
    
    // enumeration specific members
    void insertEnumField(MemberDef *md);
    void setEnumScope(MemberDef *md) { enumScope=md; }
    MemberDef *getEnumScope() const { return enumScope; }
    void setEnumDecl(OutputList &ed);
    void setEnumUsed() { eUsed=TRUE; }
    bool enumUsed() const        { return eUsed; }
    OutputList *enumDecl() const { return enumDeclList; }
    MemberList *enumFieldList()  { return enumFields; }
    void setDocumentedEnumValues(bool value) { docEnumValues=value; }
    bool hasDocumentedEnumValues() const { return docEnumValues; }
    
    // example related members
    bool addExample(const char *anchor,const char *name,const char *file);
    //void writeExample(OutputList &ol);
    bool hasExamples();
    ExampleList *getExampleList() const { return exampleList; }

    // prototype related members
    const char *getDefFile()        { return defFile; }
    int getDefLine()                { return defLine; }
    void setDecFile(const char *f)  { declFile=f; }
    void setDecLine(int l)          { defLine=l; }
    
    // convenience members
    bool isSignal() const    { return mtype==Signal;      }
    bool isSlot() const      { return mtype==Slot;        }
    bool isVariable() const  { return mtype==Variable;    }
    bool isEnumerate() const { return mtype==Enumeration; }
    bool isEnumValue() const { return mtype==EnumValue;   }
    bool isTypedef() const   { return mtype==Typedef;     }
    bool isFunction() const  { return mtype==Function;    } 
    bool isDefine() const    { return mtype==Define;      }
    bool isFriend() const    { return mtype==Friend;      }
    
    // prototype related members
    void setPrototype(bool p) { proto=p; }
    bool isPrototype() const { return proto; }
    
    // tag file related members
    //void setReference(const char *r) { external=r; } 
    //bool isReference() { return !external.isEmpty(); }

    // argument related members
    ArgumentList *argumentList() const { return argList; }
    void setArgumentList(ArgumentList *al) 
    { if (argList) delete argList;
      argList = al;
    }
    ArgumentList *templateArguments() const { return tArgList; }
    void setScopeDefTemplateArguments(ArgumentList *t);
    ArgumentList *scopeDefTemplateArguments() const { return scopeTAL; }
    void setMemberDefTemplateArguments(ArgumentList *t);
    ArgumentList *memberDefTemplateArguments() const { return membTAL; }
    //QCString getScopeTemplateNameString();
    
    // namespace related members
    NamespaceDef *getNamespace() { return nspace; }
    void setNamespace(NamespaceDef *nd) { nspace=nd; }

    // grouping related members
    void setGroupId(int groupId);
    int groupId() const          { return grpId; }
    QCString groupHeader() const { return grpHeader; }
    MemberGroup *getMemberGroup() const { return memberGroup; }
    
    void setFromAnnonymousScope(bool b) { annScope=b; }    
    void setFromAnnonymousMember(MemberDef *m) { annMemb=m; }    
    bool fromAnnonymousScope() { return annScope; }
    bool annonymousDeclShown() { return annUsed; }
    void setIndentDepth( int i) { indDepth=i; }
    int  indentDepth() { return indDepth; }
    
  private:
    ClassDef   *classDef;     // member of or related to 
    FileDef    *fileDef;      // member of file definition 
    FileDef    *fileDec;      // member of file declaration
    MemberDef  *redefines;    // the member that is redefined by this one
    MemberDef  *enumScope;    // the enclosing scope, if this is an enum field
    MemberList *redefinedBy;  // the list of members that redefine this one
    MemberDef  *memDef;       // member definition for this declaration
    MemberDef  *memDec;       // member declaration for this definition
    ExampleList *exampleList; // a list of all examples using this member
    ExampleDict *exampleDict; // a dictionary of all examples for quick access
    MemberList *enumFields;   // enumeration fields
    OutputList *enumDeclList; // stored piece of documentation for enumeration.
    NamespaceDef *nspace;     // the namespace this member is in.
    QCString type;            // return type
    QCString args;            // function arguments/variable array specifiers
    QCString exception;       // exceptions that can be thrown
    QCString init;            // initializer
    int initLines;            // number of lines in the initializer
    QCString decl;            // member declaration in class
    QCString declFile;        // file where the declaration was found
    int      declLine;        // line where the declaration was found
    QCString def;             // member definition in code (fully qualified name)
    QCString defFile;         // file where the definition was found
    int      defLine;         // line where the definition was found
    QCString anc;             // HTML anchor name
    Specifier virt;           // normal/virtual/pure virtual
    Protection prot;          // protection type [Public/Protected/Private]
    bool    related;          // is this a member that is only related to a class
    bool    stat;             // is it a static function?
    bool    inLine;           // is it an inline function?
    MemberType mtype;         // returns the kind of member
    bool eUsed;               // is the enumerate already placed in a list
    bool proto;               // is it a prototype;
    bool docEnumValues;       // is an enum with documented enum values.
    bool annScope;
    bool annUsed;
    bool annShown;
    int  indDepth;
    MemberDef *annMemb;
    ArgumentList *argList;    // argument list of this member
    ArgumentList *tArgList;   // template argument list of function template
    ArgumentList *scopeTAL;   // template argument list of class template
    ArgumentList *membTAL;    // template argument list of class template
    int grpId;                // group id
    QCString grpHeader;       // group header
    MemberGroup *memberGroup; // group's member definition
    GroupDef *group;          // group in which this member is in

    // disable copying of member defs
    MemberDef(const MemberDef &);
    MemberDef &operator=(const MemberDef &);
};

#endif