32591024f68e509e2fdb5936ed48dd261045b607
[platform/upstream/doxygen.git] / src / memberdef.h
1 /******************************************************************************
2  *
3  * 
4  *
5  * Copyright (C) 1997-2014 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 MEMBERDEF_H
19 #define MEMBERDEF_H
20
21 #include <qlist.h>
22 #include <sys/types.h>
23
24 #include "types.h"
25 #include "definition.h"
26
27 class ClassDef;
28 class NamespaceDef;
29 class GroupDef;
30 class FileDef;
31 class MemberList;
32 class MemberGroup;
33 class ExampleSDict;
34 class OutputList;
35 class GroupDef;
36 class QTextStream;
37 class ArgumentList;
38 class MemberDefImpl;
39 class QStrList;
40 struct TagInfo;
41
42 /** A model of a class/file/namespace member symbol. */
43 class MemberDef : public Definition
44 {
45   public:
46     
47     MemberDef(const char *defFileName,int defLine,int defColumn,
48               const char *type,const char *name,const char *args,
49               const char *excp,Protection prot,Specifier virt,bool stat,
50               Relationship related,MemberType t,const ArgumentList *tal,
51               const ArgumentList *al);
52    ~MemberDef(); 
53     DefType definitionType() const        { return TypeMember; }
54     // move this member into a different scope
55     MemberDef *deepCopy() const;
56     void moveTo(Definition *);
57     
58     //-----------------------------------------------------------------------------------
59     // ----  getters -----
60     //-----------------------------------------------------------------------------------
61
62     // link id
63     QCString getOutputFileBase() const;
64     QCString getReference() const;
65     QCString anchor() const;
66
67     const char *declaration() const;
68     const char *definition() const;
69     const char *typeString() const;
70     const char *argsString() const;
71     const char *excpString() const;
72     const char *bitfieldString() const;
73     const char *extraTypeChars() const;
74     const QCString &initializer() const;
75     int initializerLines() const;
76     uint64 getMemberSpecifiers() const;
77     MemberList *getSectionList(Definition *d) const;
78     QCString    displayDefinition() const;
79
80     // scope query members
81     ClassDef *getClassDef() const;
82     FileDef  *getFileDef() const;
83     NamespaceDef* getNamespaceDef() const;
84     ClassDef *accessorClass() const;
85
86     // grabbing the property read/write accessor names
87     const char *getReadAccessor() const;
88     const char *getWriteAccessor() const;
89     
90     // querying the grouping definition
91     GroupDef *getGroupDef() const;
92     Grouping::GroupPri_t getGroupPri() const;
93     const char *getGroupFileName() const;
94     int getGroupStartLine() const;
95     bool getGroupHasDocs() const;
96     QCString qualifiedName() const;
97     QCString objCMethodName(bool localLink,bool showStatic) const; 
98
99     // direct kind info 
100     Protection protection() const;
101     Specifier virtualness(int count=0) const;
102     MemberType memberType() const;
103     QCString   memberTypeName() const;
104
105     // getter methods
106     bool isSignal() const;
107     bool isSlot() const;
108     bool isVariable() const;
109     bool isEnumerate() const;
110     bool isEnumValue() const;
111     bool isTypedef() const;
112     bool isFunction() const;
113     bool isFunctionPtr() const;
114     bool isDefine() const;
115     bool isFriend() const;
116     bool isDCOP() const;
117     bool isProperty() const;
118     bool isEvent() const;
119     bool isRelated() const;
120     bool isForeign() const;
121     bool isStatic() const;
122     bool isInline() const;
123     bool isExplicit() const;
124     bool isMutable() const;
125     bool isGettable() const;
126     bool isSettable() const;
127     bool isReadable() const;
128     bool isWritable() const;
129     bool isAddable() const;
130     bool isRemovable() const;
131     bool isRaisable() const;
132     bool isFinal() const;
133     bool isAbstract() const;
134     bool isOverride() const;
135     bool isInitonly() const;
136     bool isOptional() const;
137     bool isRequired() const;
138     bool isNonAtomic() const;
139     bool isCopy() const;
140     bool isAssign() const;
141     bool isRetain() const;
142     bool isWeak() const;
143     bool isStrong() const;
144     bool isUnretained() const;
145     bool isNew() const;
146     bool isSealed() const;
147     bool isImplementation() const;
148     bool isExternal() const;
149     bool isAlias() const;
150     bool isDefault() const;
151     bool isDelete() const;
152     bool isNoExcept() const;
153     bool isAttribute() const; // UNO IDL attribute
154     bool isUNOProperty() const; // UNO IDL property
155     bool isReadonly() const;
156     bool isBound() const;
157     bool isConstrained() const;
158     bool isTransient() const;
159     bool isMaybeVoid() const;
160     bool isMaybeDefault() const;
161     bool isMaybeAmbiguous() const;
162     bool isPublished() const; // UNO IDL published
163     bool isTemplateSpecialization() const;
164     bool hasDocumentedParams() const;
165     bool hasDocumentedReturnType() const;
166     bool isObjCMethod() const;
167     bool isObjCProperty() const;
168     bool isConstructor() const;
169     bool isDestructor() const;
170     bool hasOneLineInitializer() const;
171     bool hasMultiLineInitializer() const;
172     bool protectionVisible() const;
173     bool showInCallGraph() const;
174     bool isStrongEnumValue() const;
175
176     // output info
177     bool isLinkableInProject() const;
178     bool isLinkable() const;
179     bool hasDocumentation() const;  // overrides hasDocumentation in definition.h
180     //bool hasUserDocumentation() const; // overrides hasUserDocumentation
181     bool isBriefSectionVisible() const;
182     bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
183     bool isDetailedSectionLinkable() const;
184     bool isFriendClass() const;
185     bool isDocumentedFriendClass() const;
186
187     MemberDef *reimplements() const;
188     MemberList *reimplementedBy() const;
189     bool isReimplementedBy(ClassDef *cd) const;
190
191     //int inbodyLine() const;
192     //QCString inbodyFile() const;
193     //const QCString &inbodyDocumentation() const;
194
195     ClassDef *relatedAlso() const;
196
197     bool hasDocumentedEnumValues() const;
198     MemberDef *getAnonymousEnumType() const;
199     bool isDocsForDefinition() const;
200     MemberDef *getEnumScope() const;
201     MemberList *enumFieldList() const;
202     void setEnumBaseType(const QCString &type);
203     QCString enumBaseType() const;
204
205     bool hasExamples();
206     ExampleSDict *getExamples() const;
207     bool isPrototype() const;
208
209     // argument related members
210     ArgumentList *argumentList() const;
211     ArgumentList *declArgumentList() const;
212     ArgumentList *templateArguments() const;
213     QList<ArgumentList> *definitionTemplateParameterLists() const;
214
215     // member group related members
216     int getMemberGroupId() const;
217     MemberGroup *getMemberGroup() const;
218
219     bool fromAnonymousScope() const;
220     bool anonymousDeclShown() const;
221     MemberDef *fromAnonymousMember() const;
222
223     // callgraph related members
224     bool hasCallGraph() const;
225     bool hasCallerGraph() const;
226     bool visibleMemberGroup(bool hideNoHeader);
227
228     MemberDef *templateMaster() const;
229     QCString getScopeString() const;
230     ClassDef *getClassDefOfAnonymousType();
231
232     // cached typedef functions
233     bool isTypedefValCached() const;
234     ClassDef *getCachedTypedefVal() const;
235     QCString getCachedTypedefTemplSpec() const;
236     QCString getCachedResolvedTypedef() const;
237
238     MemberDef *memberDefinition() const;
239     MemberDef *memberDeclaration() const;
240     MemberDef *inheritsDocsFrom() const;
241     MemberDef *getGroupAlias() const;
242
243     ClassDef *category() const;
244     MemberDef *categoryRelation() const;
245
246     QCString displayName(bool=TRUE) const;
247     QCString getDeclType() const;
248     void getLabels(QStrList &sl,Definition *container) const;
249
250     const ArgumentList *typeConstraints() const;
251
252     // overrules
253     QCString documentation() const;
254     QCString briefDescription(bool abbr=FALSE) const;
255     QCString fieldType() const;
256
257
258     //-----------------------------------------------------------------------------------
259     // ----  setters -----
260     //-----------------------------------------------------------------------------------
261
262     // set functions
263     void setMemberType(MemberType t);
264     void setDefinition(const char *d);
265     void setFileDef(FileDef *fd);
266     void setAnchor();
267     void setProtection(Protection p);
268     void setMemberSpecifiers(uint64 s);
269     void mergeMemberSpecifiers(uint64 s);
270     void setInitializer(const char *i);
271     void setBitfields(const char *s);
272     void setMaxInitLines(int lines);
273     void setMemberClass(ClassDef *cd);
274     void setSectionList(Definition *d,MemberList *sl);
275     void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
276                      const QCString &fileName,int startLine,bool hasDocs,
277                      MemberDef *member=0);
278     void setExplicitExternal(bool b);
279     void setReadAccessor(const char *r);
280     void setWriteAccessor(const char *w);
281     void setTemplateSpecialization(bool b);
282     
283     void makeRelated();
284     void makeForeign();
285     void setHasDocumentedParams(bool b);
286     void setHasDocumentedReturnType(bool b);
287     void setInheritsDocsFrom(MemberDef *md);
288     void setTagInfo(TagInfo *i);
289     void setArgsString(const char *as);
290
291     // relation to other members
292     void setReimplements(MemberDef *md);
293     void insertReimplementedBy(MemberDef *md);
294
295     // in-body documentation
296     //void setInbodyDocumentation(const char *docs,const char *file,int line);
297
298     void setRelatedAlso(ClassDef *cd);
299
300     // enumeration specific members
301     void insertEnumField(MemberDef *md);
302     void setEnumScope(MemberDef *md,bool livesInsideEnum=FALSE);
303     void setEnumClassScope(ClassDef *cd);
304     void setDocumentedEnumValues(bool value);
305     void setAnonymousEnumType(MemberDef *md);
306
307     // example related members
308     bool addExample(const char *anchor,const char *name,const char *file);
309     
310     // prototype related members
311     void setPrototype(bool p);
312
313     // argument related members
314     void setArgumentList(ArgumentList *al);
315     void setDeclArgumentList(ArgumentList *al);
316     void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
317     void setTypeConstraints(ArgumentList *al);
318     void setType(const char *t);
319     void setAccessorType(ClassDef *cd,const char *t);
320
321     // namespace related members
322     void setNamespace(NamespaceDef *nd);
323
324     // member group related members
325     void setMemberGroup(MemberGroup *grp);
326     void setMemberGroupId(int id);
327     void makeImplementationDetail();
328
329     // anonymous scope members
330     void setFromAnonymousScope(bool b);
331     void setFromAnonymousMember(MemberDef *m);
332
333     void enableCallGraph(bool e);
334     void enableCallerGraph(bool e);
335
336     void setTemplateMaster(MemberDef *mt);
337     void addListReference(Definition *d);
338     void setDocsForDefinition(bool b);
339     void setGroupAlias(MemberDef *md);
340
341     void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
342     void invalidateTypedefValCache();
343
344     void invalidateCachedArgumentTypes();
345     
346     // declaration <-> definition relation
347     void setMemberDefinition(MemberDef *md);
348     void setMemberDeclaration(MemberDef *md);
349         
350     void setAnonymousUsed();
351     void copyArgumentNames(MemberDef *bmd);
352
353     void setCategory(ClassDef *);
354     void setCategoryRelation(MemberDef *);
355
356     void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
357     void setBriefDescription(const char *b,const char *briefFile,int briefLine);
358     void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
359
360     void setHidden(bool b);
361
362     //-----------------------------------------------------------------------------------
363     // --- actions ----
364     //-----------------------------------------------------------------------------------
365
366     // output generation
367     void writeDeclaration(OutputList &ol,
368                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
369                    bool inGroup, const DefType compoundType,
370                    ClassDef *inheritFrom=0,const char *inheritId=0); 
371     void writeDocumentation(MemberList *ml,OutputList &ol,
372                             const char *scopeName,Definition *container,
373                             bool inGroup,bool showEnumValues=FALSE,bool
374                             showInline=FALSE);
375     void writeMemberDocSimple(OutputList &ol,Definition *container);
376     void writeEnumDeclaration(OutputList &typeDecl,
377             ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd, 
378             const DefType compoundType);
379     void warnIfUndocumented();
380     
381     MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
382                ArgumentList *actualArgs);
383
384     void findSectionsInDocumentation();
385     
386     bool visited;
387    
388   protected:
389     void flushToDisk() const;
390     void loadFromDisk() const;
391   private:
392     void lock() const;
393     void unlock() const;
394     void saveToDisk() const;
395     void makeResident() const;
396     void _computeLinkableInProject();
397     void _computeIsConstructor();
398     void _computeIsDestructor();
399     void _writeGroupInclude(OutputList &ol,bool inGroup);
400     void _writeCallGraph(OutputList &ol);
401     void _writeCallerGraph(OutputList &ol);
402     void _writeReimplements(OutputList &ol);
403     void _writeReimplementedBy(OutputList &ol);
404     void _writeExamples(OutputList &ol);
405     void _writeTypeConstraints(OutputList &ol);
406     void _writeEnumValues(OutputList &ol,Definition *container,
407                           const QCString &cfname,const QCString &ciname,
408                           const QCString &cname);
409     void _writeCategoryRelation(OutputList &ol);
410     void _writeTagData(const DefType);
411     void _addToSearchIndex();
412
413     static int s_indentLevel;
414     // disable copying of member defs
415     MemberDef(const MemberDef &);
416     MemberDef &operator=(const MemberDef &);
417
418     void writeLink(OutputList &ol,
419                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
420                    bool onlyText=FALSE);
421
422     MemberDefImpl *m_impl;
423     uchar m_isLinkableCached;    // 0 = not cached, 1=FALSE, 2=TRUE
424     uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
425     uchar m_isDestructorCached;  // 0 = not cached, 1=FALSE, 2=TRUE
426 };
427
428 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);
429
430 #endif