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

5443{
5444 BaseClassList bcl;
5445
5446 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5447 {
5448 if (cd->baseClasses().empty()) return FALSE;
5449 bcl=cd->baseClasses();
5450 }
5451 else
5452 {
5453 if (cd->subClasses().empty()) return FALSE;
5454 bcl=cd->subClasses();
5455 }
5456
5457 for (const auto &bcd : bcl)
5458 {
5459 if (bcd.classDef->isVisibleInHierarchy())
5460 {
5461 return TRUE;
5462 }
5463 }
5464 return FALSE;
5465}
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 5431 of file classdef.cpp.

5432{
5433 for (const auto &bcd : bcl)
5434 {
5435 const ClassDef *cd=bcd.classDef;
5436 if (cd->isVisibleInHierarchy()) return true;
5437 if (classHasVisibleRoot(cd->baseClasses())) return true;
5438 }
5439 return false;
5440}
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 5501 of file classdef.cpp.

5502{
5503 if (bcd->categoryOf()) // use class that is being extended in case of
5504 // an Objective-C category
5505 {
5506 bcd=bcd->categoryOf();
5507 }
5508 if (cd==bcd)
5509 {
5510 goto exit;
5511 }
5512 if (level==256)
5513 {
5514 err("Internal inconsistency: found class {} seem to have a recursive "
5515 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",cd->name());
5516 }
5517 else if (prot!=Protection::Private)
5518 {
5519 for (const auto &bcdi : cd->baseClasses())
5520 {
5521 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5522 if (baseProt==Protection::Private) prot=Protection::Private;
5523 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5524 }
5525 }
5526exit:
5527 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5528 return prot;
5529}
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 5467 of file classdef.cpp.

5468{
5469 bool allExternals = Config_getBool(ALLEXTERNALS);
5470 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5471}
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 5477 of file classdef.cpp.

5478{
5479 const int maxInheritanceDepth = 100000;
5480 if (bcd->categoryOf()) // use class that is being extended in case of
5481 // an Objective-C category
5482 {
5483 bcd=bcd->categoryOf();
5484 }
5485 if (cd==bcd) return level;
5486 if (level==256)
5487 {
5488 warn_uncond("class {} seem to have a recursive inheritance relation!\n",cd->name());
5489 return -1;
5490 }
5491 int m=maxInheritanceDepth;
5492 for (const auto &bcdi : cd->baseClasses())
5493 {
5494 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5495 if (mc<m) m=mc;
5496 if (m<0) break;
5497 }
5498 return m;
5499}
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 5396 of file classdef.cpp.

5397{
5398 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5399 {
5400 return static_cast<const ClassDef*>(d);
5401 }
5402 else
5403 {
5404 return nullptr;
5405 }
5406}
Implementation of the ClassDef interface.
Definition classdef.cpp:185

◆ toClassDef() [2/3]

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5383 of file classdef.cpp.

5384{
5385 Definition *d = toDefinition(md);
5386 if (d && typeid(*d)==typeid(ClassDefImpl))
5387 {
5388 return static_cast<ClassDef*>(d);
5389 }
5390 else
5391 {
5392 return nullptr;
5393 }
5394}
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 5408 of file classdef.cpp.

5409{
5410 if (d && typeid(*d)==typeid(ClassDefImpl))
5411 {
5412 return static_cast<ClassDefMutable*>(d);
5413 }
5414 else
5415 {
5416 return nullptr;
5417 }
5418}

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