[Kst] branches/work/kst/1.5/kst/src/libkstmath
Andrew Walker
arwalker at sumusltd.com
Fri May 11 23:39:09 CEST 2007
SVN commit 663644 by arwalker:
CCBUG:129068 Add code for recursion detection
M +51 -3 kstdataobject.cpp
M +2 -1 kstdataobject.h
--- branches/work/kst/1.5/kst/src/libkstmath/kstdataobject.cpp #663643:663644
@@ -723,11 +723,11 @@
for (; scalarDictIter.current(); ++scalarDictIter) {
if (scalarDictIter.current() == k.data()) {
return true;
- }
+ }
}
}
}
-
+
for (KstScalarMap::Iterator j = obj->outputScalars().begin(); j != obj->outputScalars().end(); ++j) {
for (KstScalarMap::ConstIterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) {
if (j.data() == k.data()) {
@@ -735,7 +735,7 @@
}
}
}
-
+
for (KstStringMap::Iterator j = obj->outputStrings().begin(); j != obj->outputStrings().end(); ++j) {
for (KstStringMap::ConstIterator k = _inputStrings.begin(); k != _inputStrings.end(); ++k) {
if (j.data() == k.data()) {
@@ -748,5 +748,53 @@
}
+bool KstDataObject::recursion(KstDataObjectDataObjectMap& objectsToCheck) {
+ KstDataObjectDataObjectMap objectsToFollow;
+ bool recurses = false;
+
+ for (KstDataObjectList::ConstIterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) {
+ if ((*it)->uses(this)) {
+ if (objectsToCheck.find(*it) == objectsToCheck.end()) {
+ objectsToFollow.insert(*it, *it);
+ } else {
+ recurses = true;
+
+ break;
+ }
+ }
+ }
+
+ if (!recurses) {
+ for (KstDataObjectDataObjectMap::Iterator j = objectsToFollow.begin(); j != objectsToFollow.end(); ++j) {
+ if ((*j)->recursion(objectsToCheck)) {
+ recurses = true;
+
+ break;
+ }
+ objectsToCheck.insert(*j, *j);
+ }
+ }
+
+ return recurses;
+}
+
+
+bool KstDataObject::recursion() {
+ bool recurses = false;
+
+ if (uses(this)) {
+ recurses = true;
+ } else {
+ KstDataObjectDataObjectMap objectsToCheck;
+
+ objectsToCheck.insert(this, this);
+
+ recurses = recursion(objectsToCheck);
+ }
+
+ return recurses;
+}
+
+
#include "kstdataobject.moc"
// vim: ts=2 sw=2 et
--- branches/work/kst/1.5/kst/src/libkstmath/kstdataobject.h #663643:663644
@@ -55,7 +55,6 @@
virtual QString propertyString() const = 0;
virtual const QString& type() const { return _type; }
virtual Kind kind() const { return Generic; }
-
virtual int sampleCount() const { return 0; }
// If you use these, you must lock() and unlock() the object as long as you
@@ -106,6 +105,8 @@
virtual void replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix);
virtual bool uses(KstObjectPtr p) const;
+ virtual bool recursion(KstDataObjectDataObjectMap& objectsToCheck);
+ virtual bool recursion();
//These are generally only valid for plugins...
const QString& name() const { return _name; }
More information about the Kst
mailing list