1 /******************************************************************************
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
27 #include "definition.h"
43 /** A model of a class/file/namespace member symbol. */
44 class MemberDef : public Definition
63 MemberDef(const char *defFileName,int defLine,
64 const char *type,const char *name,const char *args,
65 const char *excp,Protection prot,Specifier virt,bool stat,
66 Relationship related,MemberType t,const ArgumentList *tal,
67 const ArgumentList *al);
69 DefType definitionType() const { return TypeMember; }
70 // move this member into a different scope
71 MemberDef *deepCopy() const;
72 void moveTo(Definition *);
74 //-----------------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------------
79 QCString getOutputFileBase() const;
80 QCString getReference() const;
81 QCString anchor() const;
83 const char *declaration() const;
84 const char *definition() const;
85 const char *typeString() const;
86 const char *argsString() const;
87 const char *excpString() const;
88 const char *bitfieldString() const;
89 const char *extraTypeChars() const;
90 const QCString &initializer() const;
91 int initializerLines() const;
92 int getMemberSpecifiers() const;
93 MemberList *getSectionList(Definition *d) const;
95 // scope query members
96 ClassDef *getClassDef() const;
97 FileDef *getFileDef() const;
98 NamespaceDef* getNamespaceDef() const;
100 // grabbing the property read/write accessor names
101 const char *getReadAccessor() const;
102 const char *getWriteAccessor() const;
104 // querying the grouping definition
105 GroupDef *getGroupDef() const;
106 Grouping::GroupPri_t getGroupPri() const;
107 const char *getGroupFileName() const;
108 int getGroupStartLine() const;
109 bool getGroupHasDocs() const;
110 QCString qualifiedName() const;
111 QCString objCMethodName(bool localLink,bool showStatic) const;
114 Protection protection() const;
115 Specifier virtualness(int count=0) const;
116 MemberType memberType() const;
117 QCString memberTypeName() const;
120 bool isSignal() const;
122 bool isVariable() const;
123 bool isEnumerate() const;
124 bool isEnumValue() const;
125 bool isTypedef() const;
126 bool isFunction() const;
127 bool isFunctionPtr() const;
128 bool isDefine() const;
129 bool isFriend() const;
131 bool isProperty() const;
132 bool isEvent() const;
133 bool isRelated() const;
134 bool isForeign() const;
135 bool isStatic() const;
136 bool isInline() const;
137 bool isExplicit() const;
138 bool isMutable() const;
139 bool isGettable() const;
140 bool isSettable() const;
141 bool isReadable() const;
142 bool isWritable() const;
143 bool isAddable() const;
144 bool isRemovable() const;
145 bool isRaisable() const;
146 bool isFinal() const;
147 bool isAbstract() const;
148 bool isOverride() const;
149 bool isInitonly() const;
150 bool isOptional() const;
151 bool isRequired() const;
152 bool isNonAtomic() const;
154 bool isAssign() const;
155 bool isRetain() const;
157 bool isStrong() const;
158 bool isUnretained() const;
160 bool isSealed() const;
161 bool isImplementation() const;
162 bool isExternal() const;
163 bool isAlias() const;
164 bool isDefault() const;
165 bool isDelete() const;
166 bool isNoExcept() const;
167 bool isTemplateSpecialization() const;
168 bool hasDocumentedParams() const;
169 bool hasDocumentedReturnType() const;
170 bool isObjCMethod() const;
171 bool isObjCProperty() const;
172 bool isConstructor() const;
173 bool isDestructor() const;
174 bool hasOneLineInitializer() const;
175 bool hasMultiLineInitializer() const;
176 bool protectionVisible() const;
179 bool isLinkableInProject() const;
180 bool isLinkable() const;
181 bool hasDocumentation() const; // overrides hasDocumentation in definition.h
182 //bool hasUserDocumentation() const; // overrides hasUserDocumentation
183 bool isBriefSectionVisible() const;
184 bool isDetailedSectionVisible(bool inGroup,bool inFile) const;
185 bool isDetailedSectionLinkable() const;
186 bool isFriendClass() const;
187 bool isDocumentedFriendClass() const;
189 MemberDef *reimplements() const;
190 LockingPtr< MemberList > reimplementedBy() const;
191 bool isReimplementedBy(ClassDef *cd) const;
193 //int inbodyLine() const;
194 //QCString inbodyFile() const;
195 //const QCString &inbodyDocumentation() const;
197 ClassDef *relatedAlso() const;
199 bool hasDocumentedEnumValues() const;
200 MemberDef *getAnonymousEnumType() const;
201 bool isDocsForDefinition() const;
202 MemberDef *getEnumScope() const;
203 LockingPtr< MemberList > enumFieldList() const;
204 void setEnumBaseType(const QCString &type);
205 QCString enumBaseType() const;
208 LockingPtr<ExampleSDict> getExamples() const;
209 bool isPrototype() const;
211 // argument related members
212 LockingPtr<ArgumentList> argumentList() const;
213 LockingPtr<ArgumentList> declArgumentList() const;
214 LockingPtr<ArgumentList> templateArguments() const;
215 LockingPtr< QList<ArgumentList> > definitionTemplateParameterLists() const;
217 // member group related members
218 int getMemberGroupId() const;
219 MemberGroup *getMemberGroup() const;
221 bool fromAnonymousScope() const;
222 bool anonymousDeclShown() const;
224 // callgraph related members
225 bool hasCallGraph() const;
226 bool hasCallerGraph() const;
227 bool visibleMemberGroup(bool hideNoHeader);
229 MemberDef *templateMaster() const;
230 QCString getScopeString() const;
231 ClassDef *getClassDefOfAnonymousType();
233 // cached typedef functions
234 bool isTypedefValCached() const;
235 ClassDef *getCachedTypedefVal() const;
236 QCString getCachedTypedefTemplSpec() const;
237 QCString getCachedResolvedTypedef() const;
239 MemberDef *memberDefinition() const;
240 MemberDef *memberDeclaration() const;
241 MemberDef *inheritsDocsFrom() const;
242 MemberDef *getGroupAlias() const;
244 ClassDef *category() const;
245 MemberDef *categoryRelation() const;
247 QCString displayName(bool=TRUE) const;
249 //-----------------------------------------------------------------------------------
250 // ---- setters -----
251 //-----------------------------------------------------------------------------------
254 void setMemberType(MemberType t);
255 void setDefinition(const char *d);
256 void setFileDef(FileDef *fd);
257 void setAnchor(const char *a);
258 void setProtection(Protection p);
259 void setMemberSpecifiers(int s);
260 void mergeMemberSpecifiers(int s);
261 void setInitializer(const char *i);
262 void setBitfields(const char *s);
263 void setMaxInitLines(int lines);
264 void setMemberClass(ClassDef *cd);
265 void setSectionList(Definition *d,MemberList *sl);
266 void setGroupDef(GroupDef *gd,Grouping::GroupPri_t pri,
267 const QCString &fileName,int startLine,bool hasDocs,
268 MemberDef *member=0);
269 void setExplicitExternal(bool b);
270 void setReadAccessor(const char *r);
271 void setWriteAccessor(const char *w);
272 void setTemplateSpecialization(bool b);
276 void setHasDocumentedParams(bool b);
277 void setHasDocumentedReturnType(bool b);
278 void setInheritsDocsFrom(MemberDef *md);
279 void setTagInfo(TagInfo *i);
280 void setArgsString(const char *as);
282 // relation to other members
283 void setReimplements(MemberDef *md);
284 void insertReimplementedBy(MemberDef *md);
286 // in-body documentation
287 //void setInbodyDocumentation(const char *docs,const char *file,int line);
289 void setRelatedAlso(ClassDef *cd);
291 // enumeration specific members
292 void insertEnumField(MemberDef *md);
293 void setEnumScope(MemberDef *md);
294 void setEnumClassScope(ClassDef *cd);
295 void setDocumentedEnumValues(bool value);
296 void setAnonymousEnumType(MemberDef *md);
298 // example related members
299 bool addExample(const char *anchor,const char *name,const char *file);
301 // prototype related members
302 void setPrototype(bool p);
304 // argument related members
305 void setArgumentList(ArgumentList *al);
306 void setDeclArgumentList(ArgumentList *al);
307 void setDefinitionTemplateParameterLists(QList<ArgumentList> *lists);
308 void setTypeConstraints(ArgumentList *al);
309 void setType(const char *t);
310 void setAccessorType(ClassDef *cd,const char *t);
312 // namespace related members
313 void setNamespace(NamespaceDef *nd);
315 // member group related members
316 void setMemberGroup(MemberGroup *grp);
317 void setMemberGroupId(int id);
318 void makeImplementationDetail();
320 // anonymous scope members
321 void setFromAnonymousScope(bool b);
322 void setFromAnonymousMember(MemberDef *m);
324 void enableCallGraph(bool e);
325 void enableCallerGraph(bool e);
327 void setTemplateMaster(MemberDef *mt);
328 void addListReference(Definition *d);
329 void setDocsForDefinition(bool b);
330 void setGroupAlias(MemberDef *md);
332 void cacheTypedefVal(ClassDef *val,const QCString &templSpec,const QCString &resolvedType);
333 void invalidateTypedefValCache();
335 void invalidateCachedArgumentTypes();
337 // declaration <-> definition relation
338 void setMemberDefinition(MemberDef *md);
339 void setMemberDeclaration(MemberDef *md);
341 void setAnonymousUsed();
342 void copyArgumentNames(MemberDef *bmd);
344 void setCategory(ClassDef *);
345 void setCategoryRelation(MemberDef *);
347 void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
348 void setBriefDescription(const char *b,const char *briefFile,int briefLine);
349 void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine);
351 void setHidden(bool b);
353 //-----------------------------------------------------------------------------------
355 //-----------------------------------------------------------------------------------
358 void writeDeclaration(OutputList &ol,
359 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
360 bool inGroup,ClassDef *inheritFrom=0,const char *inheritId=0);
361 void writeDocumentation(MemberList *ml,OutputList &ol,
362 const char *scopeName,Definition *container,
363 bool inGroup,bool showEnumValues=FALSE,bool
365 void writeMemberDocSimple(OutputList &ol,Definition *container);
366 void warnIfUndocumented();
368 MemberDef *createTemplateInstanceMember(ArgumentList *formalArgs,
369 ArgumentList *actualArgs);
371 void writeEnumDeclaration(OutputList &typeDecl,
372 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd);
374 void findSectionsInDocumentation();
379 void flushToDisk() const;
380 void loadFromDisk() const;
384 void saveToDisk() const;
385 void makeResident() const;
386 void _computeLinkableInProject();
387 void _computeIsConstructor();
388 void _computeIsDestructor();
389 void _getLabels(QStrList &sl,Definition *container) const;
390 void _writeCallGraph(OutputList &ol);
391 void _writeCallerGraph(OutputList &ol);
392 void _writeReimplements(OutputList &ol);
393 void _writeReimplementedBy(OutputList &ol);
394 void _writeExamples(OutputList &ol);
395 void _writeTypeConstraints(OutputList &ol);
396 void _writeEnumValues(OutputList &ol,Definition *container,
397 const QCString &cfname,const QCString &ciname,
398 const QCString &cname);
399 void _writeCategoryRelation(OutputList &ol);
401 static int s_indentLevel;
402 // disable copying of member defs
403 MemberDef(const MemberDef &);
404 MemberDef &operator=(const MemberDef &);
406 void writeLink(OutputList &ol,
407 ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
408 bool onlyText=FALSE);
410 MemberDefImpl *m_impl;
412 off_t m_storagePos; // location where the item is stored in file (if impl==0)
414 uchar m_isLinkableCached; // 0 = not cached, 1=FALSE, 2=TRUE
415 uchar m_isConstructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
416 uchar m_isDestructorCached; // 0 = not cached, 1=FALSE, 2=TRUE
419 void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef);