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

5384{
5385 BaseClassList bcl;
5386
5387 if (cd->getLanguage()==SrcLangExt::VHDL) // reverse baseClass/subClass relation
5388 {
5389 if (cd->baseClasses().empty()) return FALSE;
5390 bcl=cd->baseClasses();
5391 }
5392 else
5393 {
5394 if (cd->subClasses().empty()) return FALSE;
5395 bcl=cd->subClasses();
5396 }
5397
5398 for (const auto &bcd : bcl)
5399 {
5400 if (bcd.classDef->isVisibleInHierarchy())
5401 {
5402 return TRUE;
5403 }
5404 }
5405 return FALSE;
5406}
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 5372 of file classdef.cpp.

5373{
5374 for (const auto &bcd : bcl)
5375 {
5376 const ClassDef *cd=bcd.classDef;
5377 if (cd->isVisibleInHierarchy()) return true;
5378 if (classHasVisibleRoot(cd->baseClasses())) return true;
5379 }
5380 return false;
5381}
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 5443 of file classdef.cpp.

5444{
5445 if (bcd->categoryOf()) // use class that is being extended in case of
5446 // an Objective-C category
5447 {
5448 bcd=bcd->categoryOf();
5449 }
5450 if (cd==bcd)
5451 {
5452 goto exit;
5453 }
5454 if (level==256)
5455 {
5456 err("Internal inconsistency: found class %s seem to have a recursive "
5457 "inheritance relation! Please send a bug report to doxygen@gmail.com\n",qPrint(cd->name()));
5458 }
5459 else if (prot!=Protection::Private)
5460 {
5461 for (const auto &bcdi : cd->baseClasses())
5462 {
5463 Protection baseProt = classInheritedProtectionLevel(bcdi.classDef,bcd,bcdi.prot,level+1);
5464 if (baseProt==Protection::Private) prot=Protection::Private;
5465 else if (baseProt==Protection::Protected) prot=Protection::Protected;
5466 }
5467 }
5468exit:
5469 //printf("classInheritedProtectionLevel(%s,%s)=%d\n",qPrint(cd->name()),qPrint(bcd->name()),prot);
5470 return prot;
5471}
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:84
const char * qPrint(const char *s)
Definition qcstring.h:672
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, Protected, and qPrint().

Referenced by classInheritedProtectionLevel().

◆ classVisibleInIndex()

bool classVisibleInIndex ( const ClassDef * cd)

Definition at line 5408 of file classdef.cpp.

5409{
5410 bool allExternals = Config_getBool(ALLEXTERNALS);
5411 return (allExternals && cd->isLinkable()) || cd->isLinkableInProject();
5412}
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 412 of file classdef.cpp.

417{
418 return std::make_unique<ClassDefImpl>(fileName,startLine,startColumn,name,ct,ref,fName,isSymbol,isJavaEnum);
419}

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

643{
644 auto acd = std::make_unique<ClassDefAliasImpl>(newScope,cd);
645 //printf("cd name=%s localName=%s qualifiedName=%s qualifiedNameWith=%s displayName()=%s\n",
646 // qPrint(acd->name()),qPrint(acd->localName()),qPrint(acd->qualifiedName()),
647 // qPrint(acd->qualifiedNameWithTemplateParameters()),qPrint(acd->displayName()));
648 return acd;
649}

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

5419{
5420 const int maxInheritanceDepth = 100000;
5421 if (bcd->categoryOf()) // use class that is being extended in case of
5422 // an Objective-C category
5423 {
5424 bcd=bcd->categoryOf();
5425 }
5426 if (cd==bcd) return level;
5427 if (level==256)
5428 {
5429 warn_uncond("class %s seem to have a recursive "
5430 "inheritance relation!\n",qPrint(cd->name()));
5431 return -1;
5432 }
5433 int m=maxInheritanceDepth;
5434 for (const auto &bcdi : cd->baseClasses())
5435 {
5436 int mc=minClassDistance(bcdi.classDef,bcd,level+1);
5437 if (mc<m) m=mc;
5438 if (m<0) break;
5439 }
5440 return m;
5441}
int minClassDistance(const ClassDef *cd, const ClassDef *bcd, int level)
#define warn_uncond(fmt,...)
Definition message.h:79
const int maxInheritanceDepth
Definition util.cpp:156

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

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

◆ toClassDef() [1/3]

const ClassDef * toClassDef ( const Definition * d)

Definition at line 5337 of file classdef.cpp.

5338{
5339 if (d && (typeid(*d)==typeid(ClassDefImpl) || typeid(*d)==typeid(ClassDefAliasImpl)))
5340 {
5341 return static_cast<const ClassDef*>(d);
5342 }
5343 else
5344 {
5345 return nullptr;
5346 }
5347}
Implementation of the ClassDef interface.
Definition classdef.cpp:186

◆ toClassDef() [2/3]

◆ toClassDef() [3/3]

ClassDef * toClassDef ( DefinitionMutable * d)

Definition at line 5324 of file classdef.cpp.

5325{
5326 Definition *d = toDefinition(md);
5327 if (d && typeid(*d)==typeid(ClassDefImpl))
5328 {
5329 return static_cast<ClassDef*>(d);
5330 }
5331 else
5332 {
5333 return nullptr;
5334 }
5335}
The common base class of all entity definitions found in the sources.
Definition definition.h:76
Definition * toDefinition(DefinitionMutable *dm)

References DefinitionMutable::toDefinition.

◆ toClassDefMutable()

ClassDefMutable * toClassDefMutable ( Definition * d)

Definition at line 5349 of file classdef.cpp.

5350{
5351 if (d && typeid(*d)==typeid(ClassDefImpl))
5352 {
5353 return static_cast<ClassDefMutable*>(d);
5354 }
5355 else
5356 {
5357 return nullptr;
5358 }
5359}

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(), insertMemberAlias(), ClassDefImpl::insertTemplateInstance(), ClassDefImpl::insertUsedFile(), mergeCategories(), ClassDefImpl::mergeCategory(), ClassDefImpl::mergeMembers(), ClassDefImpl::mergeMembersFromBaseClasses(), SymbolResolver::resolveClassMutable(), resolveClassNestingRelations(), setAnonymousEnumType(), ClassDefImpl::setGroupDefForAllMembers(), ClassDefMutable::sortAllMembersList(), sortMemberLists(), ClassDefImpl::writeInheritedMemberDeclarations(), and writeTagFile().