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 QCString &fileName, int startLine, int startColumn, const QCString &name, ClassDef::CompoundType ct, const QCString &ref=QCString(), const QCString &fName=QCString(), 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 QCString &key)
 
ClassDefMutablegetClassMutable (const QCString &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 5452 of file classdef.cpp.

5453{
5454 BaseClassList bcl;
5455
5456 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5457 {
5458 if (cd->baseClasses().empty()) return FALSE;
5459 bcl=cd->baseClasses();
5460 }
5461 else
5462 {
5463 if (cd->subClasses().empty()) return FALSE;
5464 bcl=cd->subClasses();
5465 }
5466
5467 for (const auto &bcd : bcl)
5468 {
5469 if (bcd.classDef->isVisibleInHierarchy())
5470 {
5471 return TRUE;
5472 }
5473 }
5474 return FALSE;
5475}
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
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

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

Referenced by writeClassTreeForList(), and writeClassTreeToOutput().

◆ classHasVisibleRoot()

bool classHasVisibleRoot ( const BaseClassList & bcl)

Definition at line 5441 of file classdef.cpp.

5442{
5443 for (const auto &bcd : bcl)
5444 {
5445 const ClassDef *cd=bcd.classDef;
5446 if (cd->isVisibleInHierarchy()) return true;
5447 if (classHasVisibleRoot(cd->baseClasses())) return true;
5448 }
5449 return false;
5450}
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 5511 of file classdef.cpp.

5512{
5513 if (bcd->categoryOf()) // use class that is being extended in case of
5514 // an Objective-C category
5515 {
5516 bcd=bcd->categoryOf();
5517 }
5518 if (cd==bcd)
5519 {
5520 goto exit;
5521 }
5522 if (level==256)
5523 {
5524 err("Internal inconsistency: found class {} seem to have a recursive "
5525 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",cd->name());
5526 }
5527 else if (prot!=Protection::Private)
5528 {
5529 for (const auto &bcdi : cd->baseClasses())
5530 {
5531 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5532 if (baseProt==Protection::Private) prot=Protection::Private;
5533 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5534 }
5535 }
5536exit:
5537 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5538 return prot;
5539}
virtual ClassDef * categoryOf() const =0
Returns the class of which this is a category (Objective-C only)
virtual const QCString & name() const =0
Protection classInheritedProtectionLevel(const ClassDef *cd, const ClassDef *bcd, Protection prot, int level)
#define err(fmt,...)
Definition message.h:127
Protection
Protection level of members.
Definition types.h:26
@ Private
Definition types.h:26
@ Protected
Definition types.h:26

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

Referenced by classInheritedProtectionLevel().

◆ classVisibleInIndex()

bool classVisibleInIndex ( const ClassDef * cd)

Definition at line 5477 of file classdef.cpp.

5478{
5479 bool allExternals = Config_getBool(ALLEXTERNALS);
5480 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5481}
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 QCString & fileName,
int startLine,
int startColumn,
const QCString & name,
ClassDef::CompoundType ct,
const QCString & ref = QCString(),
const QCString & fName = QCString(),
bool isSymbol = TRUE,
bool isJavaEnum = FALSE )

Factory method to create a new ClassDef object.

Definition at line 558 of file classdef.cpp.

563{
564 return std::make_unique<ClassDefImpl>(fileName,startLine,startColumn,name,ct,ref,fName,isSymbol,isJavaEnum);
565}

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

◆ createClassDefAlias()

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

Definition at line 785 of file classdef.cpp.

786{
787 auto acd = std::make_unique<ClassDefAliasImpl>(newScope,cd);
788 //printf("cd name=%s localName=%s qualifiedName=%s qualifiedNameWith=%s displayName()=%s\n",
789 // qPrint(acd->name()),qPrint(acd->localName()),qPrint(acd->qualifiedName()),
790 // qPrint(acd->qualifiedNameWithTemplateParameters()),qPrint(acd->displayName()));
791 return acd;
792}

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

◆ getClass()

◆ getClassMutable()

◆ minClassDistance()

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

Definition at line 5487 of file classdef.cpp.

5488{
5489 const int maxInheritanceDepth = 100000;
5490 if (bcd->categoryOf()) // use class that is being extended in case of
5491 // an Objective-C category
5492 {
5493 bcd=bcd->categoryOf();
5494 }
5495 if (cd==bcd) return level;
5496 if (level==256)
5497 {
5498 warn_uncond("class {} seem to have a recursive inheritance relation!\n",cd->name());
5499 return -1;
5500 }
5501 int m=maxInheritanceDepth;
5502 for (const auto &bcdi : cd->baseClasses())
5503 {
5504 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5505 if (mc<m) m=mc;
5506 if (m<0) break;
5507 }
5508 return m;
5509}
int minClassDistance(const ClassDef *cd, const ClassDef *bcd, int level)
#define warn_uncond(fmt,...)
Definition message.h:122
const int maxInheritanceDepth
Definition util.cpp:156

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

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

◆ toClassDef() [1/3]

const ClassDef * toClassDef ( const Definition * d)

Definition at line 5406 of file classdef.cpp.

5407{
5408 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5409 {
5410 return static_cast<const ClassDef*>(d);
5411 }
5412 else
5413 {
5414 return nullptr;
5415 }
5416}
Implementation of the ClassDef interface.
Definition classdef.cpp:185

◆ toClassDef() [2/3]

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5393 of file classdef.cpp.

5394{
5395 Definition *d = toDefinition(md);
5396 if (d && typeid(*d)==typeid(ClassDefImpl))
5397 {
5398 return static_cast<ClassDef*>(d);
5399 }
5400 else
5401 {
5402 return nullptr;
5403 }
5404}
The common base class of all entity definitions found in the sources.
Definition definition.h:76
Definition * toDefinition(DefinitionMutable *dm)

References toDefinition().

◆ toClassDefMutable()

ClassDefMutable * toClassDefMutable ( Definition * d)

Definition at line 5418 of file classdef.cpp.

5419{
5420 if (d && typeid(*d)==typeid(ClassDefImpl))
5421 {
5422 return static_cast<ClassDefMutable*>(d);
5423 }
5424 else
5425 {
5426 return nullptr;
5427 }
5428}

Referenced by addClassAndNestedClasses(), addClassToContext(), addClassToGroups(), ModuleDefImpl::addClassToModule(), ModuleManager::addClassToModule(), addListReferences(), addMembersToMemberGroup(), ClassDefImpl::addMembersToTemplateInstance(), addMemberToGroups(), ClassDefImpl::addTypeConstraint(), buildCompleteMemberLists(), computeMemberReferences(), computeTemplateClassRelations(), VhdlDocGen::computeVhdlComponentRelations(), ClassDefImpl::countInheritedDecMembers(), countMembers(), createTagLessInstance(), createTemplateInstanceMembers(), ClassDefImpl::deepCopy(), distributeClassGroupRelations(), distributeMemberGroupDocumentation(), findClassRelation(), findSectionsInDocumentation(), findTagLessClasses(), 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::sortAllMembersList(), sortMemberLists(), ClassDefImpl::writeInheritedMemberDeclarations(), and writeTagFile().