Doxygen
Loading...
Searching...
No Matches
classdef.h File Reference

#include <src/classdef.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< ClassDef > createClassDef (const DString &fileName, int startLine, size_t 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< ClassDef > createClassDefAlias (const Definition *newScope, const ClassDef *cd)
ClassDef * toClassDef (Definition *d)
ClassDef * toClassDef (DefinitionMutable *d)
const ClassDef * toClassDef (const Definition *d)
ClassDefMutable * toClassDefMutable (Definition *d)
ClassDef * getClass (const DString &key)
ClassDefMutable * getClassMutable (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 77 of file classdef.h.

◆ ClassDefSet

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

Definition at line 91 of file classdef.h.

◆ TemplateInstanceList

Definition at line 87 of file classdef.h.

◆ TemplateNameMap

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

Definition at line 89 of file classdef.h.

Function Documentation

◆ classHasVisibleChildren()

bool classHasVisibleChildren ( const ClassDef * cd)

Definition at line 5588 of file classdef.cpp.

5589{
5590 BaseClassList bcl;
5591
5592 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5593 {
5594 if (cd->baseClasses().empty()) return false;
5595 bcl=cd->baseClasses();
5596 }
5597 else
5598 {
5599 if (cd->subClasses().empty()) return false;
5600 bcl=cd->subClasses();
5601 }
5602
5603 for (const auto &bcd : bcl)
5604 {
5605 if (bcd.classDef->isVisibleInHierarchy())
5606 {
5607 return true;
5608 }
5609 }
5610 return false;
5611}
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:77

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

Referenced by writeClassTreeForList(), and writeClassTreeToOutput().

◆ classHasVisibleRoot()

bool classHasVisibleRoot ( const BaseClassList & bcl)

Definition at line 5577 of file classdef.cpp.

5578{
5579 for (const auto &bcd : bcl)
5580 {
5581 const ClassDef *cd=bcd.classDef;
5582 if (cd->isVisibleInHierarchy()) return true;
5583 if (classHasVisibleRoot(cd->baseClasses())) return true;
5584 }
5585 return false;
5586}
A abstract class representing of a compound symbol.
Definition classdef.h:100
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 5647 of file classdef.cpp.

5648{
5649 if (bcd->categoryOf()) // use class that is being extended in case of
5650 // an Objective-C category
5651 {
5652 bcd=bcd->categoryOf();
5653 }
5654 if (cd==bcd)
5655 {
5656 goto exit;
5657 }
5658 if (level==256)
5659 {
5660 err("Internal inconsistency: found class {} seem to have a recursive "
5661 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",cd->name());
5662 }
5663 else if (prot!=Protection::Private)
5664 {
5665 for (const auto &bcdi : cd->baseClasses())
5666 {
5667 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5668 if (baseProt==Protection::Private) prot=Protection::Private;
5669 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5670 }
5671 }
5672exit:
5673 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5674 return prot;
5675}
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 5613 of file classdef.cpp.

5614{
5615 bool allExternals = Config_getBool(ALLEXTERNALS);
5616 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5617}
virtual bool isLinkable() const =0
virtual bool isLinkableInProject() const =0
#define Config_getBool(name)
Definition config.h:33

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

Referenced by writeClassTree().

◆ createClassDef()

std::unique_ptr< ClassDef > createClassDef ( const DString & fileName,
int startLine,
size_t 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 582 of file classdef.cpp.

587{
588 return std::make_unique<ClassDefImpl>(fileName,startLine,startColumn,name,ct,ref,fName,isSymbol,isJavaEnum);
589}

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

◆ createClassDefAlias()

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

Definition at line 813 of file classdef.cpp.

814{
815 auto acd = std::make_unique<ClassDefAliasImpl>(newScope,cd);
816 //printf("cd name=%s localName=%s qualifiedName=%s qualifiedNameWith=%s displayName()=%s\n",
817 // qPrint(acd->name()),qPrint(acd->localName()),qPrint(acd->qualifiedName()),
818 // qPrint(acd->qualifiedNameWithTemplateParameters()),qPrint(acd->displayName()));
819 return acd;
820}

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

◆ getClass()

◆ getClassMutable()

◆ minClassDistance()

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

Definition at line 5623 of file classdef.cpp.

5624{
5625 const int maxInheritanceDepth = 100000;
5626 if (bcd->categoryOf()) // use class that is being extended in case of
5627 // an Objective-C category
5628 {
5629 bcd=bcd->categoryOf();
5630 }
5631 if (cd==bcd) return level;
5632 if (level==256)
5633 {
5634 warn_uncond("class {} seem to have a recursive inheritance relation!\n",cd->name());
5635 return -1;
5636 }
5637 int m=maxInheritanceDepth;
5638 for (const auto &bcdi : cd->baseClasses())
5639 {
5640 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5641 if (mc<m) m=mc;
5642 if (m<0) break;
5643 }
5644 return m;
5645}
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 5542 of file classdef.cpp.

5543{
5544 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5545 {
5546 return static_cast<const ClassDef*>(d);
5547 }
5548 else
5549 {
5550 return nullptr;
5551 }
5552}
Implementation of the ClassDef interface.
Definition classdef.cpp:201

◆ toClassDef() [2/3]

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5529 of file classdef.cpp.

5530{
5531 Definition *d = toDefinition(md);
5532 if (d && typeid(*d)==typeid(ClassDefImpl))
5533 {
5534 return static_cast<ClassDef*>(d);
5535 }
5536 else
5537 {
5538 return nullptr;
5539 }
5540}
The common base class of all entity definitions found in the sources.
Definition definition.h:77
Definition * toDefinition(DefinitionMutable *dm)

References toDefinition().

◆ toClassDefMutable()

ClassDefMutable * toClassDefMutable ( Definition * d)

Definition at line 5554 of file classdef.cpp.

5555{
5556 if (d && typeid(*d)==typeid(ClassDefImpl))
5557 {
5558 return static_cast<ClassDefMutable*>(d);
5559 }
5560 else
5561 {
5562 return nullptr;
5563 }
5564}

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(), ClassDefImpl::writeInheritedMemberDeclarations(), and writeTagFile().