Doxygen
Loading...
Searching...
No Matches
classdef.h File Reference
#include <memory>
#include <vector>
#include <unordered_set>
#include "containers.h"
#include "definition.h"
#include "arguments.h"
#include "membergroup.h"
#include "configvalues.h"
Include dependency graph for classdef.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BaseClassDef
 Class that contains information about an inheritance relation. More...
struct  TemplateInstanceDef
 Class that contains information about a template instance relation. More...
class  ClassDef
 A abstract class representing of a compound symbol. More...
class  ClassDefMutable
struct  UsesClassDef
 Class that contains information about a usage relation. More...
class  UsesClassList
struct  ConstraintClassDef
 Class that contains information about a type constraint relations. More...
class  ConstraintClassList

Typedefs

using BaseClassList = std::vector<BaseClassDef>
using TemplateInstanceList = std::vector<TemplateInstanceDef>
using TemplateNameMap = std::map<std::string,int>
using ClassDefSet = std::unordered_set<const ClassDef*>

Functions

std::unique_ptr< ClassDefcreateClassDef (const DString &fileName, int startLine, int startColumn, const DString &name, ClassDef::CompoundType ct, const DString &ref=DString(), const DString &fName=DString(), bool isSymbol=true, bool isJavaEnum=false)
 Factory method to create a new ClassDef object.
std::unique_ptr< ClassDefcreateClassDefAlias (const Definition *newScope, const ClassDef *cd)
ClassDeftoClassDef (Definition *d)
ClassDeftoClassDef (DefinitionMutable *d)
const ClassDeftoClassDef (const Definition *d)
ClassDefMutabletoClassDefMutable (Definition *d)
ClassDefgetClass (const DString &key)
ClassDefMutablegetClassMutable (const DString &key)
bool classHasVisibleRoot (const BaseClassList &bcl)
bool classHasVisibleChildren (const ClassDef *cd)
bool classVisibleInIndex (const ClassDef *cd)
int minClassDistance (const ClassDef *cd, const ClassDef *bcd, int level=0)
Protection classInheritedProtectionLevel (const ClassDef *cd, const ClassDef *bcd, Protection prot=Protection::Public, int level=0)

Typedef Documentation

◆ BaseClassList

using BaseClassList = std::vector<BaseClassDef>

Definition at line 81 of file classdef.h.

◆ ClassDefSet

using ClassDefSet = std::unordered_set<const ClassDef*>

Definition at line 95 of file classdef.h.

◆ TemplateInstanceList

Definition at line 91 of file classdef.h.

◆ TemplateNameMap

using TemplateNameMap = std::map<std::string,int>

Definition at line 93 of file classdef.h.

Function Documentation

◆ classHasVisibleChildren()

bool classHasVisibleChildren ( const ClassDef * cd)

Definition at line 5518 of file classdef.cpp.

5519{
5520 BaseClassList bcl;
5521
5522 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5523 {
5524 if (cd->baseClasses().empty()) return false;
5525 bcl=cd->baseClasses();
5526 }
5527 else
5528 {
5529 if (cd->subClasses().empty()) return false;
5530 bcl=cd->subClasses();
5531 }
5532
5533 for (const auto &bcd : bcl)
5534 {
5535 if (bcd.classDef->isVisibleInHierarchy())
5536 {
5537 return true;
5538 }
5539 }
5540 return false;
5541}
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
virtual const BaseClassList & subClasses() const =0
Returns the list of sub classes that directly derive from this class.
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
std::vector< BaseClassDef > BaseClassList
Definition classdef.h:81

References ClassDef::baseClasses(), classHasVisibleChildren(), Definition::getLanguage(), and ClassDef::subClasses().

Referenced by classHasVisibleChildren(), writeClassTreeForList(), and writeClassTreeToOutput().

◆ classHasVisibleRoot()

bool classHasVisibleRoot ( const BaseClassList & bcl)

Definition at line 5507 of file classdef.cpp.

5508{
5509 for (const auto &bcd : bcl)
5510 {
5511 const ClassDef *cd=bcd.classDef;
5512 if (cd->isVisibleInHierarchy()) return true;
5513 if (classHasVisibleRoot(cd->baseClasses())) return true;
5514 }
5515 return false;
5516}
A abstract class representing of a compound symbol.
Definition classdef.h:104
virtual bool isVisibleInHierarchy() const =0
the class is visible in a class diagram, or class hierarchy
bool classHasVisibleRoot(const BaseClassList &bcl)

References ClassDef::baseClasses(), classHasVisibleRoot(), and ClassDef::isVisibleInHierarchy().

Referenced by DotGfxHierarchyTable::addClassList(), DotGfxHierarchyTable::addHierarchy(), classHasVisibleRoot(), countClassesInTreeList(), writeClassTreeForList(), and writeClassTreeToOutput().

◆ classInheritedProtectionLevel()

