1 /******************************************************************************
3 * $Id: definition.h,v 1.21 2001/03/19 19:27:40 root Exp $
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.
24 #include <sys/types.h>
26 #include "lockingptr.h"
41 /** Data associated with a detailed description. */
49 /** Data associated with a brief description. */
58 /** Data associated with description found in the body. */
61 int startLine; //!< line number of the start of the definition
62 int endLine; //!< line number of the end of the definition
63 FileDef *fileDef; //!< file definition containing the function body
66 /** Abstract interface for a Definition or DefinitionList */
71 virtual ~DefinitionIntf() {}
72 /*! Types of derived classes */
85 /*! Use this for dynamic inspection of the type of the derived class */
86 virtual DefType definitionType() const = 0;
89 /** The common base class of all entity definitions found in the sources.
91 * This can be a class or a member function, or a file, or a namespace, etc.
92 * Use definitionType() to find which type of definition this is.
94 class Definition : public DefinitionIntf, public LockableObj
98 /*! Create a new definition */
100 const char *defFileName,int defLine,
101 const char *name,const char *b=0,const char *d=0,
104 /*! Destroys the definition */
105 virtual ~Definition();
107 //-----------------------------------------------------------------------------------
108 // ---- getters -----
109 //-----------------------------------------------------------------------------------
111 /*! Returns the name of the definition */
112 const QCString& name() const { return m_name; }
114 /*! Returns the name of the definition as it appears in the output */
115 virtual QCString displayName(bool includeScope=TRUE) const = 0;
117 /*! Returns the local name without any scope qualifiers. */
118 QCString localName() const;
120 /*! Returns the fully qualified name of this definition
122 virtual QCString qualifiedName() const;
124 /*! Returns the name of this definition as it appears in the symbol map.
126 QCString symbolName() const;
128 /*! Returns the base file name (without extension) of this definition.
129 * as it is referenced to/written to disk.
131 virtual QCString getOutputFileBase() const = 0;
133 /*! Returns the anchor within a page where this item can be found */
134 virtual QCString anchor() const = 0;
136 /*! Returns the name of the source listing of this file. */
137 virtual QCString getSourceFileBase() const { ASSERT(0); return "NULL"; }
139 /*! Returns the detailed description of this definition */
140 QCString documentation() const;
142 /*! Returns the line number at which the detailed documentation was found. */
145 /*! Returns the file in which the detailed documentation block was found.
146 * This can differ from getDefFileName().
148 QCString docFile() const;
150 /*! Returns the brief description of this definition. This can include commands. */
151 QCString briefDescription(bool abbreviate=FALSE) const;
153 /*! Returns a plain text version of the brief description suitable for use
156 QCString briefDescriptionAsTooltip() const;
158 /*! Returns the line number at which the brief description was found. */
159 int briefLine() const;
161 /*! Returns the documentation found inside the body of a member */
162 QCString inbodyDocumentation() const;
164 /*! Returns the file in which the in body documentation was found */
165 QCString inbodyFile() const;
167 /*! Returns the line at which the first in body documentation
169 int inbodyLine() const;
171 /*! Returns the file in which the brief description was found.
172 * This can differ from getDefFileName().
174 QCString briefFile() const;
176 /*! returns the file in which this definition was found */
177 QCString getDefFileName() const;
179 /*! returns the extension of the file in which this definition was found */
180 QCString getDefFileExtension() const;
182 /*! returns the line number at which the definition was found */
183 int getDefLine() const { return m_defLine; }
185 /*! Returns TRUE iff the definition is documented
186 * (which could be generated documentation)
187 * @see hasUserDocumentation()
189 virtual bool hasDocumentation() const;
191 /*! Returns TRUE iff the definition is documented by the user. */
192 virtual bool hasUserDocumentation() const;
194 /*! Returns TRUE iff it is possible to link to this item within this
197 virtual bool isLinkableInProject() const = 0;
199 /*! Returns TRUE iff it is possible to link to this item. This can
200 * be a link to another project imported via a tag file.
202 virtual bool isLinkable() const = 0;
204 /*! Returns TRUE iff the name is part of this project and
205 * may appear in the output
207 virtual bool isVisibleInProject() const;
209 /*! Returns TRUE iff the name may appear in the output */
210 virtual bool isVisible() const;
212 /*! Returns TRUE iff this item is supposed to be hidden from the output. */
213 bool isHidden() const;
215 /*! returns TRUE if this entity was artificially introduced, for
216 * instance because it is used to show a template instantiation relation.
218 bool isArtificial() const;
220 /*! If this definition was imported via a tag file, this function
221 * returns the tagfile for the external project. This can be
222 * translated into an external link target via
223 * Doxygen::tagDestinationDict
225 virtual QCString getReference() const;
227 /*! Returns TRUE if this definition is imported via a tag file. */
228 virtual bool isReference() const;
230 /*! Returns the first line of the body of this item (applicable to classes and
233 int getStartBodyLine() const;
235 /*! Returns the last line of the body of this item (applicable to classes and
238 int getEndBodyLine() const;
240 /*! Returns the file in which the body of this item is located or 0 if no
243 FileDef *getBodyDef();
245 /** Returns the programming language this definition was written in. */
246 SrcLangExt getLanguage() const;
248 LockingPtr<GroupList> partOfGroups() const;
250 LockingPtr< QList<ListItemInfo> > xrefListItems() const;
252 virtual Definition *findInnerCompound(const char *name);
253 virtual Definition *getOuterScope() const;
255 LockingPtr<MemberSDict> getReferencesMembers() const;
256 LockingPtr<MemberSDict> getReferencedByMembers() const;
258 bool hasSections() const;
260 //-----------------------------------------------------------------------------------
261 // ---- setters -----
262 //-----------------------------------------------------------------------------------
264 /*! Sets a new \a name for the definition */
265 void setName(const char *name);
267 /*! Sets the documentation of this definition to \a d. */
268 virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE);
270 /*! Sets the brief description of this definition to \a b.
271 * A dot is added to the sentence if not available.
273 virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine);
275 /*! Set the documentation that was found inside the body of an item.
276 * If there was already some documentation set, the new documentation
279 virtual void setInbodyDocumentation(const char *d,const char *docFile,int docLine);
281 /*! Sets the tag file id via which this definition was imported. */
282 void setReference(const char *r);
284 /*! Add the list of anchors that mark the sections that are found in the
287 void addSectionsToDefinition(QList<SectionInfo> *anchorList);
290 void setBodySegment(int bls,int ble);
291 void setBodyDef(FileDef *fd);
292 void addSourceReferencedBy(MemberDef *d);
293 void addSourceReferences(MemberDef *d);
295 void setRefItems(const QList<ListItemInfo> *sli);
296 void mergeRefItems(Definition *d);
297 virtual void addInnerCompound(Definition *d);
298 virtual void setOuterScope(Definition *d);
300 virtual void setHidden(bool b);
302 void setArtificial(bool b);
303 void setLanguage(SrcLangExt lang);
305 //-----------------------------------------------------------------------------------
307 //-----------------------------------------------------------------------------------
309 QCString convertNameToFile(const char *name,bool allowDots=FALSE) const;
310 void writeSourceDef(OutputList &ol,const char *scopeName);
311 void writeInlineCode(OutputList &ol,const char *scopeName);
312 void writeSourceRefs(OutputList &ol,const char *scopeName);
313 void writeSourceReffedBy(OutputList &ol,const char *scopeName);
314 void makePartOfGroup(GroupDef *gd);
315 //void writePathFragment(OutputList &ol) const;
316 void writeNavigationPath(OutputList &ol) const;
317 QCString navigationPathAsString() const;
318 virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {}
319 virtual void writeSummaryLinks(OutputList &) {}
320 QCString pathFragment() const;
322 /*! Writes the documentation anchors of the definition to
323 * the Doxygen::tagFile stream.
325 void writeDocAnchorsToTagFile();
326 void setLocalName(const QCString name);
328 void addSectionsToIndex();
329 void writeToc(OutputList &ol);
333 virtual void flushToDisk() const;
334 virtual void loadFromDisk() const;
335 virtual void makeResident() const;
337 void unlock() const {}
339 Definition(const Definition &d);
342 static void addToMap(const char *name,Definition *d);
343 static void removeFromMap(Definition *d);
345 void _setSymbolName(const QCString &name);
347 int _getXRefListId(const char *listName) const;
348 void _writeSourceRefList(OutputList &ol,const char *scopeName,
349 const QCString &text,MemberSDict *members,bool);
350 void _setBriefDescription(const char *b,const char *briefFile,int briefLine);
351 void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop);
352 void _setInbodyDocumentation(const char *d,const char *docFile,int docLine);
353 bool _docsAlreadyAdded(const QCString &doc);
354 DefinitionImpl *m_impl; // internal structure holding all private data
357 QCString m_symbolName;
361 /** A list of Definition objects. */
362 class DefinitionList : public QList<Definition>, public DefinitionIntf
366 DefType definitionType() const { return TypeSymbolList; }
367 int compareItems(GCI item1,GCI item2)
369 return stricmp(((Definition *)item1)->name(),
370 ((Definition *)item2)->name()
376 /** An iterator for Definition objects in a DefinitionList. */
377 class DefinitionListIterator : public QListIterator<Definition>
380 DefinitionListIterator(const DefinitionList &l) :
381 QListIterator<Definition>(l) {}
382 ~DefinitionListIterator() {}