diff --git a/Solver/function.cpp b/Solver/function.cpp index daf95950717933280dcd62dba21f79eaddf309f9..742d0221c1fbc05e760c75a4fc4cfb00c49bcc99 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -71,14 +71,18 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller) r = it->second; for (std::set<dataCacheDouble*>::iterator dep = r->_iDependOn.begin(); dep != r->_iDependOn.end(); dep++) { if (&(*dep)->_cacheMap == this) { + throw; r = NULL; break; } } } } - if (r==NULL) + if (r==NULL) { + if(_parent) + throw; r = new dataCacheDouble(this, (function*)(f)); + } if (caller) r->addMeAsDependencyOf(caller); return *r; diff --git a/Solver/function.h b/Solver/function.h index d099676280b563af99c627501336baf23b4598d7..84a38f783ccd9eae8e44dea8864d55fe39bcd9ec 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -147,6 +147,7 @@ class dgDataCacheMap; // more explanation at the head of this file class dataCacheMap { friend class dataCacheDouble; + protected: dataCacheMap *_parent; std::list<dataCacheMap*> _children; std::vector<dataCacheMap*> _secondaryCaches; @@ -155,15 +156,18 @@ class dataCacheMap { std::set<dataCacheDouble*> _allDataCaches; std::set<dataCacheDouble*> _toInvalidateOnElement; - MElement *_element; - protected: + MElement *_element; void addDataCacheDouble(dataCacheDouble *data, bool invalidatedOnElement){ _allDataCaches.insert(data); if(invalidatedOnElement) _toInvalidateOnElement.insert(data); } public: + void printList() { + for(std::set<dataCacheDouble*>::iterator it = _toInvalidateOnElement.begin(); it!= _toInvalidateOnElement.end(); it++) + printf("%p\n",*it); + } virtual dgDataCacheMap *asDgDataCacheMap() { Msg::Error("I'm not a dgDataCacheMap\n"); return NULL; @@ -195,7 +199,7 @@ class dataCacheMap { _nbEvaluationPoints = 0; _parent=NULL; } - dataCacheMap(dataCacheMap *parent) { + void setParent(dataCacheMap *parent) { _parent = parent; _parent->_children.push_back(this); _nbEvaluationPoints = 0;