Protection classInheritedProtectionLevel ( const ClassDef * cd,
const ClassDef * bcd,
Protection prot = Protection::Public,
int level = 0 )

Definition at line 5577 of file classdef.cpp.

5578{
5579 if (bcd->categoryOf()) // use class that is being extended in case of
5580 // an Objective-C category
5581 {
5582 bcd=bcd->categoryOf();
5583 }
5584 if (cd==bcd)
5585 {
5586 goto exit;
5587 }
5588 if (level==256)
5589 {
5590 err("Internal inconsistency: found class {} seem to have a recursive "
5591 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",cd->name());
5592 }
5593 else if (prot!=Protection::Private)
5594 {
5595 for (const auto &bcdi : cd->baseClasses())
5596 {
5597 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5598 if (baseProt==Protection::Private) prot=Protection::Private;
5599 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5600 }
5601 }
5602exit:
5603 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5604 return prot;
5605}
virtual ClassDef * categoryOf() const =0
Returns the class of which this is a category (Objective-C only).
virtual const DString & name() const =0
Protection classInheritedProtectionLevel(const ClassDef *cd, const ClassDef *bcd, Protection prot, int level)
#define err(fmt,...)
Definition message.h:127
Protection
Definition types.h:32

References ClassDef::baseClasses(), ClassDef::categoryOf(), classInheritedProtectionLevel(), err, and Definition::name().

Referenced by classInheritedProtectionLevel().

◆ classVisibleInIndex()

bool classVisibleInIndex ( const ClassDef * cd)

Definition at line 5543 of file classdef.cpp.

5544{
5545 bool allExternals = Config_getBool(ALLEXTERNALS);
5546 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5547}
virtual bool isLinkable() const =0
virtual bool isLinkableInProject() const =0
#define Config_getBool(name)
Definition config.h:33

References classVisibleInIndex(), Config_getBool, Definition::isLinkable(), and Definition::isLinkableInProject().

Referenced by classVisibleInIndex(), and writeClassTree().

◆ createClassDef()

std::unique_ptr< ClassDef > createClassDef ( const DString & fileName,
int startLine,
int startColumn,
const DString & name,
ClassDef::CompoundType ct,
const DString & ref = DString(),
const DString & fName = DString(),
bool isSymbol = true,
bool isJavaEnum = false )

Factory method to create a new ClassDef object.

Definition at line 573 of file classdef.cpp.

578{
579 return std::make_unique<ClassDefImpl>(fileName,startLine,startColumn,name,ct,ref,fName,isSymbol,isJavaEnum);
580}

References createClassDef().

Referenced by addClassToContext(), createClassDef(), createTagLessInstance(), findClassRelation(), findUsedClassesForClass(), findUsingDeclarations(), and ClassDefMutable::setPrimaryConstructorParams().

◆ createClassDefAlias()

std::unique_ptr< ClassDef > createClassDefAlias ( const Definition * newScope,
const ClassDef * cd )

Definition at line 799 of file classdef.cpp.

800{
801 auto acd = std::make_unique<ClassDefAliasImpl>(newScope,cd);
802 //printf("cd name=%s localName=%s qualifiedName=%s qualifiedNameWith=%s displayName()=%s\n",
803 // qPrint(acd->name()),qPrint(acd->localName()),qPrint(acd->qualifiedName()),
804 // qPrint(acd->qualifiedNameWithTemplateParameters()),qPrint(acd->displayName()));
805 return acd;
806}

References createClassDefAlias().

Referenced by createClassDefAlias(), ClassDefAliasImpl::deepCopy(), findUsingDeclImports(), resolveClassNestingRelations(), and ClassDefMutable::setPrimaryConstructorParams().

◆ getClass()

◆ getClassMutable()

◆ minClassDistance()

int minClassDistance ( const ClassDef * cd,
const ClassDef * bcd,
int level = 0 )

Definition at line 5553 of file classdef.cpp.

5554{
5555 const int maxInheritanceDepth = 100000;
5556 if (bcd->categoryOf()) // use class that is being extended in case of
5557 // an Objective-C category
5558 {
5559 bcd=bcd->categoryOf();
5560 }
5561 if (cd==bcd) return level;
5562 if (level==256)
5563 {
5564 warn_uncond("class {} seem to have a recursive inheritance relation!\n",cd->name());
5565 return -1;
5566 }
5567 int m=maxInheritanceDepth;
5568 for (const auto &bcdi : cd->baseClasses())
5569 {
5570 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5571 if (mc<m) m=mc;
5572 if (m<0) break;
5573 }
5574 return m;
5575}
int minClassDistance(const ClassDef *cd, const ClassDef *bcd, int level)
#define warn_uncond(fmt,...)
Definition message.h:122

References ClassDef::baseClasses(), ClassDef::categoryOf(), minClassDistance(), Definition::name(), and warn_uncond.

Referenced by ClassDefImpl::getMemberByName(), and minClassDistance().

◆ toClassDef() [1/3]

const ClassDef * toClassDef ( const Definition * d)

Definition at line 5472 of file classdef.cpp.

5473{
5474 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5475 {
5476 return static_cast<const ClassDef*>(d);
5477 }
5478 else
5479 {
5480 return nullptr;
5481 }
5482}
Implementation of the ClassDef interface.
Definition classdef.cpp:197

References toClassDef().

◆ toClassDef() [2/3]

ClassDef * toClassDef ( Definition * d)

Definition at line 5447 of file classdef.cpp.

5448{
5449 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5450 {
5451 return static_cast<ClassDef*>(d);
5452 }
5453 else
5454 {
5455 return nullptr;
5456 }
5457}

References toClassDef().

Referenced by DocSets::addIndexItem(), ClassDefImpl::addInnerCompound(), NamespaceDefImpl::addInnerCompound(), MemberDefImpl::addListReference(), definitionToName(), findMemberLink(), findModuleDef(), findTagLessClasses(), findUsingDeclImports(), SymbolResolver::Private::followPath(), generateClassMemberLink(), generateClassOrGlobalLink(), generateClassOrGlobalLink(), FTVHelp::Private::generateTree(), ClassDefAliasImpl::getCdAlias(), getDefs(), SymbolResolver::Private::getResolvedSymbol(), SymbolResolver::Private::getResolvedType(), SymbolResolver::Private::getResolvedTypeRec(), ClassDefImpl::getTemplateParameterLists(), SymbolResolver::Private::isAccessibleFrom(), SymbolResolver::Private::isAccessibleFromWithExpScope(), makeQualifiedNameWithTemplateParameters(), MemberDefImpl::moveTo(), DefinitionImpl::navigationPathAsString(), scopeIsTemplate(), searchTemplateSpecs(), SearchIndex::setCurrentDoc(), ClassDefMutable::setPrimaryConstructorParams(), toClassDef(), toClassDef(), toClassDef(), updateCallContextForSmartPointer(), writeDefArgumentList(), writeJavasScriptSearchDataPage(), MemberDefImpl::writeMemberDocSimple(), writeObjCMethodCall(), MemberList::writeSimpleDocumentation(), and VhdlDocGen::writeVHDLTypeDocumentation().

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5459 of file classdef.cpp.

5460{
5461 Definition *d = toDefinition(md);
5462 if (d && typeid(*d)==typeid(ClassDefImpl))
5463 {
5464 return static_cast<ClassDef*>(d);
5465 }
5466 else
5467 {
5468 return nullptr;
5469 }
5470}
The common base class of all entity definitions found in the sources.
Definition definition.h:77
Definition * toDefinition(DefinitionMutable *dm)

References toClassDef(), and toDefinition().

◆ toClassDefMutable()

ClassDefMutable * toClassDefMutable ( Definition * d)

Definition at line 5484 of file classdef.cpp.

5485{
5486 if (d && typeid(*d)==typeid(ClassDefImpl))
5487 {
5488 return static_cast<ClassDefMutable*>(d);
5489 }
5490 else
5491 {
5492 return nullptr;
5493 }
5494}

References toClassDefMutable().

Referenced by addClassAndNestedClasses(), addClassToContext(), addClassToGroups(), ModuleDefImpl::addClassToModule(), ModuleManager::addClassToModule(), addMembersToMemberGroup(), ClassDefImpl::addMembersToTemplateInstance(), addMemberToGroups(), ClassDefImpl::addTypeConstraint(), applyToAllDefinitions(), buildCompleteMemberLists(), computeMemberReferences(), computeTemplateClassRelations(), VhdlDocGen::computeVhdlComponentRelations(), ClassDefImpl::countInheritedDecMembers(), countMembers(), createTagLessInstance(), createTemplateInstanceMembers(), ClassDefImpl::deepCopy(), distributeClassGroupRelations(), distributeMemberGroupDocumentation(), findClassRelation(), findSectionsInDocumentation(), findTemplateInstanceRelation(), findUsedClassesForClass(), findUsingDeclarations(), findUsingDeclImports(), generateClassDocs(), generateClassOrGlobalLink(), generateNamespaceClassDocs(), MemberDefImpl::getClassDefMutable(), getClassMutable(), ClassDefImpl::hideDerivedVariablesInPython(), insertMemberAlias(), ClassDefImpl::insertTemplateInstance(), ClassDefImpl::insertUsedFile(), ClassDefImpl::internalInsertMember(), mergeCategories(), ClassDefImpl::mergeCategory(), ClassDefImpl::mergeMembers(), ClassDefImpl::mergeMembersFromBaseClasses(), SymbolResolver::resolveClassMutable(), resolveClassNestingRelations(), setAnonymousEnumType(), ClassDefImpl::setGroupDefForAllMembers(), ClassDefMutable::setPrimaryConstructorParams(), sortMemberLists(), toClassDefMutable(), ClassDefImpl::writeInheritedMemberDeclarations(), and writeTagFile().