00001 /****************************************************************************** 00002 * 00003 * $Id: definition.h,v 1.21 2001/03/19 19:27:40 root Exp $ 00004 * 00005 * Copyright (C) 1997-2008 by Dimitri van Heesch. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and its 00008 * documentation under the terms of the GNU General Public License is hereby 00009 * granted. No representations are made about the suitability of this software 00010 * for any purpose. It is provided "as is" without express or implied warranty. 00011 * See the GNU General Public License for more details. 00012 * 00013 * Documents produced by Doxygen are derivative works derived from the 00014 * input used in their production; they are not affected by this license. 00015 * 00016 */ 00017 00018 #ifndef DEFINITION_H 00019 #define DEFINITION_H 00020 00021 #include "qtbc.h" 00022 #include <qlist.h> 00023 #include <qdict.h> 00024 #include <sys/types.h> 00025 00026 #include "lockingptr.h" 00027 00028 class FileDef; 00029 class OutputList; 00030 class SectionDict; 00031 class MemberSDict; 00032 class MemberDef; 00033 class GroupDef; 00034 class GroupList; 00035 struct ListItemInfo; 00036 struct SectionInfo; 00037 class Definition; 00038 class DefinitionImpl; 00039 00040 #if 0 00041 struct ReachableDefinition 00042 { 00043 ReachableDefinition(Definition *d,int dist) : def(d), distance(dist) {} 00044 Definition *def; 00045 int distance; 00046 }; 00047 #endif 00048 00049 struct DocInfo 00050 { 00051 QCString doc; 00052 int line; 00053 QCString file; 00054 }; 00055 00056 struct BriefInfo 00057 { 00058 QCString doc; 00059 QCString tooltip; 00060 int line; 00061 QCString file; 00062 }; 00063 00064 struct BodyInfo 00065 { 00066 int startLine; // line number of the start of the definition 00067 int endLine; // line number of the end of the definition 00068 FileDef *fileDef; // file definition containing the function body 00069 }; 00070 00072 class DefinitionIntf 00073 { 00074 public: 00075 DefinitionIntf() {} 00076 virtual ~DefinitionIntf() {} 00078 enum DefType 00079 { 00080 TypeClass = 0, 00081 TypeFile = 1, 00082 TypeNamespace = 2, 00083 TypeMember = 3, 00084 TypeGroup = 4, 00085 TypePackage = 5, 00086 TypePage = 6, 00087 TypeDir = 7, 00088 TypeSymbolList = 8 00089 }; 00091 virtual DefType definitionType() const = 0; 00092 }; 00093 00098 class Definition : public DefinitionIntf, public LockableObj 00099 { 00100 public: 00101 00103 Definition( 00104 const char *defFileName,int defLine, 00105 const char *name,const char *b=0,const char *d=0, 00106 bool isSymbol=TRUE); 00107 00109 virtual ~Definition(); 00110 00111 //----------------------------------------------------------------------------------- 00112 // ---- getters ----- 00113 //----------------------------------------------------------------------------------- 00114 00116 const QCString& name() const { return m_name; } 00117 00119 QCString localName() const; 00120 00123 virtual QCString qualifiedName() const; 00124 00127 QCString symbolName() const; 00128 00132 virtual QCString getOutputFileBase() const = 0; 00133 00135 virtual QCString getSourceFileBase() const { ASSERT(0); return "NULL"; } 00136 00138 QCString documentation() const; 00139 00141 int docLine() const; 00142 00146 QCString docFile() const; 00147 00149 QCString briefDescription() const; 00150 00154 QCString briefDescriptionAsTooltip() const; 00155 00157 int briefLine() const; 00158 00162 QCString briefFile() const; 00163 00165 QCString getDefFileName() const; 00166 00168 QCString getDefFileExtension() const; 00169 00171 int getDefLine() const; 00172 00177 virtual bool hasDocumentation() const; 00178 00180 virtual bool hasUserDocumentation() const; 00181 00185 virtual bool isLinkableInProject() const = 0; 00186 00190 virtual bool isLinkable() const = 0; 00191 00195 virtual bool isVisibleInProject() const; 00196 00198 virtual bool isVisible() const; 00199 00201 bool isHidden() const; 00202 00206 bool isArtificial() const; 00207 00213 virtual QCString getReference() const; 00214 00216 virtual bool isReference() const; 00217 00221 int getStartBodyLine() const; 00222 00226 int getEndBodyLine() const; 00227 00231 FileDef *getBodyDef(); 00232 00233 LockingPtr<GroupList> partOfGroups() const; 00234 00235 LockingPtr< QList<ListItemInfo> > xrefListItems() const; 00236 00237 virtual Definition *findInnerCompound(const char *name); 00238 virtual Definition *getOuterScope() const; 00239 00240 LockingPtr<MemberSDict> getReferencesMembers() const; 00241 LockingPtr<MemberSDict> getReferencedByMembers() const; 00242 00243 //----------------------------------------------------------------------------------- 00244 // ---- setters ----- 00245 //----------------------------------------------------------------------------------- 00246 00248 void setName(const char *name); 00249 00251 void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE); 00252 00256 void setBriefDescription(const char *b,const char *briefFile,int briefLine); 00257 00259 void setReference(const char *r); 00260 00264 void addSectionsToDefinition(QList<SectionInfo> *anchorList); 00265 00266 // source references 00267 void setBodySegment(int bls,int ble); 00268 void setBodyDef(FileDef *fd); 00269 void addSourceReferencedBy(MemberDef *d); 00270 void addSourceReferences(MemberDef *d); 00271 00272 void setRefItems(const QList<ListItemInfo> *sli); 00273 void mergeRefItems(Definition *d); 00274 virtual void addInnerCompound(Definition *d); 00275 virtual void setOuterScope(Definition *d); 00276 00277 void setHidden(bool b); 00278 00279 void setArtificial(bool b); 00280 00281 //----------------------------------------------------------------------------------- 00282 // --- actions ---- 00283 //----------------------------------------------------------------------------------- 00284 00285 QCString convertNameToFile(const char *name,bool allowDots=FALSE) const; 00286 void writeSourceDef(OutputList &ol,const char *scopeName); 00287 void writeInlineCode(OutputList &ol,const char *scopeName); 00288 void writeSourceRefs(OutputList &ol,const char *scopeName); 00289 void writeSourceReffedBy(OutputList &ol,const char *scopeName); 00290 void makePartOfGroup(GroupDef *gd); 00291 void writePathFragment(OutputList &ol) const; 00292 void writeNavigationPath(OutputList &ol) const; 00293 virtual void writeQuickMemberLinks(OutputList &,MemberDef *) const {} 00294 00298 void writeDocAnchorsToTagFile(); 00299 00300 protected: 00301 void setLocalName(const QCString name); 00302 00303 virtual void flushToDisk() const; 00304 virtual void loadFromDisk() const; 00305 virtual void makeResident() const; 00306 void lock() const {} 00307 void unlock() const {} 00308 00309 private: 00310 00311 static void addToMap(const char *name,Definition *d); 00312 static void removeFromMap(Definition *d); 00313 00314 void _setSymbolName(const QCString &name); 00315 00316 int _getXRefListId(const char *listName) const; 00317 void _writeSourceRefList(OutputList &ol,const char *scopeName, 00318 const QCString &text,MemberSDict *members,bool); 00319 void _setBriefDescription(const char *b,const char *briefFile,int briefLine); 00320 void _setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace,bool atTop); 00321 bool _docsAlreadyAdded(const QString &doc); 00322 DefinitionImpl *m_impl; // internal structure holding all private data 00323 QCString m_name; 00324 bool m_isSymbol; 00325 QCString m_symbolName; 00326 00327 }; 00328 00329 class DefinitionList : public QList<Definition>, public DefinitionIntf 00330 { 00331 public: 00332 ~DefinitionList() {} 00333 DefType definitionType() const { return TypeSymbolList; } 00334 int compareItems(GCI item1,GCI item2) 00335 { 00336 return stricmp(((Definition *)item1)->name(), 00337 ((Definition *)item2)->name() 00338 ); 00339 } 00340 00341 }; 00342 00343 class DefinitionListIterator : public QListIterator<Definition> 00344 { 00345 public: 00346 DefinitionListIterator(const DefinitionList &l) : 00347 QListIterator<Definition>(l) {} 00348 ~DefinitionListIterator() {} 00349 }; 00350 00351 #endif