commit
c1120c1df4
|
@ -2044,34 +2044,34 @@ const Function* Type::getFunction(const std::string& funcName) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool Type::hasCircularDependencies(std::set<BaseInfo>* anchestors) const
|
||||
bool Type::hasCircularDependencies(std::set<BaseInfo>* ancestors) const
|
||||
{
|
||||
std::set<BaseInfo> knownAnchestors;
|
||||
if (!anchestors) {
|
||||
anchestors=&knownAnchestors;
|
||||
std::set<BaseInfo> knownAncestors;
|
||||
if (!ancestors) {
|
||||
ancestors=&knownAncestors;
|
||||
}
|
||||
for (std::vector<BaseInfo>::const_iterator parent=derivedFrom.begin(); parent!=derivedFrom.end(); ++parent) {
|
||||
if (!parent->type)
|
||||
continue;
|
||||
else if (this==parent->type)
|
||||
return true;
|
||||
else if (anchestors->find(*parent)!=anchestors->end())
|
||||
else if (ancestors->find(*parent)!=ancestors->end())
|
||||
return true;
|
||||
else {
|
||||
anchestors->insert(*parent);
|
||||
if (parent->type->hasCircularDependencies(anchestors))
|
||||
ancestors->insert(*parent);
|
||||
if (parent->type->hasCircularDependencies(ancestors))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::findDependency(const Type* anchestor) const
|
||||
bool Type::findDependency(const Type* ancestor) const
|
||||
{
|
||||
if (this==anchestor)
|
||||
if (this==ancestor)
|
||||
return true;
|
||||
for (std::vector<BaseInfo>::const_iterator parent=derivedFrom.begin(); parent!=derivedFrom.end(); ++parent) {
|
||||
if (parent->type && parent->type->findDependency(anchestor))
|
||||
if (parent->type && parent->type->findDependency(ancestor))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -119,17 +119,17 @@ public:
|
|||
|
||||
/**
|
||||
* Check for circulare dependencies, i.e. loops within the class hierarchie
|
||||
* @param anchestors list of anchestors. For internal usage only, clients should not supply this argument.
|
||||
* @param ancestors list of ancestors. For internal usage only, clients should not supply this argument.
|
||||
* @return true if there is a circular dependency
|
||||
*/
|
||||
bool hasCircularDependencies(std::set<BaseInfo>* anchestors = nullptr) const;
|
||||
bool hasCircularDependencies(std::set<BaseInfo>* ancestors = nullptr) const;
|
||||
|
||||
/**
|
||||
* Check for dependency
|
||||
* @param anchestor potential anchestor
|
||||
* @param ancestor potential ancestor
|
||||
* @return true if there is a dependency
|
||||
*/
|
||||
bool findDependency(const Type* anchestor) const;
|
||||
bool findDependency(const Type* ancestor) const;
|
||||
};
|
||||
|
||||
/** @brief Information about a member variable. */
|
||||
|
|
Loading…
Reference in New Issue