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 5611 of file classdef.cpp.

5612{
5613 BaseClassList bcl;
5614
5615 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5616 {
5617 if (cd->baseClasses().empty()) return false;
5618 bcl=cd->baseClasses();
5619 }
5620 else
5621 {
5622 if (cd->subClasses().empty()) return false;
5623 bcl=cd->subClasses();
5624 }
5625
5626 for (const auto &bcd : bcl)
5627 {
5628 if (bcd.classDef->isVisibleInHierarchy())
5629 {
5630 return true;
5631 }
5632 }
5633 return false;
5634}
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 5600 of file classdef.cpp.

5601{
5602 for (const auto &bcd : bcl)
5603 {
5604 const ClassDef *cd=bcd.classDef;
5605 if (cd->isVisibleInHierarchy()) return true;
5606 if (classHasVisibleRoot(cd->baseClasses())) return true;
5607 }
5608 return false;
5609}
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 5670 of file classdef.cpp.

5671{
5672 if (bcd->categoryOf()) // use class that is being extended in case of
5673 // an Objective-C category
5674 {
5675 bcd=bcd->categoryOf();
5676 }
5677 if (cd==bcd)
5678 {
5679 goto exit;
5680 }
5681 if (level==256)
5682 {
5683 err("Internal inconsistency: found class {} seem to have a recursive "
5684 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",cd->name());
5685 }
5686 else if (prot!=Protection::Private)
5687 {
5688 for (const auto &bcdi : cd->baseClasses())
5689 {
5690 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5691 if (baseProt==Protection::Private) prot=Protection::Private;
5692 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5693 }
5694 }
5695exit:
5696 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5697 return prot;
5698}
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 5636 of file classdef.cpp.

5637{
5638 bool allExternals = Config_getBool(ALLEXTERNALS);
5639 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5640}
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 583 of file classdef.cpp.

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

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 816 of file classdef.cpp.

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

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 5646 of file classdef.cpp.

5647{
5648 const int maxInheritanceDepth = 100000;
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) return level;
5655 if (level==256)
5656 {
5657 warn_uncond("class {} seem to have a recursive inheritance relation!\n",cd->name());
5658 return -1;
5659 }
5660 int m=maxInheritanceDepth;
5661 for (const auto &bcdi : cd->baseClasses())
5662 {
5663 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5664 if (mc<m) m=mc;
5665 if (m<0) break;
5666 }
5667 return m;
5668}
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 5565 of file classdef.cpp.

5566{
5567 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5568 {
5569 return static_cast<const ClassDef*>(d);
5570 }
5571 else
5572 {
5573 return nullptr;
5574 }
5575}
Implementation of the ClassDef interface.
Definition classdef.cpp:201

◆ toClassDef() [2/3]

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5552 of file classdef.cpp.

5553{
5554 Definition *d = toDefinition(md);
5555 if (d && typeid(*d)==typeid(ClassDefImpl))
5556 {
5557 return static_cast<ClassDef*>(d);
5558 }
5559 else
5560 {
5561 return nullptr;
5562 }
5563}
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 5577 of file classdef.cpp.

5578{
5579 if (d && typeid(*d)==typeid(ClassDefImpl))
5580 {
5581 return static_cast<ClassDefMutable*>(d);
5582 }
5583 else
5584 {
5585 return nullptr;
5586 }
5587}

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().