/****************************************************************************** * * * * Copyright (C) 1997-2001 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #ifndef CLASSDEF_H #define CLASSDEF_H #include "qtbc.h" #include #include #include #include "entry.h" #include "memberlist.h" #include "definition.h" class MemberDict; class ClassList; class ClassSDict; class OutputList; class FileDef; class BaseClassList; class NamespaceDef; class MemberDef; class ExampleSDict; class MemberNameInfoSDict; class UsesClassDict; class MemberGroupList; class MemberGroupDict; class QTextStream; class PackageDef; class GroupDef; class StringDict; struct IncludeInfo; /*! \brief This class contains all information about a compound. * * A compound can be a class, struct, union, interface, or exception. * \note This class should be renamed to CompoundDef */ class ClassDef : public Definition { public: /*! \name Public API * \{ */ /*! The various compound types */ enum CompoundType { Class=Entry::CLASS_SEC, Struct=Entry::STRUCT_SEC, Union=Entry::UNION_SEC, Interface=Entry::INTERFACE_SEC, Exception=Entry::EXCEPTION_SEC }; DefType definitionType() { return TypeClass; } QCString getOutputFileBase() const; QCString getFileBase() const; QCString getSourceFileBase() const; bool hasDocumentation() const; /*! Returns the name as it is appears in the documentation */ QCString displayName() const; /*! Returns the type of compound this is */ CompoundType compoundType() const { return m_compType; } /*! Returns the type of compound as a string */ QCString compoundTypeString() const; /*! Returns the list of base classes from which this class directly * inherits. */ BaseClassList *baseClasses() { return m_inherits; } /*! Returns the list of sub classes that directly inherit from this class */ BaseClassList *subClasses() { return m_inheritedBy; } /*! Returns a dictionary of all members. This includes any inherited * members. Members are sorted alphabetically. */ MemberNameInfoSDict *memberNameInfoSDict() { return m_allMemberNameInfoSDict; } void writeDocumentation(OutputList &ol); void writeMemberList(OutputList &ol); void writeDeclaration(OutputList &ol,MemberDef *md,bool inGroup); /*! Return the protection level (Public,Protected,Private) in which * this compound was found. */ Protection protection() const { return m_prot; } /*! returns TRUE iff a link is possible to an item within this project. */ bool isLinkableInProject(); /*! return TRUE iff a link to this class is possible (either within * this project, or as a cross-reference to another project). */ bool isLinkable() { return isLinkableInProject() || isReference(); } /*! the class is visible in a class diagram, or class hierarchy */ bool isVisibleInHierarchy(); /*! Returns the template arguments of this class * Will return 0 if not applicable. */ ArgumentList *templateArguments() const { return m_tempArgs; } /*! Returns the template arguments that this nested class "inherits" * from its outer class (doxygen assumes there is only one!). * Will return 0 if not applicable. */ ArgumentList *outerTemplateArguments() const; /*! Returns the namespace this compound is in, or 0 if it has a global * scope. */ NamespaceDef *getNamespaceDef() { return m_nspace; } /*! Returns the file in which this compound's definition can be found. * Should not return 0 (but it might be a good idea to check anyway). */ FileDef *getFileDef() const { return m_fileDef; } /*! Returns the Java package this class is in or 0 if not applicable. */ PackageDef *packageDef() const; /*! Returns TRUE iff \a bcd is a direct or indirect base class of this * class. This function will recusively traverse all branches of the * inheritance tree. */ bool isBaseClass(ClassDef *bcd); /*! Is this an artificial class that is the template argument of * a class. If so the argument number is returned, otherwise -1 * is returned. */ int isTemplateBaseClass() const { return m_isTemplBaseClass; } UsesClassDict *usedImplementationClasses() const { return m_usesImplClassDict; } UsesClassDict *usedInterfaceClasses() const { return m_usesIntfClassDict; } virtual Definition *findInnerCompound(const char *name); /* member lists by protection */ MemberList pubMembers; MemberList proMembers; MemberList priMembers; MemberList pubStaticMembers; MemberList proStaticMembers; MemberList priStaticMembers; MemberList pubSlots; MemberList proSlots; MemberList priSlots; MemberList pubAttribs; MemberList proAttribs; MemberList priAttribs; MemberList pubStaticAttribs; MemberList proStaticAttribs; MemberList priStaticAttribs; MemberList pubTypes; MemberList proTypes; MemberList priTypes; MemberList related; MemberList signals; MemberList friends; MemberList dcopMethods; MemberList properties; /* member list by types */ MemberList constructors; MemberList typedefMembers; MemberList enumMembers; MemberList enumValMembers; MemberList functionMembers; MemberList relatedMembers; MemberList variableMembers; MemberList propertyMembers; /*! \} Public API */ /*! \name Doxygen internal API * \{ */ void insertBaseClass(ClassDef *,const char *name,Protection p,Specifier s,const char *t=0); void insertSubClass(ClassDef *,Protection p,Specifier s,const char *t=0); void setIncludeFile(FileDef *fd,const char *incName,bool local); void insertMember(MemberDef *); void insertUsedFile(const char *); void computeAnchors(); void computeMemberGroups(); void setAnchor(MemberDef *); void dumpMembers(); bool addExample(const char *anchor,const char *name, const char *file); void addMembersToMemberGroup(); void distributeMemberGroupDocumentation(); void setNamespace(NamespaceDef *nd) { m_nspace = nd; } void setTemplateArguments(ArgumentList *al); void mergeMembers(); void setFileDef(FileDef *fd) { m_fileDef=fd; } void determineImplUsageRelation(); void determineIntfUsageRelation(); void setSubGrouping(bool enabled) { m_subGrouping = enabled; } void setProtection(Protection p) { m_prot=p; } void setGroupDefForAllMembers(GroupDef *g); void addInnerCompound(Definition *d); void setIsTemplateBaseClass(int num) { m_isTemplBaseClass = num; } void initTemplateMapping(); void setTemplateArgumentMapping(const char *formal,const char *actual); QCString getTemplateArgumentMapping(const char *formal) const; /*! Creates a new compound definition. * \param outerScope class, file or namespace in which this class is * defined. * \param fileName full path and file name in which this compound was * found. * \param startLine line number where the definition of this compound * starts. * \param name the name of this compound (including scope) * \param ct the kind of Compound * \param ref the tag file from which this compound is extracted * or 0 if the compound doesn't come from a tag file * \param fName the file name as found in the tag file. * This overwrites the file that doxygen normally * generates based on the compound type & name. */ ClassDef(const char *fileName,int startLine, const char *name,CompoundType ct, const char *ref=0,const char *fName=0); /*! Destroys a compound definition. */ ~ClassDef(); bool visited; protected: void addUsedInterfaceClasses(MemberDef *md,const char *typeStr); bool hasExamples(); bool hasNonReferenceSuperClass(); /*! \} Interal API */ private: /*! file name that forms the base for the output file containing the * class documentation. For compatibility with Qt (e.g. links via tag * files) this name cannot be derived from the class name directly. */ QCString m_fileName; /*! Include information about the header file should be included * in the documentation. 0 by default, set by setIncludeFile(). */ IncludeInfo *m_incInfo; /*! file name that forms the base for the "list of members" for this * class. */ QCString m_memListFileName; /*! Bare name of the class without any scoping prefixes * (like for nested classes and classes inside namespaces) */ QCString m_scopelessName; /*! List of base class (or super-classes) from which this class derives * directly. */ BaseClassList *m_inherits; /*! List of sub-classes that directly derive from this class */ BaseClassList *m_inheritedBy; /*! Namespace this class is part of * (this is the inner most namespace in case of nested namespaces) */ NamespaceDef *m_nspace; /*! File this class is defined in */ FileDef *m_fileDef; /*! List of all members (including inherited members) */ MemberNameInfoSDict *m_allMemberNameInfoSDict; /*! Template arguments of this class */ ArgumentList *m_tempArgs; /*! Files that were used for generating the class documentation. */ QStrList m_files; /*! Examples that use this class */ ExampleSDict *m_exampleSDict; /*! Holds the kind of "class" this is. */ CompoundType m_compType; /*! The protection level in which this class was found. * Typically Public, but for nested classes this can also be Protected * or Private. */ Protection m_prot; /*! Does this class group its user-grouped members * as a sub-section of the normal (public/protected/..) * groups? */ bool m_subGrouping; /*! The inner classes contained in this class. Will be 0 if there are * no inner classes. */ ClassSDict *m_innerClasses; /* user defined member groups */ MemberGroupList *m_memberGroupList; MemberGroupDict *m_memberGroupDict; /* classes for the collaboration diagram */ UsesClassDict *m_usesImplClassDict; UsesClassDict *m_usesIntfClassDict; /*! Is this a class that exists because of template class that * inherited one of it's template arguments. If so that this * variable indicate the template argument number, otherwise * this is -1 */ int m_isTemplBaseClass; /*! A mapping used by template classes, which maps formal * template arguments to their actual instantiations. * This is used while generating inheritance graphs. */ StringDict *m_templateMapping; }; /*! \brief Class that contains information about a usage relation. */ struct UsesClassDef { UsesClassDef(ClassDef *cd) : classDef(cd) { accessors = new QDict(17); containment = TRUE; } ~UsesClassDef() { delete accessors; } void addAccessor(const char *s) { if (accessors->find(s)==0) { accessors->insert(s,(void *)666); } } /*! Class definition that this relation uses. */ ClassDef *classDef; /*! Dictionary of member variable names that form the edge labels of the * usage relation. */ QDict *accessors; /*! Template arguments used for the base class */ QCString templSpecifiers; bool containment; }; /*! \brief Dictionary of usage relations. */ class UsesClassDict : public QDict { public: UsesClassDict(int size) : QDict(size) {} ~UsesClassDict() {} }; /*! \brief Iterator class to iterate over a dictionary of usage relations. */ class UsesClassDictIterator : public QDictIterator { public: UsesClassDictIterator(const QDict &d) : QDictIterator(d) {} ~UsesClassDictIterator() {} }; /*! \brief Class that contains information about an inheritance relation. */ struct BaseClassDef { BaseClassDef(ClassDef *cd,const char *n,Protection p, Specifier v,const char *t) : classDef(cd), usedName(n), prot(p), virt(v), templSpecifiers(t) {} /*! Class definition that this relation inherits from. */ ClassDef *classDef; /*! name used in the inheritance list * (may be a typedef name instead of the class name) */ QCString usedName; /*! Protection level of the inheritance relation: * Public, Protected, or Private */ Protection prot; /*! Virtualness of the inheritance relation: * Normal, or Virtual */ Specifier virt; /*! Template arguments used for the base class */ QCString templSpecifiers; }; /*! \brief list of base classes * * The classes are alphabetically sorted on name if inSort() is used. */ class BaseClassList : public QList { public: ~BaseClassList() {} int compareItems(GCI item1,GCI item2) { ClassDef *c1=((BaseClassDef *)item1)->classDef; ClassDef *c2=((BaseClassDef *)item2)->classDef; if (c1==0 || c2==0) return FALSE; else return stricmp(c1->name(),c2->name()); } }; /*! \brief Iterator for a list of base classes */ class BaseClassListIterator : public QListIterator { public: BaseClassListIterator(const BaseClassList &bcl) : QListIterator(bcl) {} }; #endif