From 4f8e046f7fbf8f5b0eff22740e8b22360794ede0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Thu, 19 Jan 2017 06:55:23 +0100 Subject: [PATCH] DAG: Fix preprocessor definition inconsistencies --- src/App/CMakeLists.txt | 3 +++ src/App/Document.cpp | 18 ++++++++++-------- src/App/Document.h | 3 +-- src/App/DocumentObject.cpp | 24 ++++++++++++++++-------- src/App/DocumentObject.h | 4 +--- src/App/DocumentPyImp.cpp | 4 ++-- src/App/PropertyExpressionEngine.cpp | 8 ++++---- src/App/PropertyLinks.cpp | 16 ++++++++-------- src/FCConfig.h | 2 -- 9 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index be7a21313..fe2fb6627 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -14,6 +14,9 @@ ENDIF(DOCDIR) add_definitions(-DBOOST_${Boost_VERSION}) +#if you want to use the old DAG structure uncomment this line +#add_definitions(-DUSE_OLD_DAG) + #write relevant cmake variables to a file for later access with python. Exportet are all variables #starting with BUILD. As the variable only exists if the user set it to ON a dict is useless, we #use a python list for export. diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 9e6ecc2b0..be68a1bf5 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -62,7 +62,7 @@ recompute path. Also enables more complicated dependencies beyond trees. #include #include -#if USE_OLD_DAG +#ifdef USE_OLD_DAG #include #include #include @@ -150,7 +150,7 @@ struct DocumentP int iUndoMode; unsigned int UndoMemSize; unsigned int UndoMaxStackSize; -#if USE_OLD_DAG +#ifdef USE_OLD_DAG DependencyList DepList; std::map VertexObjectList; std::map vertexMap; @@ -1675,7 +1675,7 @@ std::vector Document::getInList(const DocumentObject* me) return result; } -#if USE_OLD_DAG +#ifdef USE_OLD_DAG namespace boost { // recursive helper function to get all dependencies void out_edges_recursive(const Vertex& v, const DependencyList& g, std::set& out) @@ -1761,9 +1761,11 @@ Document::getDependencyList(const std::vector& objs) const ary.push_back(VertexMap[*it]); return ary; } +#endif void Document::_rebuildDependencyList(void) { +#ifdef USE_OLD_DAG d->VertexObjectList.clear(); d->DepList.clear(); // Filling up the adjacency List @@ -1793,10 +1795,10 @@ void Document::_rebuildDependencyList(void) add_edge(d->VertexObjectList[It->second],d->VertexObjectList[*It2],d->DepList); } } +#endif } -#else - +#ifndef USE_OLD_DAG std::vector Document::getDependencyList(const std::vector& objs) const { std::vector dep; @@ -1841,7 +1843,7 @@ void Document::renameObjectIdentifiers(const std::maprenameObjectIdentifiers(extendedPaths); } -#if USE_OLD_DAG +#ifdef USE_OLD_DAG int Document::recompute() { int objectCount = 0; @@ -1961,7 +1963,7 @@ int Document::recompute() return objectCount; } -#else // USE_OLD_DAG +#else //ifdef USE_OLD_DAG std::vector Document::topologicalSort() const { @@ -2302,7 +2304,7 @@ void Document::remObject(const char* sName) signalTransactionRemove(*pos->second, 0); } -#if USE_OLD_DAG +#ifdef USE_OLD_DAG if (!d->vertexMap.empty()) { // recompute of document is running for (std::map::iterator it = d->vertexMap.begin(); it != d->vertexMap.end(); ++it) { diff --git a/src/App/Document.h b/src/App/Document.h index 92bc29932..41b8a2fc8 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -355,10 +355,9 @@ protected: /// helper which Recompute only this feature bool _recomputeFeature(DocumentObject* Feat); void _clearRedos(); -#if USE_OLD_DAG + /// refresh the internal dependency graph void _rebuildDependencyList(void); -#endif std::string getTransientDirectoryName(const std::string& uuid, const std::string& filename) const; diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 7883c9146..94525ac60 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -182,7 +182,7 @@ std::vector DocumentObject::getOutList(void) const return ret; } -#if USE_OLD_DAG +#ifdef USE_OLD_DAG std::vector DocumentObject::getInList(void) const { if (_pDoc) @@ -191,7 +191,7 @@ std::vector DocumentObject::getInList(void) const return std::vector(); } -#else // if USE_OLD_DAG +#else // ifndef USE_OLD_DAG std::vector DocumentObject::getInList(void) const { @@ -303,10 +303,9 @@ bool DocumentObject::testIfLinkDAGCompatible(PropertyLinkSub &linkTo) const return this->testIfLinkDAGCompatible(linkTo_in_vector); } -#if USE_OLD_DAG -#else bool DocumentObject::_isInInListRecursive(const DocumentObject *act, const DocumentObject* test, const DocumentObject* checkObj, int depth) const { +#ifndef USE_OLD_DAG if (std::find(_inList.begin(), _inList.end(), test) != _inList.end()) return true; @@ -322,23 +321,29 @@ bool DocumentObject::_isInInListRecursive(const DocumentObject *act, const Docum } return false; +#endif } bool DocumentObject::isInInListRecursive(DocumentObject *linkTo) const { +#ifndef USE_OLD_DAG return _isInInListRecursive(this, linkTo, this, getDocument()->countObjects()); +#endif } bool DocumentObject::isInInList(DocumentObject *linkTo) const { +#ifndef USE_OLD_DAG if (std::find(_inList.begin(), _inList.end(), linkTo) != _inList.end()) return true; else return false; +#endif } bool DocumentObject::_isInOutListRecursive(const DocumentObject *act, const DocumentObject* test, const DocumentObject* checkObj, int depth) const { +#ifndef USE_OLD_DAG std::vector outList = act->getOutList(); if (std::find(outList.begin(), outList.end(), test) != outList.end()) @@ -356,13 +361,15 @@ bool DocumentObject::_isInOutListRecursive(const DocumentObject *act, const Docu } return false; +#endif } bool DocumentObject::isInOutListRecursive(DocumentObject *linkTo) const { +#ifndef USE_OLD_DAG return _isInOutListRecursive(this, linkTo, this, getDocument()->countObjects()); +#endif } -#endif //USE_OLD_DAG void DocumentObject::onLostLinkToObject(DocumentObject*) { @@ -541,16 +548,17 @@ void DocumentObject::unsetupObject() ext->onExtendedUnsetupObject(); } -#if USE_OLD_DAG -#else void App::DocumentObject::_removeBackLink(DocumentObject* rmfObj) { +#ifndef USE_OLD_DAG _inList.erase(std::remove(_inList.begin(), _inList.end(), rmfObj), _inList.end()); +#endif } void App::DocumentObject::_addBackLink(DocumentObject* newObje) { +#ifndef USE_OLD_DAG if ( std::find(_inList.begin(), _inList.end(), newObje) == _inList.end() ) _inList.push_back(newObje); +#endif //USE_OLD_DAG } -#endif //USE_OLD_DAG \ No newline at end of file diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 72f26662d..dda66f69f 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -142,8 +142,7 @@ public: std::vector getInListRecursive(void) const; /// get group if object is part of a group, otherwise 0 is returned DocumentObjectGroup* getGroup() const; -#if USE_OLD_DAG -#else + /// test if this object is in the InList and recursive further down bool isInInListRecursive(DocumentObject* objToTest) const; /// test if this object is directly (non recursive) in the InList @@ -156,7 +155,6 @@ public: void _removeBackLink(DocumentObject*); /// internal, used by ProperyLink to maintain DAG back links void _addBackLink(DocumentObject*); -#endif //USE_OLD_DAG //@} /** diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 88296ce9d..a73ba2096 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -492,7 +492,7 @@ Py::List DocumentPy::getObjects(void) const Py::List DocumentPy::getToplogicalSortedObjects(void) const { -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG std::vector objs = getDocumentPtr()->topologicalSort(); Py::List res; @@ -508,7 +508,7 @@ Py::List DocumentPy::getToplogicalSortedObjects(void) const Py::List DocumentPy::getRootObjects(void) const { -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG std::vector objs = getDocumentPtr()->getRootObjects(); Py::List res; diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 944fea6ec..d14662106 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -123,7 +123,7 @@ void PropertyExpressionEngine::Paste(const Property &from) AtomicPropertyChange signaller(*this); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks ExpressionMap::const_iterator i = expressions.begin(); while (i != expressions.end()) { @@ -148,7 +148,7 @@ void PropertyExpressionEngine::Paste(const Property &from) for (ExpressionMap::const_iterator it = fromee->expressions.begin(); it != fromee->expressions.end(); ++it) { expressions[it->first] = ExpressionInfo(boost::shared_ptr(it->second.expression->copy()), it->second.comment.c_str()); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks std::set deps; it->second.expression->getDeps(deps); @@ -404,7 +404,7 @@ void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, boost::sh AtomicPropertyChange signaller(*this); expressions[usePath] = ExpressionInfo(expr, comment); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain the backlinks in the documentobject graph datastructure std::set deps; expr->getDeps(deps); @@ -425,7 +425,7 @@ void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, boost::sh AtomicPropertyChange signaller(*this); expressions.erase(usePath); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain the backlinks in the documentobject graph datastructure std::set deps; expressions[usePath].expression->getDeps(deps); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index de49b6cdf..3794bc861 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -80,7 +80,7 @@ void PropertyLink::setValue(App::DocumentObject * lValue) return; // nothing to do aboutToSetValue(); -#if USE_OLD_DAG==0 +#ifndef USE_OLD_DAG // maintain the back link in the DocumentObject class if(_pcLink) _pcLink->_removeBackLink(static_cast(getContainer())); @@ -212,7 +212,7 @@ int PropertyLinkList::getSize(void) const void PropertyLinkList::setValue(DocumentObject* lValue) { -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain the back link in the DocumentObject class for(auto *obj : _lValueList) obj->_removeBackLink(static_cast(getContainer())); @@ -236,7 +236,7 @@ void PropertyLinkList::setValue(DocumentObject* lValue) void PropertyLinkList::setValues(const std::vector& lValue) { aboutToSetValue(); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain the back link in the DocumentObject class for(auto *obj : _lValueList) obj->_removeBackLink(static_cast(getContainer())); @@ -385,7 +385,7 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue, const std::vector_removeBackLink(static_cast(getContainer())); if(lValue) @@ -580,7 +580,7 @@ int PropertyLinkSubList::getSize(void) const void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName) { -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks for(auto *obj : _lValueList) obj->_removeBackLink(static_cast(getContainer())); @@ -609,7 +609,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c if (lValue.size() != lSubNames.size()) throw Base::Exception("PropertyLinkSubList::setValues: size of subelements list != size of objects list"); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks. _lValueList can contain items multiple times, but we trust the document //object to ensure that this works for(auto *obj : _lValueList) @@ -635,7 +635,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c if (lValue.size() != lSubNames.size()) throw Base::Exception("PropertyLinkSubList::setValues: size of subelements list != size of objects list"); -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks. _lValueList can contain items multiple times, but we trust the document //object to ensure that this works for(auto *obj : _lValueList) @@ -655,7 +655,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector &SubList) { -#if USE_OLD_DAG == 0 +#ifndef USE_OLD_DAG //maintain backlinks. _lValueList can contain items multiple times, but we trust the document //object to ensure that this works for(auto *obj : _lValueList) diff --git a/src/FCConfig.h b/src/FCConfig.h index 4b771bbf4..eca969c0a 100644 --- a/src/FCConfig.h +++ b/src/FCConfig.h @@ -342,6 +342,4 @@ typedef unsigned __int64 uint64_t; //# define _PreComp_ // use precompiled header #endif -#define USE_OLD_DAG 0 - #endif //FC_CONFIG_H