Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / memberdef.h
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 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,const char *metaData);
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 isSequence() const;
113     bool isDictionary() const;
114     bool isFunction() const;
115     bool isFunctionPtr() const;
116     bool isDefine() const;
117     bool isFriend() const;
118     bool isDCOP() const;
119     bool isProperty() const;
120     bool isEvent() const;
121     bool isRelated() const;
122     bool isForeign() const;
123     bool isStatic() const;
124     bool isInline() const;
125     bool isExplicit() const;
126     bool isMutable() const;
127     bool isGettable() const;
128     bool isPrivateGettable() const;
129     bool isProtectedGettable() const;
130     bool isSettable() const;
131     bool isPrivateSettable() const;
132     bool isProtectedSettable() const;
133     bool isReadable() const;
134     bool isWritable() const;
135     bool isAddable() const;
136     bool isRemovable() const;
137     bool isRaisable() const;
138     bool isFinal() const;
139     bool isAbstract() const;
140     bool isOverride() const;
141     bool isInitonly() const;
142     bool isOptional() const;
143     bool isRequired() const;
144     bool isNonAtomic() const;
145     bool isCopy() const;
146     bool isAssign() const;
147     bool isRetain() const;
148     bool isWeak() const;
149     bool isStrong() const;
150     bool isUnretained() const;
151     bool isNew() const;
152     bool isSealed() const;
153     bool isImplementation() const;
154     bool isExternal() const;
155     bool isAlias() const;
156     bool isDefault() const;
157     bool isDelete() const;
158     bool isNoExcept() const;
159     bool isAttribute() const; // UNO IDL attribute
160     bool isUNOProperty() const; // UNO IDL property
161     bool isReadonly() const;
162     bool isBound() const;
163     bool isConstrained() const;
164     bool isTransient() const;
165     bool isMaybeVoid() const;
166     bool isMaybeDefault() const;
167     bool isMaybeAmbiguous() const;
168     bool isPublished() const; // UNO IDL published
169     bool isTemplateSpecialization() const;
170     bool hasDocumentedParams() const;
171     bool hasDocumentedReturnType() const;
172     bool isObjCMethod() const;
173     bool isObjCProperty() const;
174     bool isConstructor() const;
175     bool isDestructor() const;
176     bool hasOneLineInitializer() const;
177     bool hasMultiLineInitializer() const;
178     bool protectionVisible() const;
179     bool showInCallGraph() const;
180     bool isStrongEnumValue() const;
181     bool livesInsideEnum() const;
182     bool isSliceLocal() const;
183
184     int numberOfFlowKeyWords();
185     // derived getters
186     bool isFriendToHide() const;
187     bool isNotFriend() const;
188     bool isFunctionOrSignalSlot() const;
189     bool isRelatedOrFriend() const;
190
191     // output info
192     bool isLinkableInProject() const;
193     bool isLinkable() const;
194     bool hasDocumentation() const;  // overrides hasDocumentation in definition.h
195     //bool hasUserDocumentation() const; // overrides hasUserDocumentation
196     bool isDeleted() const;
197     bool isBriefSectionVisible() const;
198     bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
199     bool isDetailedSectionLinkable() const;
200     bool isFriendClass() const;
201     bool isDocumentedFriendClass() const;
202
203     MemberDef *reimplements() const;
204     MemberList *reimplementedBy() const;
205     bool isReimplementedBy(ClassDef *cd) const;
206
207     //int inbodyLine() const;
208     //QCString inbodyFile() const;
209     //const QCString &inbodyDocumentation() const;
210
211     ClassDef *relatedAlso() const;
212
213     bool hasDocumentedEnumValues() const;
214     MemberDef *getAnonymousEnumType() const;
215     bool isDocsForDefinition() const;
216     MemberDef *getEnumScope() const;
217     MemberList *enumFieldList() const;
218     void setEnumBaseType(const QCString &type);
219     QCString enumBaseType() const;
220
221     bool hasExamples();
222     ExampleSDict *getExamples() const;
223     bool isPrototype() const;
224
225     // argument related members
226     ArgumentList *argumentList() const;
227     ArgumentList *declArgumentList() const;
228     ArgumentList *templateArguments() const;
229     QList<ArgumentList> *definitionTemplateParameterLists() const;
230
231     // member group related members
232     int getMemberGroupId() const;
233     MemberGroup *getMemberGroup() const;
234
235     bool fromAnonymousScope() const;
236     bool anonymousDeclShown() const;
237     MemberDef *fromAnonymousMember() const;
238
239     // callgraph related members
240     bool hasCallGraph() const;
241     bool hasCallerGraph() const;
242     bool visibleMemberGroup(bool hideNoHeader);
243     // refrenced related members
244     bool hasReferencesRelation() const;
245     bool hasReferencedByRelation() const;
246
247     MemberDef *templateMaster() const;
248     QCString getScopeString() const;
249     ClassDef *getClassDefOfAnonymousType();
250
251     // cached typedef functions
252     bool isTypedefValCached() const;
253     ClassDef *getCachedTypedefVal() const;
254     QCString getCachedTypedefTemplSpec() const;
255     QCString getCachedResolvedTypedef() const;
256
257     MemberDef *memberDefinition() const;
258     MemberDef *memberDeclaration() const;
259     MemberDef *inheritsDocsFrom() const;
260     MemberDef *getGroupAlias() const;
261
262     ClassDef *category() const;
263     MemberDef *categoryRelation() const;
264
265     QCString displayName(bool=TRUE) const;
266     QCString getDeclType() const;
267     void getLabels(QStrList &sl,Definition *container) const;
268
269     const ArgumentList *typeConstraints() const;
270
271     // overrules
272     QCString documentation() const;
273     QCString briefDescription(bool abbr=FALSE) const;
274     QCString fieldType() const;
275     bool isReference() const;
276
277
278     //-----------------------------------------------------------------------------------
279     // ----  setters -----
280     //-----------------------------------------------------------------------------------
281
282     void addFlowKeyWord();
283
284     // set functions
285     void setMemberType(MemberType t);
286     void setDefinition(const char *d);
287     void setFileDef(FileDef *fd);
288     void setAnchor();
289     void setProtection(Protection p);
290     void setMemberSpecifiers(uint64 s);
291     void mergeMemberSpecifiers(uint64 s);
292     void setInitializer(const char *i);
293     void setBitfields(const char *s);
294     void setMaxInitLines(int lines);
295     void setMemberClass(ClassDef *cd);
296     void setSectionList(Definition *d,MemberList *sl);
297     void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
298                      const QCString &fileName,int startLine,bool hasDocs,
299                      MemberDef *member=0);
300     void setExplicitExternal(bool b);
301     void setReadAccessor(const char *r);
302     void setWriteAccessor(const char *w);
303     void setTemplateSpecialization(bool b);
304     
305     void makeRelated();
306     void makeForeign();
307     void setHasDocumentedParams(bool b);
308     void setHasDocumentedReturnType(bool b);
309     void setInheritsDocsFrom(MemberDef *md);
310     void setTagInfo(TagInfo *i);
311     void setArgsString(const char *as);
312
313     // relation to other members
314     void setReimplements(MemberDef *md);
315     void insertReimplementedBy(MemberDef *md);
316
317     // in-body documentation
318     //void setInbodyDocumentation(const char *docs,const char *file,int line);
319
320     void setRelatedAlso(ClassDef *cd);
321
322     // enumeration specific members
323     void insertEnumField(MemberDef *md);
324     void setEnumScope(MemberDef *md,bool livesInsideEnum=FALSE);
325     void setEnumClassScope(ClassDef *cd);
326     void setDocumentedEnumValues(bool value);
327     void setAnonymousEnumType(MemberDef *md);
328
329     // example related members
330     bool addExample(const char *anchor,const char *name,const char *file);
331     
332     // prototype related members
333     void setPrototype(bool p);
334
335     // argument related members
336     void setArgumentList(ArgumentList *al);
337     void setDeclArgumentList(ArgumentList *al);
338     void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
339     void setTypeConstraints(ArgumentList *al);
340     void setType(const char *t);
341     void setAccessorType(ClassDef *cd,const char *t);
342
343     // namespace related members
344     void setNamespace(NamespaceDef *nd);
345
346     // member group related members
347     void setMemberGroup(MemberGroup *grp);
348     void setMemberGroupId(int id);
349     void makeImplementationDetail();
350
351     // anonymous scope members
352     void setFromAnonymousScope(bool b);
353     void setFromAnonymousMember(MemberDef *m);
354
355     void enableCallGraph(bool e);
356     void enableCallerGraph(bool e);
357
358     void enableReferencedByRelation(bool e);
359     void enableReferencesRelation(bool e);
360
361     void setTemplateMaster(MemberDef *mt);
362     void addListReference(Definition *d);
363     void setDocsForDefinition(bool b);
364     void setGroupAlias(MemberDef *md);
365
366     void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
367     void invalidateTypedefValCache();
368
369     void invalidateCachedArgumentTypes();
370     
371     // declaration <-> definition relation
372     void setMemberDefinition(MemberDef *md);
373     void setMemberDeclaration(MemberDef *md);
374         
375     void setAnonymousUsed();
376     void copyArgumentNames(MemberDef *bmd);
377
378     void setCategory(ClassDef *);
379     void setCategoryRelation(MemberDef *);
380
381     void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
382     void setBriefDescription(const char *b,const char *briefFile,int briefLine);
383     void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
384
385     void setHidden(bool b);
386
387     //-----------------------------------------------------------------------------------
388     // --- actions ----
389     //-----------------------------------------------------------------------------------
390
391     // output generation
392     void writeDeclaration(OutputList &ol,
393                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
394                    bool inGroup, ClassDef *inheritFrom=0,const char *inheritId=0); 
395     void writeDocumentation(MemberList *ml,int memCount,int memTotal,OutputList &ol,
396                             const char *scopeName,Definition *container,
397                             bool inGroup,bool showEnumValues=FALSE,bool
398                             showInline=FALSE);
399     void writeMemberDocSimple(OutputList &ol,Definition *container);
400     void writeEnumDeclaration(OutputList &typeDecl,
401             ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd);
402     void writeTagFile(FTextStream &);
403     void warnIfUndocumented();
404     void warnIfUndocumentedParams();
405     
406     MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
407                ArgumentList *actualArgs);
408
409     void findSectionsInDocumentation();
410     
411     bool visited;
412    
413   protected:
414     void flushToDisk() const;
415     void loadFromDisk() const;
416   private:
417     void lock() const;
418     void unlock() const;
419     void saveToDisk() const;
420     void makeResident() const;
421     void _computeLinkableInProject();
422     void _computeIsConstructor();
423     void _computeIsDestructor();
424     void _writeGroupInclude(OutputList &ol,bool inGroup);
425     void _writeCallGraph(OutputList &ol);
426     void _writeCallerGraph(OutputList &ol);
427     void _writeReimplements(OutputList &ol);
428     void _writeReimplementedBy(OutputList &ol);
429     void _writeExamples(OutputList &ol);
430     void _writeTypeConstraints(OutputList &ol);
431     void _writeEnumValues(OutputList &ol,Definition *container,
432                           const QCString &cfname,const QCString &ciname,
433                           const QCString &cname);
434     void _writeCategoryRelation(OutputList &ol);
435     void _writeTagData(const DefType);
436     void _addToSearchIndex();
437
438     static int s_indentLevel;
439
440     int number_of_flowkw;
441
442     // disable copying of member defs
443     MemberDef(const MemberDef &);
444     MemberDef &operator=(const MemberDef &);
445
446     void writeLink(OutputList &ol,
447                    ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
448                    bool onlyText=FALSE);
449
450     MemberDefImpl *m_impl;
451     uchar m_isLinkableCached;    // 0 = not cached, 1=FALSE, 2=TRUE
452     uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
453     uchar m_isDestructorCached;  // 0 = not cached, 1=FALSE, 2=TRUE
454 };
455
456 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);
457
458 #endif