DAG: Fix preprocessor definition inconsistencies

This commit is contained in:
Stefan Tröger 2017-01-19 06:55:23 +01:00 committed by wmayer
parent d9adc9cd6c
commit 4f8e046f7f
9 changed files with 45 additions and 37 deletions

View File

@ -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.

View File

@ -62,7 +62,7 @@ recompute path. Also enables more complicated dependencies beyond trees.
#include <boost/graph/subgraph.hpp>
#include <boost/graph/graphviz.hpp>
#if USE_OLD_DAG
#ifdef USE_OLD_DAG
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
@ -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<DocumentObject*,Vertex> VertexObjectList;
std::map<Vertex,DocumentObject*> vertexMap;
@ -1675,7 +1675,7 @@ std::vector<App::DocumentObject*> 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<Vertex>& out)
@ -1761,9 +1761,11 @@ Document::getDependencyList(const std::vector<App::DocumentObject*>& 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<App::DocumentObject*> Document::getDependencyList(const std::vector<App::DocumentObject*>& objs) const
{
std::vector<App::DocumentObject*> dep;
@ -1841,7 +1843,7 @@ void Document::renameObjectIdentifiers(const std::map<App::ObjectIdentifier, App
(*it)->renameObjectIdentifiers(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<App::DocumentObject*> 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<Vertex,DocumentObject*>::iterator it = d->vertexMap.begin(); it != d->vertexMap.end(); ++it) {

View File

@ -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;

View File

@ -182,7 +182,7 @@ std::vector<DocumentObject*> DocumentObject::getOutList(void) const
return ret;
}
#if USE_OLD_DAG
#ifdef USE_OLD_DAG
std::vector<App::DocumentObject*> DocumentObject::getInList(void) const
{
if (_pDoc)
@ -191,7 +191,7 @@ std::vector<App::DocumentObject*> DocumentObject::getInList(void) const
return std::vector<App::DocumentObject*>();
}
#else // if USE_OLD_DAG
#else // ifndef USE_OLD_DAG
std::vector<App::DocumentObject*> 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 <DocumentObject*> 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

View File

@ -142,8 +142,7 @@ public:
std::vector<App::DocumentObject*> 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
//@}
/**

View File

@ -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<DocumentObject*> 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<DocumentObject*> objs = getDocumentPtr()->getRootObjects();
Py::List res;

View File

@ -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<Expression>(it->second.expression->copy()), it->second.comment.c_str());
#if USE_OLD_DAG == 0
#ifndef USE_OLD_DAG
//maintain backlinks
std::set<ObjectIdentifier> 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<ObjectIdentifier> 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<ObjectIdentifier> deps;
expressions[usePath].expression->getDeps(deps);

View File

@ -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<DocumentObject*>(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<DocumentObject*>(getContainer()));
@ -236,7 +236,7 @@ void PropertyLinkList::setValue(DocumentObject* lValue)
void PropertyLinkList::setValues(const std::vector<DocumentObject*>& 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<DocumentObject*>(getContainer()));
@ -385,7 +385,7 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue, const std::vector<s
return; //nothing to do
aboutToSetValue();
#if USE_OLD_DAG == 0
#ifndef USE_OLD_DAG
if(_pcLinkSub)
_pcLinkSub->_removeBackLink(static_cast<App::DocumentObject*>(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<DocumentObject*>(getContainer()));
@ -609,7 +609,7 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& 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<DocumentObject*>& 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<DocumentObject*>& lValue,c
void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector<string> &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)

View File

@ -342,6 +342,4 @@ typedef unsigned __int64 uint64_t;
//# define _PreComp_ // use precompiled header
#endif
#define USE_OLD_DAG 0
#endif //FC_CONFIG_H