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